|
1 # This file is used by EnableLanguage in cmGlobalGenerator to determine that |
|
2 # the FreePascal can actually compile and link the most basic of programs. |
|
3 # If not, a fatal error is set, cmake stops processing commands and will not |
|
4 # generate any makefiles or projects. |
|
5 |
|
6 if(NOT CMAKE_Pascal_COMPILER_WORKS) |
|
7 message(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER}") |
|
8 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/testpascalcompiler.pas |
|
9 "program testPascalCompiler; |
|
10 begin |
|
11 end. |
|
12 ") |
|
13 |
|
14 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt |
|
15 "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules) |
|
16 set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE) |
|
17 project(test Pascal) |
|
18 add_executable(testpascalcompiler testpascalcompiler.pas) |
|
19 ") |
|
20 |
|
21 # To avoid try_compile recurse error, use any binary directory other |
|
22 # than ${CMAKE_BINARY_DIR}. The choice of |
|
23 # bindir = ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp is |
|
24 # especially advantageous since it makes an in-source build which |
|
25 # means that no special variables need to be set to find files. |
|
26 try_compile(CMAKE_Pascal_COMPILER_WORKS |
|
27 ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp |
|
28 ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp |
|
29 test |
|
30 OUTPUT_VARIABLE RESULT_OUTPUT |
|
31 ) |
|
32 set(PASCAL_TEST_WAS_RUN 1) |
|
33 endif(NOT CMAKE_Pascal_COMPILER_WORKS) |
|
34 |
|
35 if(NOT CMAKE_Pascal_COMPILER_WORKS) |
|
36 message(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- broken") |
|
37 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log |
|
38 "Determining if the Pascal compiler works failed with " |
|
39 "the following output:\n${RESULT_OUTPUT}\n\n") |
|
40 message(FATAL_ERROR "The Pascal builder \"${CMAKE_Pascal_COMPILER}\" " |
|
41 "is not able to compile and link a simple test program.\nIt fails " |
|
42 "with the following output:\n ${RESULT_OUTPUT}\n\n" |
|
43 "CMake will not be able to correctly generate this project.") |
|
44 else(NOT CMAKE_Pascal_COMPILER_WORKS) |
|
45 if(PASCAL_TEST_WAS_RUN) |
|
46 message(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- works") |
|
47 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeOutput.log |
|
48 "Determining if the Pascal compiler works passed with " |
|
49 "the following output:\n${RESULT_OUTPUT}\n\n") |
|
50 endif(PASCAL_TEST_WAS_RUN) |
|
51 set(CMAKE_Pascal_COMPILER_WORKS 1 CACHE INTERNAL "") |
|
52 endif(NOT CMAKE_Pascal_COMPILER_WORKS) |
|
53 |