diff -r 25b95d6224fc -r 9b1c206a6cf2 hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Sat Dec 01 21:24:25 2012 -0500 +++ b/hedgewars/CMakeLists.txt Sat Dec 01 21:32:34 2012 -0500 @@ -12,6 +12,12 @@ set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas) set(engine_output_name "hwengine") +if (APPLE) + set(required_fpc_version 2.6) +else() + set(required_fpc_version 2.2) +endif() + set(engine_sources ${hwengine_project} LuaPas.pas @@ -101,54 +107,15 @@ endif(BUILD_ENGINE_LIBRARY) -#PASCAL DETECTION SECTION -IF(FPC) - set(fpc_executable ${FPC}) -ELSE() - find_program(fpc_executable fpc) -ENDIF() - -message(STATUS "Check for working FPC compiler: ${fpc_executable}") -execute_process(COMMAND ${fpc_executable} -iV OUTPUT_VARIABLE fpc_output ERROR_VARIABLE fpc_error) -if(fpc_error) - message(STATUS "Check for working FPC compiler: ${fpc_executable} -- broken") -else(fpc_error) - message(STATUS "Check for working FPC compiler: ${fpc_executable} -- works") -endif(fpc_error) +# Check Freepascal version +find_package(Freepascal) -string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}") -if(fpc_version) - string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}") - string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}") - string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}") - message(STATUS "Found Freepascal: ${fpc_executable} (version ${fpc_vers_major}.${fpc_vers_minor})") - math(EXPR fpc_version "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}") - - if(fpc_version LESS "020200") - message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0") - elseif(APPLE AND (fpc_version LESS "020600")) - message(FATAL_ERROR "Minimum required version of FreePascal is 2.6.0 on Mac OS X") - endif() +if (FPC_VERSION VERSION_LESS required_fpc_version) + message(FATAL_ERROR "Necessary FPC version not found (version >= ${required_fpc_version} required)") else() - message(FATAL_ERROR "No FreePascal compiler found!") + message(STATUS "Found FPC: ${FPC_EXECUTABLE} (version ${FPC_VERSION})") endif() -message(STATUS "Checking whether linker supports noexecstack flag") -set(noexecstack_flags "-k-z" "-knoexecstack") -file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.") - -execute_process(COMMAND ${fpc_executable} ${noexecstack_flags} checkstack.pas - WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} - RESULT_VARIABLE testnoexecstack - OUTPUT_QUIET ERROR_QUIET - ) - -if(${testnoexecstack}) - set (noexecstack_flags "") - message(STATUS "Checking whether linker supports noexecstack flag -- no") -else(${testnoexecstack}) - message(STATUS "Checking whether linker supports noexecstack flag -- yes") -endif(${testnoexecstack}) #DEPENDECIES AND EXECUTABLES SECTION if(APPLE) @@ -241,7 +208,7 @@ set(fpc_flags ${noexecstack_flags} ${pascal_flags} ${hwengine_project}) -IF(NOT APPLE) +if(NOT APPLE) #here is the command for standard executables or for shared library add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}" COMMAND "${fpc_executable}" @@ -249,7 +216,7 @@ MAIN_DEPENDENCY ${hwengine_project} DEPENDS ${engine_sources} ) -ELSE() +else() #these are the dependencies for building a universal binary on Mac OS X foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build}) set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list}) @@ -267,7 +234,7 @@ ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/${engine_output_name} DEPENDS ${lipo_args_list} ) -ENDIF() +endif() add_custom_target(${engine_output_name} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}${CMAKE_EXECUTABLE_SUFFIX}")