hedgewars/CMakeLists.txt
branchwebgl
changeset 9130 4f4b71da3559
parent 9127 e350500c4edb
child 9160 fc46e75f6b72
equal deleted inserted replaced
9127:e350500c4edb 9130:4f4b71da3559
   146         set(powerpc_build "powerpc")
   146         set(powerpc_build "powerpc")
   147     endif()
   147     endif()
   148 
   148 
   149     #on OSX we need to provide the SDL_main() function when building as executable
   149     #on OSX we need to provide the SDL_main() function when building as executable
   150     if(NOT ${LIBENGINE})
   150     if(NOT ${LIBENGINE})
   151         #let's look for the installed sdlmain file; if it is not found, let's build our own
   151         add_subdirectory(sdlmain_osx)
   152         find_package(SDL REQUIRED)
   152         list(APPEND pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
   153         #remove the ";-framework Cocoa" from the SDL_LIBRARY variable
       
   154         string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL_LIBRARY}")
       
   155         #find libsdmain.a
       
   156         find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_library_only}/Resources/)
       
   157 
       
   158         if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
       
   159             include_directories(${SDL_INCLUDE_DIR})
       
   160             add_library (SDLmain STATIC sdlmain_osx/SDLMain.m)
       
   161             #add a dependency to the hwengine target
       
   162             list(APPEND engine_sources SDLmain)
       
   163             set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
       
   164         endif()
       
   165 
       
   166         list(APPEND pascal_flags "-k${SDLMAIN_LIB}")
       
   167     endif()
   153     endif()
   168 
   154 
   169     #when you have multiple ld installation make sure you get the one bundled with the compiler
   155     #when you have multiple ld installation make sure you get the one bundled with the compiler
   170     get_filename_component(compiler_dir ${CMAKE_C_COMPILER} PATH)
   156     get_filename_component(compiler_dir ${CMAKE_C_COMPILER} PATH)
   171     list(APPEND pascal_flags "-FD${compiler_dir}")
   157     list(APPEND pascal_flags "-FD${compiler_dir}")
   265 #TODO: convert avwrapper to .pas unit so we can skip this step
   251 #TODO: convert avwrapper to .pas unit so we can skip this step
   266 if(${FFMPEG_FOUND})
   252 if(${FFMPEG_FOUND})
   267     add_dependencies(hwengine avwrapper)
   253     add_dependencies(hwengine avwrapper)
   268 endif()
   254 endif()
   269 
   255 
       
   256 if(APPLE)
       
   257     add_dependencies(hwengine SDLmain)
       
   258 endif(APPLE)
       
   259 
   270 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   260 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   271 if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOT ${FFMPEG_FOUND}))
   261 if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOT ${FFMPEG_FOUND}))
   272     add_dependencies(hwengine ENGINECLEAN)
   262     add_dependencies(hwengine ENGINECLEAN)
   273 endif()
   263 endif()
   274 
   264