hedgewars/CMakeLists.txt
changeset 8666 1652c1d9adc8
parent 8665 3ff8694d9e22
child 8669 3f9853888d4f
equal deleted inserted replaced
8665:3ff8694d9e22 8666:1652c1d9adc8
   187     endif()
   187     endif()
   188     add_custom_target(ENGINECLEAN COMMAND ${SAFE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars")
   188     add_custom_target(ENGINECLEAN COMMAND ${SAFE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars")
   189 endif()
   189 endif()
   190 
   190 
   191 
   191 
   192 if(NOT NOVIDEOREC)
   192 if(${FFMPEG_FOUND})
   193     find_package(FFMPEG)
   193     # TODO: this check is only for SDL < 2
   194     if(${FFMPEG_FOUND})
   194     # fpc will take care of linking but we need to have this library installed
   195         # TODO: this check is only for SDL < 2
   195     find_package(GLUT REQUIRED)
   196         # fpc will take care of linking but we need to have this library installed
   196 
   197         find_package(GLUT REQUIRED)
   197     #TODO: convert avwrapper to .pas unit so we can skip this step
   198 
   198     include_directories(${FFMPEG_INCLUDE_DIR})
   199         #TODO: convert avwrapper to .pas unit so we can skip this step
   199     list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING")
   200         include_directories(${FFMPEG_INCLUDE_DIR})
   200     if(WIN32)
   201         list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING")
   201         # there are some problems with linking our avwrapper as static lib, so link it as shared
   202         IF (WIN32)
   202         add_library(avwrapper SHARED avwrapper.c)
   203             # there are some problems with linking our avwrapper as static lib, so link it as shared
   203         target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
   204             add_library(avwrapper SHARED avwrapper.c)
   204         install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir})
   205             target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
       
   206             install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir})
       
   207         ELSE()
       
   208             add_library(avwrapper STATIC avwrapper.c)
       
   209             list(APPEND pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}")
       
   210         ENDIF()
       
   211     else()
   205     else()
   212         message(${WARNING} "Could NOT find FFMPEG/LibAV, video recording will be disabled")
   206         add_library(avwrapper STATIC avwrapper.c)
   213     endif()
   207     endif()
   214 else()
       
   215     message(STATUS "Video recording disabled by user")
       
   216 endif()
   208 endif()
   217 
   209 
   218 
   210 
   219 set(fpc_flags ${pascal_flags} ${hwengine_project})
   211 set(fpc_flags ${pascal_flags} ${hwengine_project})
   220 
   212 
   271 if(${FFMPEG_FOUND})
   263 if(${FFMPEG_FOUND})
   272     add_dependencies(hwengine avwrapper)
   264     add_dependencies(hwengine avwrapper)
   273 endif()
   265 endif()
   274 
   266 
   275 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   267 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   276 if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND}))
   268 if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOT ${FFMPEG_FOUND}))
   277     add_dependencies(hwengine ENGINECLEAN)
   269     add_dependencies(hwengine ENGINECLEAN)
   278 endif()
   270 endif()
   279 
   271 
   280 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})
   272 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})