hedgewars/CMakeLists.txt
changeset 7109 af3a43a46f21
parent 7031 d5ea24399a48
child 7112 38c5d56c4d6e
equal deleted inserted replaced
7107:1982e702ed2f 7109:af3a43a46f21
   169         ARGS ${pascal_compiler_flags}
   169         ARGS ${pascal_compiler_flags}
   170         MAIN_DEPENDENCY ${hwengine_project}
   170         MAIN_DEPENDENCY ${hwengine_project}
   171         DEPENDS ${engine_sources}
   171         DEPENDS ${engine_sources}
   172         )
   172         )
   173 ELSE()
   173 ELSE()
   174     #let's build sdlmain, which is absent from the framework
   174     #on OSX we need to provide the main() function when building as executable
   175     find_package(SDL REQUIRED)
   175     if(NOT BUILD_ENGINE_LIBRARY)
   176 
   176         #let's look for the bundled sdlmain, if not found build our own
   177     set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
   177         find_package(SDL REQUIRED)
   178     include_directories(${SDL_INCLUDE_DIR})
   178         #remove the ";-framework Cocoa" from the SDL_LIBRARY variable
   179 
   179         string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
   180     add_library (SDLmain STATIC SDLMain.m)
   180         #find libsdmain.a
   181 
   181         find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/)
       
   182 
       
   183         if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
       
   184             set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
       
   185             include_directories(${SDL_INCLUDE_DIR})
       
   186             add_library (SDLmain STATIC SDLMain.m)
       
   187             #add a dependency to the hwengine target
       
   188             set(engine_sources ${engine_sources} "SDLmain")
       
   189             set(SDLMAIN_LIB "${CMAKE_BINARY_DIR}/bin/libSDLmain.a")
       
   190         endif()
       
   191 
       
   192         set(pascal_compiler_flags "-k${SDLMAIN_LIB}" ${pascal_compiler_flags})
       
   193     endif()
   182 
   194 
   183     #these are the dependencies for building a universal binary on Mac OS X
   195     #these are the dependencies for building a universal binary on Mac OS X
   184     foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
   196     foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
   185         set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list})
   197         set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list})
   186         add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}"
   198         add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}"
   187             COMMAND "${pascal_compiler}"
   199             COMMAND "${pascal_compiler}"
   188             ARGS ${pascal_compiler_flags} -ohwengine.${build_arch} -P${build_arch}
   200             ARGS ${pascal_compiler_flags} -ohwengine.${build_arch} -P${build_arch}
   189             MAIN_DEPENDENCY ${hwengine_project}
   201             MAIN_DEPENDENCY ${hwengine_project}
   190             DEPENDS ${engine_sources} SDLmain
   202             DEPENDS ${engine_sources}
   191             )
   203             )
   192         add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
   204         add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
   193     endforeach()
   205     endforeach()
   194 
   206 
   195     add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}"
   207     add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}"