author | nemo |
Mon, 25 Feb 2013 12:54:50 -0500 | |
branch | icegun |
changeset 8576 | 286ebfcb3d97 |
parent 8285 | a1500ffdc343 |
permissions | -rw-r--r-- |
8162
b97a17bf89ec
Move code for Freepascal to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff
changeset
|
1 |
# Load Freepascal |
8164
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
2 |
if (FPC) |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
3 |
set(FPC_EXECUTABLE ${FPC}) |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
4 |
else() |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
5 |
find_program(FPC_EXECUTABLE |
8162
b97a17bf89ec
Move code for Freepascal to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff
changeset
|
6 |
NAMES fpc |
b97a17bf89ec
Move code for Freepascal to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff
changeset
|
7 |
PATHS /opt/local/bin /usr/local/bin /usr/bin) |
8164
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
8 |
endif() |
8162
b97a17bf89ec
Move code for Freepascal to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff
changeset
|
9 |
|
b97a17bf89ec
Move code for Freepascal to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff
changeset
|
10 |
# Check Freepascal version |
8164
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
11 |
if (FPC_EXECUTABLE) |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
12 |
exec_program(${FPC_EXECUTABLE} ARGS "-v" OUTPUT_VARIABLE FPC_VERSION_FULL) |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
13 |
|
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
14 |
string(REGEX MATCH "[0-9]+\\.[0-9]+" FPC_VERSION_LONG "${FPC_VERSION_FULL}") |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
15 |
string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" FPC_VERSION "${FPC_VERSION_LONG}") |
8285 | 16 |
message(STATUS "Found Freepascal: ${FPC_EXECUTABLE} (version ${FPC_VERSION})") |
8164
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
17 |
else() |
8195
37d47f09f981
caught a few more possible glitches in engine cmakefile
koda
parents:
8188
diff
changeset
|
18 |
message(FATAL_ERROR "Could NOT find Freepascal") |
8164
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
19 |
endif() |
8162
b97a17bf89ec
Move code for Freepascal to separate CMake module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
diff
changeset
|
20 |
|
8164
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
21 |
# Check for noexecstack flag support |
8283 | 22 |
message(STATUS "Checking whether linker needs explicit noexecstack") |
8164
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
23 |
set(NOEXECSTACK_FLAGS "-k-z" "-knoexecstack") |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
24 |
file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.") |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
25 |
|
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
26 |
execute_process(COMMAND ${FPC_EXECUTABLE} ${NOEXECSTACK_FLAGS} checkstack.pas |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
27 |
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
28 |
RESULT_VARIABLE TEST_NOEXECSTACK |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
29 |
OUTPUT_QUIET ERROR_QUIET) |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
30 |
|
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
31 |
if (TEST_NOEXECSTACK) |
b12634f2e1b2
Move noexecstack flags to Freepascal module and refactor.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8162
diff
changeset
|
32 |
set(NOEXECSTACK_FLAGS "") |
8166
5bc0fc0bab4d
Refactor Freepascal module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8164
diff
changeset
|
33 |
message(STATUS "Checking whether linker needs explicit noexecstack -- no") |
8188
4c166505e5c8
fix compiling engine (bug introduced in r33868aea694c)
koda
parents:
8166
diff
changeset
|
34 |
else(TEST_NOEXECSTACK) |
8166
5bc0fc0bab4d
Refactor Freepascal module.
Bryan Dunsmore <dunsmoreb@gmail.com>
parents:
8164
diff
changeset
|
35 |
message(STATUS "Checking whether linker needs explicit noexecstack -- yes") |
8188
4c166505e5c8
fix compiling engine (bug introduced in r33868aea694c)
koda
parents:
8166
diff
changeset
|
36 |
endif(TEST_NOEXECSTACK) |
8195
37d47f09f981
caught a few more possible glitches in engine cmakefile
koda
parents:
8188
diff
changeset
|
37 |