cmake_modules/FindFreepascal.cmake
changeset 8164 b12634f2e1b2
parent 8162 b97a17bf89ec
child 8166 5bc0fc0bab4d
equal deleted inserted replaced
8162:b97a17bf89ec 8164:b12634f2e1b2
     1 # Load Freepascal
     1 # Load Freepascal
     2 IF (FPC)
     2 if (FPC)
     3     SET(FPC_EXECUTABLE ${FPC})
     3     set(FPC_EXECUTABLE ${FPC})
     4 ELSE()
     4 else()
     5     FIND_PROGRAM(FPC_EXECUTABLE
     5     find_program(FPC_EXECUTABLE
     6         NAMES fpc
     6         NAMES fpc
     7         PATHS /opt/local/bin /usr/local/bin /usr/bin)
     7         PATHS /opt/local/bin /usr/local/bin /usr/bin)
     8 ENDIF()
     8 endif()
     9 
     9 
    10 # Check Freepascal version
    10 # Check Freepascal version
    11 IF (FPC_EXECUTABLE)
    11 if (FPC_EXECUTABLE)
    12     EXEC_PROGRAM(${FPC_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE FPC_VERSION_FULL)
    12     exec_program(${FPC_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE FPC_VERSION_FULL)
    13 
    13 
    14     STRING(REGEX MATCH "[0-9]+\\.[0-9]+" FPC_VERSION_LONG "${FPC_VERSION_FULL}")
    14     string(REGEX MATCH "[0-9]+\\.[0-9]+" FPC_VERSION_LONG "${FPC_VERSION_FULL}")
    15     STRING(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" FPC_VERSION "${FPC_VERSION_LONG}")
    15     string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" FPC_VERSION "${FPC_VERSION_LONG}")
    16 ELSE()
    16 else()
    17     MESSAGE(FATAL_ERROR "Freepascal not found (required for hedgewars)")
    17     message(FATAL_ERROR "Freepascal not found (required for hedgewars)")
    18 ENDIF()
    18 endif()
       
    19 
       
    20 # Check for noexecstack flag support
       
    21 set(NOEXECSTACK_FLAGS "-k-z" "-knoexecstack")
       
    22 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
       
    23 
       
    24 execute_process(COMMAND ${FPC_EXECUTABLE} ${NOEXECSTACK_FLAGS} checkstack.pas
       
    25     WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
       
    26     RESULT_VARIABLE TEST_NOEXECSTACK
       
    27     OUTPUT_QUIET ERROR_QUIET)
       
    28 
       
    29 if (TEST_NOEXECSTACK)
       
    30     set(NOEXECSTACK_FLAGS "")
       
    31     message(STATUS "Checking whether linker supports noexecstack flag -- no")
       
    32 else()
       
    33     message(STATUS "Checking whether linker supports noexecstack flag -- yes")
       
    34 endif()