equal
deleted
inserted
replaced
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 message(STATUS "Checking whether linker needs explicit noexecstack") |
|
23 set(NOEXECSTACK_FLAGS "-k-z" "-knoexecstack") |
|
24 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.") |
|
25 |
|
26 execute_process(COMMAND ${FPC_EXECUTABLE} ${NOEXECSTACK_FLAGS} checkstack.pas |
|
27 WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} |
|
28 RESULT_VARIABLE TEST_NOEXECSTACK |
|
29 OUTPUT_QUIET ERROR_QUIET) |
|
30 |
|
31 if (TEST_NOEXECSTACK) |
|
32 set(NOEXECSTACK_FLAGS "") |
|
33 message(STATUS "Checking whether linker needs explicit noexecstack -- no") |
|
34 else(TEST_NOEXECSTACK) |
|
35 message(STATUS "Checking whether linker needs explicit noexecstack -- yes") |
|
36 endif(TEST_NOEXECSTACK) |
|
37 |
|