hedgewars/CMakeLists.txt
branchcmake_pascal
changeset 8843 843a9a405542
parent 8840 e1be48f36b82
child 8846 c156ac6ddc2b
equal deleted inserted replaced
8840:e1be48f36b82 8843:843a9a405542
   118     endif()
   118     endif()
   119 
   119 
   120     #on OSX we need to provide the SDL_main() function when building as executable
   120     #on OSX we need to provide the SDL_main() function when building as executable
   121     if(NOT BUILD_ENGINE_LIBRARY)
   121     if(NOT BUILD_ENGINE_LIBRARY)
   122         add_subdirectory(sdlmain)
   122         add_subdirectory(sdlmain)
       
   123         list(APPEND HW_LINK_LIBS SDLmain)
   123         add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
   124         add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
   124     endif()
   125     endif()
   125 endif(APPLE)
   126 endif(APPLE)
   126 
   127 
   127 if(FFMPEG_FOUND)
   128 if(FFMPEG_FOUND)
   128     add_subdirectory(avwrapper)
   129     add_subdirectory(avwrapper)
       
   130     list(APPEND HW_LINK_LIBS avwrapper)
   129     add_definitions(-dUSE_VIDEO_RECORDING)
   131     add_definitions(-dUSE_VIDEO_RECORDING)
   130     add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
   132     add_flag_append(CMAKE_Pascal_FLAGS -Fl${LIBRARY_OUTPUT_PATH})
   131 endif()
   133 endif()
   132 
   134 
   133 find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
   135 find_package_or_disable_msg(PNG NOPNG "Screenshots will be saved in BMP")
   136     add_definitions(-dPNG_SCREENSHOTS)
   138     add_definitions(-dPNG_SCREENSHOTS)
   137     add_flag_append(CMAKE_Pascal_FLAGS -Fl${PNG_LIB_DIR})
   139     add_flag_append(CMAKE_Pascal_FLAGS -Fl${PNG_LIB_DIR})
   138 endif()
   140 endif()
   139 
   141 
   140 if(NOT LUA_FOUND)
   142 if(NOT LUA_FOUND)
       
   143     list(APPEND HW_LINK_LIBS lua)
   141     add_flag_append(CMAKE_Pascal_FLAGS -k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a)
   144     add_flag_append(CMAKE_Pascal_FLAGS -k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a)
   142     #linking with liblua.a requires system readline
   145     #linking with liblua.a requires system readline
   143     if(UNIX)
   146     if(UNIX)
   144         add_flag_append(CMAKE_Pascal_FLAGS -k-lreadline)
   147         add_flag_append(CMAKE_Pascal_FLAGS -k-lreadline)
   145     endif(UNIX)
   148     endif(UNIX)
   146 endif()
   149 endif()
   147 
   150 
   148 if(NOT PHYSFS_FOUND)
   151 if(NOT PHYSFS_FOUND)
       
   152     add_definitions(-dPHYSFS_INTERNAL)
       
   153     list(APPEND HW_LINK_LIBS physfs)
   149     #-XLA is a beta fpc flag that renames libraries before passing them to the linker
   154     #-XLA is a beta fpc flag that renames libraries before passing them to the linker
   150     #we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements
   155     #we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements
   151     #(should be harmless on other platforms)
   156     #(should be harmless on other platforms)
   152     add_flag_append(CMAKE_Pascal_FLAGS "-XLAphysfs=${physfs_output_name}")
   157     add_flag_append(CMAKE_Pascal_FLAGS "-XLAphysfs=${physfs_output_name}")
   153     add_definitions(-dPHYSFS_INTERNAL)
       
   154 endif()
   158 endif()
   155 
   159 list(APPEND HW_LINK_LIBS physlayer)
   156 
   160 
   157 if(HAVE_MIXINIT)
   161 if(HAVE_MIXINIT)
   158     add_definitions(-dSDL_MIXER_NEWER)
   162     add_definitions(-dSDL_MIXER_NEWER)
   159 endif(HAVE_MIXINIT)
   163 endif(HAVE_MIXINIT)
   160 
   164 
   184     set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
   188     set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
   185     set(destination_dir ${target_binary_install_dir})
   189     set(destination_dir ${target_binary_install_dir})
   186     add_executable(hwengine ${engine_sources})
   190     add_executable(hwengine ${engine_sources})
   187 endif()
   191 endif()
   188 
   192 
   189 
   193 target_link_libraries(hwengine ${HW_LINK_LIBS})
   190 #when system Lua is not found we need to compile it before engine
       
   191 if(NOT LUA_FOUND)
       
   192     target_link_libraries(hwengine lua)
       
   193 endif()
       
   194 
       
   195 # same for physfs
       
   196 if(NOT PHYSFS_FOUND)
       
   197     target_link_libraries(hwengine physfs)
       
   198 endif()
       
   199 
       
   200 target_link_libraries(hwengine physlayer)
       
   201 
       
   202 #when ffmpeg/libav is found we need to compile it before engine
       
   203 #TODO: convert avwrapper to .pas unit so we can skip this step
       
   204 if(${FFMPEG_FOUND})
       
   205     target_link_libraries(hwengine avwrapper)
       
   206 endif()
       
   207 
       
   208 if(APPLE AND NOT BUILD_ENGINE_LIBRARY)
       
   209     target_link_libraries(hwengine SDLmain)
       
   210 endif()
       
   211 
   194 
   212 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})
   195 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})