hedgewars/CMakeLists.txt
changeset 8316 89232b2fa1d6
parent 8314 7faceaca67d4
child 8322 50369fa5053b
equal deleted inserted replaced
8315:b3875e10a8ae 8316:89232b2fa1d6
    88     options.inc
    88     options.inc
    89     adler32.pas
    89     adler32.pas
    90     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
    90     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
    91     )
    91     )
    92 
    92 
    93 if(BUILD_ENGINE_LIBRARY)
    93 if(${BUILD_ENGINE_LIBRARY})
    94     message(WARNING "Engine will be built as library (experimental)")
    94     message(WARNING "Engine will be built as library (experimental)")
    95     set(pascal_flags "-dHWLIBRARY" ${pascal_flags})
    95     set(pascal_flags "-dHWLIBRARY" ${pascal_flags})
    96 
    96 
    97     # create position independent code, only required for x68_64 builds, similar to -fPIC
    97     # create position independent code, only required for x68_64 builds, similar to -fPIC
    98     if(CMAKE_SIZEOF_VOID_P MATCHES "8")
    98     if(CMAKE_SIZEOF_VOID_P MATCHES "8")
   101 
   101 
   102     # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
   102     # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
   103     if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
   103     if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
   104         set(pascal_flags "-k-no_order_inits" ${pascal_flags})
   104         set(pascal_flags "-k-no_order_inits" ${pascal_flags})
   105     endif()
   105     endif()
   106 endif(BUILD_ENGINE_LIBRARY)
   106     set(destination_dir ${target_library_install_dir})
       
   107 else(${BUILD_ENGINE_LIBRARY})
       
   108     set(destination_dir ${target_binary_install_dir})
       
   109 endif(${BUILD_ENGINE_LIBRARY})
   107 
   110 
   108 
   111 
   109 # Check Freepascal version
   112 # Check Freepascal version
   110 find_package(Freepascal)
   113 find_package(Freepascal)
   111 
   114 
   123     if(powerpc_build)
   126     if(powerpc_build)
   124         set(powerpc_build "powerpc")
   127         set(powerpc_build "powerpc")
   125     endif()
   128     endif()
   126 
   129 
   127     #on OSX we need to provide the SDL_main() function when building as executable
   130     #on OSX we need to provide the SDL_main() function when building as executable
   128     if(NOT BUILD_ENGINE_LIBRARY)
   131     if(NOT ${BUILD_ENGINE_LIBRARY})
   129         #let's look for the installed sdlmain file; if it is not found, let's build our own
   132         #let's look for the installed sdlmain file; if it is not found, let's build our own
   130         find_package(SDL REQUIRED)
   133         find_package(SDL REQUIRED)
   131         #remove the ";-framework Cocoa" from the SDL_LIBRARY variable
   134         #remove the ";-framework Cocoa" from the SDL_LIBRARY variable
   132         string(REGEX REPLACE "(.*);-.*" "\\1" sdl_dir "${SDL_LIBRARY}")
   135         string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL_LIBRARY}")
   133         #find libsdmain.a
   136         #find libsdmain.a
   134         find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_dir}/Resources/)
   137         find_file(SDLMAIN_LIB libSDLMain.a PATHS ${sdl_library_only}/Resources/)
   135 
   138 
   136         if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
   139         if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND")
   137             include_directories(${SDL_INCLUDE_DIR})
   140             include_directories(${SDL_INCLUDE_DIR})
   138             add_library (SDLmain STATIC SDLMain.m)
   141             add_library (SDLmain STATIC SDLMain.m)
   139             #add a dependency to the hwengine target
   142             #add a dependency to the hwengine target
   185         set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags})
   188         set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags})
   186         IF (WIN32)
   189         IF (WIN32)
   187             # there are some problems with linking our avwrapper as static lib, so link it as shared
   190             # there are some problems with linking our avwrapper as static lib, so link it as shared
   188             add_library(avwrapper SHARED avwrapper.c)
   191             add_library(avwrapper SHARED avwrapper.c)
   189             target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
   192             target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
   190             install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_dir})
   193             install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir})
   191         ELSE()
   194         ELSE()
   192             add_library(avwrapper STATIC avwrapper.c)
   195             add_library(avwrapper STATIC avwrapper.c)
   193             set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags})
   196             set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags})
   194         ENDIF()
   197         ENDIF()
   195     else()
   198     else()
   250 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   253 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   251 if((FPC_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND}))
   254 if((FPC_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND}))
   252     add_dependencies(${engine_output_name} ENGINECLEAN)
   255     add_dependencies(${engine_output_name} ENGINECLEAN)
   253 endif()
   256 endif()
   254 
   257 
   255 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${target_dir})
   258 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})