cmake_modules/FindFreepascal.cmake
branchflibqtfrontend
changeset 8208 171da01bd04d
parent 8195 37d47f09f981
child 8283 af97cdbb7713
equal deleted inserted replaced
8141:6482875b0d97 8208:171da01bd04d
       
     1 # Load Freepascal
       
     2 if (FPC)
       
     3     set(FPC_EXECUTABLE ${FPC})
       
     4 else()
       
     5     find_program(FPC_EXECUTABLE
       
     6         NAMES fpc
       
     7         PATHS /opt/local/bin /usr/local/bin /usr/bin)
       
     8 endif()
       
     9 
       
    10 # Check Freepascal version
       
    11 if (FPC_EXECUTABLE)
       
    12     exec_program(${FPC_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE FPC_VERSION_FULL)
       
    13 
       
    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}")
       
    16     message(STATUS "Found Freepascal: ${FPC_EXECUTABLE} (version ${FPC_VERSION}")
       
    17 else()
       
    18     message(FATAL_ERROR "Could NOT find Freepascal")
       
    19 endif()
       
    20 
       
    21 # Check for noexecstack flag support
       
    22 set(NOEXECSTACK_FLAGS "-k-z" "-knoexecstack")
       
    23 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
       
    24 
       
    25 execute_process(COMMAND ${FPC_EXECUTABLE} ${NOEXECSTACK_FLAGS} checkstack.pas
       
    26     WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
       
    27     RESULT_VARIABLE TEST_NOEXECSTACK
       
    28     OUTPUT_QUIET ERROR_QUIET)
       
    29 
       
    30 if (TEST_NOEXECSTACK)
       
    31     set(NOEXECSTACK_FLAGS "")
       
    32     message(STATUS "Checking whether linker needs explicit noexecstack -- no")
       
    33 else(TEST_NOEXECSTACK)
       
    34     message(STATUS "Checking whether linker needs explicit noexecstack -- yes")
       
    35 endif(TEST_NOEXECSTACK)
       
    36