hedgewars/CMakeLists.txt
changeset 7718 97ba379164ec
parent 7708 95de696e4711
child 7730 2013733f9ca9
equal deleted inserted replaced
7717:2684fdb9d874 7718:97ba379164ec
   135         string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
   135         string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
   136         #find libsdmain.a
   136         #find libsdmain.a
   137         find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/)
   137         find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/)
   138 
   138 
   139         if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
   139         if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
   140             set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
       
   141             include_directories(${SDL_INCLUDE_DIR})
   140             include_directories(${SDL_INCLUDE_DIR})
   142             add_library (SDLmain STATIC SDLMain.m)
   141             add_library (SDLmain STATIC SDLMain.m)
   143             #add a dependency to the hwengine target
   142             #add a dependency to the hwengine target
   144             set(engine_sources ${engine_sources} SDLmain)
   143             set(engine_sources ${engine_sources} SDLmain)
   145             set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
   144             set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a")
   172 
   171 
   173 #DEPENDECIES AND EXECUTABLES SECTION
   172 #DEPENDECIES AND EXECUTABLES SECTION
   174 if(NOT NOPNG)
   173 if(NOT NOPNG)
   175     find_package(PNG)
   174     find_package(PNG)
   176     if(${PNG_FOUND})
   175     if(${PNG_FOUND})
   177         message(STATUS "PNG screenshots enabled (library found at ${PNG_LIBRARY})")
   176         message(STATUS "Found libpng: ${PNG_LIBRARY}")
   178         set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags})
   177         set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags})
   179         if(APPLE)  # need to explictly link with the static lib -- maybe windows too?
   178         if(APPLE)  # need to explictly link with the static lib -- maybe windows too?
   180             string(REGEX REPLACE "(.*)libpng.*" "\\1" PNG_LIBDIR "${PNG_LIBRARY}")
   179             string(REGEX REPLACE "(.*)libpng.*" "\\1" PNG_LIBDIR "${PNG_LIBRARY}")
   181             set(pascal_flags "-k${PNG_LIBDIR}/libpng.a" ${pascal_flags})
   180             set(pascal_flags "-k${PNG_LIBDIR}/libpng.a" ${pascal_flags})
   182         endif()
   181         endif()
   183     else()
   182     else()
   184         message(STATUS "PNG library not found, switching to screenshots in BMP format")
   183         message(STATUS "Screenshots will be in BMP format because libpng was not found")
   185     endif()
   184     endif()
   186 else()
   185 else()
   187     message(STATUS "PNG screenshots disabled per user request, using BMP format")
   186     message(STATUS "Screenshots will be in BMP format per user request")
   188 endif()
   187 endif()
   189 
   188 
   190 
   189 
   191 
   190 
   192 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   191 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   193 if(fpc_version LESS "020600")
   192 if(fpc_version LESS "020600")
   194     add_custom_target(ENGINECLEAN COMMAND ${CMAKE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars")
   193     add_custom_target(ENGINECLEAN COMMAND ${CMAKE_BUILD_TOOL} "clean" "${PROJECT_BINARY_DIR}" "${hedgewars_SOURCE_DIR}/hedgewars")
   195 endif()
   194 endif()
   196 
   195 
   197 
   196 
   198 if(NOT NO_VIDEOREC)
   197 if(NOT NOVIDEOREC)
   199     if(${FFMPEG_FOUND})
   198     if(${FFMPEG_FOUND})
   200         message(STATUS "Compiling with video recording")
   199         message(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
   201         include_directories(${FFMPEG_INCLUDE_DIR})
   200         include_directories(${FFMPEG_INCLUDE_DIR})
   202         set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags})
   201         set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags})
   203         set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
       
   204         IF (WIN32)
   202         IF (WIN32)
   205             # there are some problems with linking our avwrapper as static lib, so link it as shared
   203             # there are some problems with linking our avwrapper as static lib, so link it as shared
   206             add_library(avwrapper SHARED avwrapper.c)
   204             add_library(avwrapper SHARED avwrapper.c)
   207             target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
   205             target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
   208             install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_dir})
   206             install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_dir})
   213         ENDIF()
   211         ENDIF()
   214         if(fpc_version LESS "020600")
   212         if(fpc_version LESS "020600")
   215             add_dependencies(avwrapper ENGINECLEAN)
   213             add_dependencies(avwrapper ENGINECLEAN)
   216         endif()
   214         endif()
   217     else()
   215     else()
   218         message(STATUS "FFMPEG library not found, video recording will be disabled")
   216         message(STATUS "Could NOT find FFMPEG, video recording will be disabled")
   219     endif()
   217     endif()
   220 else()
   218 else()
   221     message(STATUS "Video recording disabled by user")
   219     message(STATUS "Video recording disabled by user")
   222 endif()
   220 endif()
   223 
   221