author | unc0rr |
Thu, 29 Aug 2013 12:01:19 +0400 | |
changeset 9439 | e0570f2e5f41 |
parent 9413 | 37fcb9a796e6 |
child 9517 | 217eacb69395 |
permissions | -rw-r--r-- |
8750
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
1 |
# Determine the compiler to use for Pascal programs |
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
2 |
# NOTE, a generator may set CMAKE_Pascal_COMPILER before |
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
3 |
# loading this file to force a compiler. |
8752
48cf2ccb83c6
with lot of hackery, use add_executable on pascal files, SUCCSS
koda
parents:
8750
diff
changeset
|
4 |
# use environment variable Pascal first if defined by user, next use |
8750
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
5 |
# the cmake variable CMAKE_GENERATOR_PASCAL which can be defined by a generator |
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
6 |
# as a default compiler |
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
7 |
|
8859 | 8 |
if(NOT CMAKE_Pascal_COMPILER) |
9 |
# prefer the environment variable FPC |
|
10 |
if($ENV{FPC} MATCHES ".+") |
|
11 |
get_filename_component(CMAKE_Pascal_COMPILER_INIT $ENV{FPC} PROGRAM PROGRAM_ARGS CMAKE_Pascal_FLAGS_ENV_INIT) |
|
12 |
if(CMAKE_Pascal_FLAGS_ENV_INIT) |
|
13 |
set(CMAKE_Pascal_COMPILER_ARG1 "${CMAKE_Pascal_FLAGS_ENV_INIT}" CACHE STRING "First argument to Pascal compiler") |
|
14 |
endif(CMAKE_Pascal_FLAGS_ENV_INIT) |
|
15 |
if(EXISTS ${CMAKE_Pascal_COMPILER_INIT}) |
|
16 |
else(EXISTS ${CMAKE_Pascal_COMPILER_INIT}) |
|
17 |
message(FATAL_ERROR "Could not find compiler set in environment variable FPC:\n$ENV{FPC}.") |
|
18 |
endif(EXISTS ${CMAKE_Pascal_COMPILER_INIT}) |
|
19 |
endif($ENV{FPC} MATCHES ".+") |
|
8750
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
20 |
|
8859 | 21 |
# next try prefer the compiler specified by the generator |
22 |
if(CMAKE_GENERATOR_PASCAL) |
|
23 |
if(NOT CMAKE_Pascal_COMPILER_INIT) |
|
24 |
set(CMAKE_Pascal_COMPILER_INIT ${CMAKE_GENERATOR_PASCAL}) |
|
25 |
endif(NOT CMAKE_Pascal_COMPILER_INIT) |
|
26 |
endif(CMAKE_GENERATOR_PASCAL) |
|
8750
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
27 |
|
8859 | 28 |
# finally list compilers to try |
29 |
if(CMAKE_Pascal_COMPILER_INIT) |
|
30 |
set(CMAKE_Pascal_COMPILER_LIST ${CMAKE_Pascal_COMPILER_INIT}) |
|
31 |
else(CMAKE_Pascal_COMPILER_INIT) |
|
32 |
set(CMAKE_Pascal_COMPILER_LIST fpc) |
|
33 |
endif(CMAKE_Pascal_COMPILER_INIT) |
|
8750
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
34 |
|
8859 | 35 |
# Find the compiler. |
36 |
find_program(CMAKE_Pascal_COMPILER NAMES ${CMAKE_Pascal_COMPILER_LIST} DOC "Pascal compiler") |
|
37 |
if(CMAKE_Pascal_COMPILER_INIT AND NOT CMAKE_Pascal_COMPILER) |
|
38 |
set(CMAKE_Pascal_COMPILER "${CMAKE_Pascal_COMPILER_INIT}" CACHE FILEPATH "Pascal compiler" FORCE) |
|
39 |
endif(CMAKE_Pascal_COMPILER_INIT AND NOT CMAKE_Pascal_COMPILER) |
|
40 |
endif(NOT CMAKE_Pascal_COMPILER) |
|
41 |
mark_as_advanced(CMAKE_Pascal_COMPILER) |
|
8750
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
42 |
|
8852 | 43 |
if(NOT CMAKE_Pascal_COMPILER_VERSION) |
8859 | 44 |
execute_process(COMMAND ${CMAKE_Pascal_COMPILER} -iV |
45 |
OUTPUT_VARIABLE CMAKE_Pascal_COMPILER_VERSION |
|
46 |
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
47 |
) # we assume no error for something so simple |
|
9413
37fcb9a796e6
this should prevent duplication of CMAKE_Pascal_FLAGS
koda
parents:
8859
diff
changeset
|
48 |
set(CMAKE_Pascal_COMPILER_ARG1 "-l- -v0ewn") |
8852 | 49 |
endif(NOT CMAKE_Pascal_COMPILER_VERSION) |
50 |
mark_as_advanced(CMAKE_Pascal_COMPILER_VERSION) |
|
51 |
||
8859 | 52 |
get_filename_component(COMPILER_LOCATION "${CMAKE_Pascal_COMPILER}" PATH) |
8750
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
53 |
|
d9e57426e759
barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff
changeset
|
54 |
# configure variables set in this file for fast reload later on |
8764
f16bcb3dba9e
the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents:
8754
diff
changeset
|
55 |
if(${CMAKE_VERSION} VERSION_LESS 2.8.10) |
8859 | 56 |
configure_file(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in |
57 |
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakePascalCompiler.cmake" |
|
58 |
IMMEDIATE ) |
|
8764
f16bcb3dba9e
the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents:
8754
diff
changeset
|
59 |
else(${CMAKE_VERSION} VERSION_LESS 2.8.10) |
8859 | 60 |
configure_file(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in |
61 |
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMAKE_VERSION}/CMakePascalCompiler.cmake" |
|
62 |
IMMEDIATE ) |
|
8764
f16bcb3dba9e
the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents:
8754
diff
changeset
|
63 |
endif(${CMAKE_VERSION} VERSION_LESS 2.8.10) |
f16bcb3dba9e
the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents:
8754
diff
changeset
|
64 |
|
8859 | 65 |
set(CMAKE_Pascal_COMPILER_ENV_VAR "FPC") |
66 |