hedgewars/CMakeLists.txt
changeset 8090 38d9cc60b14c
parent 8087 ccc99eebdac2
child 8093 2286a39140da
--- a/hedgewars/CMakeLists.txt	Wed Nov 21 15:03:33 2012 +0100
+++ b/hedgewars/CMakeLists.txt	Wed Nov 21 18:34:45 2012 +0100
@@ -101,6 +101,7 @@
 endif(BUILD_ENGINE_LIBRARY)
 
 
+#PASCAL DETECTION SECTION
 IF(FPC)
     set(fpc_executable ${FPC})
 ELSE()
@@ -108,23 +109,40 @@
 ENDIF()
 
 if(fpc_executable)
-    exec_program(${fpc_executable} ARGS "-iV" OUTPUT_VARIABLE fpc_output)
+    execute_process(COMMAND ${fpc_executable} -iV OUTPUT_VARIABLE fpc_output)
 endif(fpc_executable)
 
+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()
+else()
+    message(FATAL_ERROR "No FreePascal compiler found!")
+endif()
+
 set(noexecstack_flags "-k-z" "-knoexecstack")
 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
 
-exec_program(${fpc_executable} ${EXECUTABLE_OUTPUT_PATH}
-    ARGS ${noexecstack_flags} checkstack.pas
-    OUTPUT_VARIABLE noout
-    RETURN_VALUE testnoexecstack
+execute_process(COMMAND ${fpc_executable} ${noexecstack_flags} checkstack.pas
+    WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
+    RESULT_VARIABLE testnoexecstack
+    OUTPUT_QUIET
     )
 
 if(${testnoexecstack})
     set (noexecstack_flags "")
 endif(${testnoexecstack})
 
-
+#DEPENDECIES AND EXECUTABLES SECTION
 if(APPLE)
     string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}")
     string(REGEX MATCH "[iI]386+" i386_build "${CMAKE_OSX_ARCHITECTURES}")
@@ -156,28 +174,6 @@
     set(pascal_flags "-k${LIBRARY_OUTPUT_PATH}/libphysfs.a" ${pascal_flags})
 endif(APPLE)
 
-
-#PASCAL DETECTION SECTION
-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()
-else()
-    message(FATAL_ERROR "No FreePascal compiler found!")
-endif()
-
-
-#DEPENDECIES AND EXECUTABLES SECTION
 if(NOT NOPNG)
     find_package(PNG)
     if(${PNG_FOUND})