hedgewars/CMakeLists.txt
branchcmake_pascal
changeset 8752 48cf2ccb83c6
parent 8702 a28966180a29
child 8754 0c08d07e791a
equal deleted inserted replaced
8750:d9e57426e759 8752:48cf2ccb83c6
    15 if(HAVE_IMGINIT)
    15 if(HAVE_IMGINIT)
    16     list(APPEND pascal_flags "-dSDL_IMAGE_NEWER")
    16     list(APPEND pascal_flags "-dSDL_IMAGE_NEWER")
    17 endif()
    17 endif()
    18 
    18 
    19 
    19 
       
    20 enable_language(Pascal)
    20 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
    21 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
    21 
    22 
    22 #SOURCE AND PROGRAMS SECTION
    23 #SOURCE AND PROGRAMS SECTION
    23 if(${BUILD_ENGINE_LIBRARY})
    24 #if(${BUILD_ENGINE_LIBRARY})
    24     set(engine_output_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
    25 #    set(engine_output_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
    25     set(hwengine_project hwLibrary.pas)
    26 #    set(hwengine_project hwLibrary.pas)
    26 else()
    27 #else()
    27     set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
    28 #    set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
    28     set(hwengine_project hwengine.pas)
    29 #    set(hwengine_project hwengine.pas)
    29 endif()
    30 #endif()
    30 
    31 
    31 if (APPLE)
    32 if (APPLE)
    32     set(required_fpc_version 2.6)
    33     set(required_fpc_version 2.6)
    33 else()
    34 else()
    34     set(required_fpc_version 2.2)
    35     set(required_fpc_version 2.2)
   201         add_library(avwrapper STATIC avwrapper.c)
   202         add_library(avwrapper STATIC avwrapper.c)
   202     endif()
   203     endif()
   203 endif()
   204 endif()
   204 
   205 
   205 
   206 
       
   207 set(CMAKE_Pascal_FLAGS "-B -FE${PROJECT_BINARY_DIR}/bin -FU${PROJECT_BINARY_DIR}/hedgewars -vm4079,4080,4081 -Fl${PROJECT_BINARY_DIR}/bin -Px86_64   -Fi${PROJECT_BINARY_DIR}/hedgewars -k-L${PROJECT_BINARY_DIR}/bin -Cs2000000 -vewnq -dDEBUGFILE -k-llua -k${SDLMAIN_LIB}")
       
   208 add_executable(hwengine hwengine.pas)
       
   209 
   206 set(fpc_flags ${pascal_flags} ${hwengine_project})
   210 set(fpc_flags ${pascal_flags} ${hwengine_project})
   207 
   211 
   208 if(NOT APPLE)
   212 #add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}")
   209     #here is the command for standard executables or for shared library
       
   210     add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}"
       
   211         COMMAND "${FREEPASCAL_EXECUTABLE}"
       
   212         ARGS ${fpc_flags} -o${engine_output_name}
       
   213         DEPENDS ${engine_sources}
       
   214         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
       
   215         )
       
   216 else()
       
   217     #these are the dependencies for building a universal binary on Mac OS X
       
   218     foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
       
   219         list(APPEND lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
       
   220         add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}"
       
   221             COMMAND "${FREEPASCAL_EXECUTABLE}"
       
   222             ARGS ${fpc_flags} -ohwengine.${build_arch} -P${build_arch}
       
   223             DEPENDS ${engine_sources}
       
   224             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
       
   225             )
       
   226         add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
       
   227         add_custom_command(TARGET hwengine.${build_arch} POST_BUILD
       
   228             COMMAND "install_name_tool"
       
   229             ARGS -id @executable_path/../Frameworks/${engine_output_name}
       
   230                 ${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}
       
   231             )
       
   232     endforeach()
       
   233 
       
   234     add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}"
       
   235         COMMAND "lipo"
       
   236         ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}
       
   237         DEPENDS ${lipo_args_list}
       
   238         )
       
   239 endif()
       
   240 
       
   241 
       
   242 add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}")
       
   243 
   213 
   244 #when system Lua is not found we need to compile it before engine
   214 #when system Lua is not found we need to compile it before engine
   245 if(NOT LUA_FOUND)
   215 if(NOT LUA_FOUND)
   246     add_dependencies(hwengine lua)
   216     add_dependencies(hwengine lua)
   247 endif()
   217 endif()
   262 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   232 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
   263 if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOT ${FFMPEG_FOUND}))
   233 if((FREEPASCAL_VERSION VERSION_LESS "2.6") AND (NOT ${FFMPEG_FOUND}))
   264     add_dependencies(hwengine ENGINECLEAN)
   234     add_dependencies(hwengine ENGINECLEAN)
   265 endif()
   235 endif()
   266 
   236 
   267 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})
   237 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine" DESTINATION ${destination_dir})