hedgewars/CMakeLists.txt
changeset 8311 bc18481dca8b
parent 8283 af97cdbb7713
child 8312 9e8781faabab
equal deleted inserted replaced
8310:a98c349bc06b 8311:bc18481dca8b
     8 
     8 
     9 configure_file(${hedgewars_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
     9 configure_file(${hedgewars_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
    10 
    10 
    11 #SOURCE AND PROGRAMS SECTION
    11 #SOURCE AND PROGRAMS SECTION
    12 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
    12 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
    13 set(engine_output_name "hwengine")
    13 set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
    14 
    14 
    15 if (APPLE)
    15 if (APPLE)
    16     set(required_fpc_version 2.6)
    16     set(required_fpc_version 2.6)
    17 else()
    17 else()
    18     set(required_fpc_version 2.2)
    18     set(required_fpc_version 2.2)
    84     adler32.pas
    84     adler32.pas
    85     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
    85     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
    86     )
    86     )
    87 
    87 
    88 if(BUILD_ENGINE_LIBRARY)
    88 if(BUILD_ENGINE_LIBRARY)
    89     message(STATUS "Engine will be built as library (experimental)")
    89     message(WARNING "Engine will be built as library (experimental)")
    90     set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas)
    90     set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas)
    91     set(pascal_flags "-dHWLIBRARY" ${pascal_flags})
    91     set(pascal_flags "-dHWLIBRARY" ${pascal_flags})
    92 
    92 
    93     # create position independent code, only required for x68_64 builds, similar to -fPIC
    93     # create position independent code, only required for x68_64 builds, similar to -fPIC
    94     if(CMAKE_SIZEOF_VOID_P MATCHES "8")
    94     if(CMAKE_SIZEOF_VOID_P MATCHES "8")
    95         set(pascal_flags "-Cg" ${pascal_flags})
    95         set(pascal_flags "-Cg" ${pascal_flags})
    96     endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
    96     endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
    97 
    97 
    98     # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
    98     # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
    99     if(APPLE AND current_macosx_version GREATER "10.5")
    99     if(APPLE AND current_macosx_version VERSION_GREATER "10.5")
   100         set(pascal_flags "-k-no_order_inits" ${pascal_flags})
   100         set(pascal_flags "-k-no_order_inits" ${pascal_flags})
   101     endif()
   101     endif()
   102 
   102 
   103     if(APPLE)
   103     if (WIN32)
   104         set(engine_output_name "libhwengine.dylib")
   104         # windows is silly and takes the name specified in hwLibrary.pas
   105     endif (APPLE)
   105         set(engine_output_name "hwLibrary.dll")
       
   106         #set(pascal_flags "-D" "-Dv'${HEDGEWARS_VERSION}'" "-Dd'Hedgewars engine'" ${pascal_flags})
       
   107     elseif (WIN32)
       
   108         if (APPLE)
       
   109             set(engine_output_name "libhwengine.dylib")
       
   110         else (APPLE)
       
   111             set(engine_output_name "libhwengine.so")
       
   112         endif (APPLE)
       
   113     endif (WIN32)
       
   114 
   106 endif(BUILD_ENGINE_LIBRARY)
   115 endif(BUILD_ENGINE_LIBRARY)
   107 
   116 
   108 
   117 
   109 # Check Freepascal version
   118 # Check Freepascal version
   110 find_package(Freepascal)
   119 find_package(Freepascal)
   202 
   211 
   203 set(fpc_flags ${NOEXECSTACK_FLAGS} ${pascal_flags} ${hwengine_project})
   212 set(fpc_flags ${NOEXECSTACK_FLAGS} ${pascal_flags} ${hwengine_project})
   204 
   213 
   205 if(NOT APPLE)
   214 if(NOT APPLE)
   206     #here is the command for standard executables or for shared library
   215     #here is the command for standard executables or for shared library
   207     add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}"
   216     add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}"
   208         COMMAND "${FPC_EXECUTABLE}"
   217         COMMAND "${FPC_EXECUTABLE}"
   209         ARGS ${fpc_flags}
   218         ARGS ${fpc_flags}
   210         MAIN_DEPENDENCY ${hwengine_project}
   219         MAIN_DEPENDENCY ${hwengine_project}
   211         DEPENDS ${engine_sources}
   220         DEPENDS ${engine_sources}
   212         )
   221         )
   229         DEPENDS ${lipo_args_list}
   238         DEPENDS ${lipo_args_list}
   230         )
   239         )
   231 endif()
   240 endif()
   232 
   241 
   233 
   242 
   234 add_custom_target(${engine_output_name} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}")
   243 add_custom_target(${engine_output_name} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}")
   235 
   244 
   236 #when system Lua is not found we need to compile it before engine
   245 #when system Lua is not found we need to compile it before engine
   237 if(NOT LUA_FOUND)
   246 if(NOT LUA_FOUND)
   238     add_dependencies(${engine_output_name} lua)
   247     add_dependencies(${engine_output_name} lua)
   239 endif()
   248 endif()
   250 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   259 #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}))
   260 if((FPC_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND}))
   252     add_dependencies(${engine_output_name} ENGINECLEAN)
   261     add_dependencies(${engine_output_name} ENGINECLEAN)
   253 endif()
   262 endif()
   254 
   263 
   255 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})
   264 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${target_dir})