cmake_modules/CMakeDeterminePascalCompiler.cmake
author sheepluva
Thu, 23 Jan 2014 13:56:53 +0100
changeset 10061 b7161f00a6ca
parent 9517 217eacb69395
permissions -rw-r--r--
hide complete IP of other users, when non-admin requests player info. showing the first two parts of the IP was kinda pointless to begin with (what for?) and has recently lead to increased abuse and lobby flooding due to bots collecting/posting IP tracking information
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
9517
217eacb69395 fail early when an incompatible cmake version is found
koda
parents: 9413
diff changeset
     8
# NOTE: on Darwin cmake >= 2.8.11 until cmake <= 2.8.12.1 will add an incompatible
217eacb69395 fail early when an incompatible cmake version is found
koda
parents: 9413
diff changeset
     9
# -F flag to <FLAGS> so you won't be able to use those versions with this script
217eacb69395 fail early when an incompatible cmake version is found
koda
parents: 9413
diff changeset
    10
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    11
if(NOT CMAKE_Pascal_COMPILER)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    12
    # prefer the environment variable FPC
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    13
    if($ENV{FPC} MATCHES ".+")
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    14
        get_filename_component(CMAKE_Pascal_COMPILER_INIT $ENV{FPC} PROGRAM PROGRAM_ARGS CMAKE_Pascal_FLAGS_ENV_INIT)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    15
        if(CMAKE_Pascal_FLAGS_ENV_INIT)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    16
            set(CMAKE_Pascal_COMPILER_ARG1 "${CMAKE_Pascal_FLAGS_ENV_INIT}" CACHE STRING "First argument to Pascal compiler")
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    17
        endif(CMAKE_Pascal_FLAGS_ENV_INIT)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    18
        if(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    19
        else(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    20
            message(FATAL_ERROR "Could not find compiler set in environment variable FPC:\n$ENV{FPC}.")
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    21
        endif(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    22
    endif($ENV{FPC} MATCHES ".+")
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    23
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    24
    # next try prefer the compiler specified by the generator
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    25
    if(CMAKE_GENERATOR_PASCAL)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    26
        if(NOT CMAKE_Pascal_COMPILER_INIT)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    27
            set(CMAKE_Pascal_COMPILER_INIT ${CMAKE_GENERATOR_PASCAL})
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    28
        endif(NOT CMAKE_Pascal_COMPILER_INIT)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    29
    endif(CMAKE_GENERATOR_PASCAL)
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    30
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    31
    # finally list compilers to try
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    32
    if(CMAKE_Pascal_COMPILER_INIT)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    33
        set(CMAKE_Pascal_COMPILER_LIST ${CMAKE_Pascal_COMPILER_INIT})
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    34
    else(CMAKE_Pascal_COMPILER_INIT)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    35
        set(CMAKE_Pascal_COMPILER_LIST fpc)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    36
    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
    37
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    38
    # Find the compiler.
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    39
    find_program(CMAKE_Pascal_COMPILER NAMES ${CMAKE_Pascal_COMPILER_LIST} DOC "Pascal compiler")
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    40
    if(CMAKE_Pascal_COMPILER_INIT AND NOT CMAKE_Pascal_COMPILER)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    41
        set(CMAKE_Pascal_COMPILER "${CMAKE_Pascal_COMPILER_INIT}" CACHE FILEPATH "Pascal compiler" FORCE)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    42
    endif(CMAKE_Pascal_COMPILER_INIT AND NOT CMAKE_Pascal_COMPILER)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    43
endif(NOT CMAKE_Pascal_COMPILER)
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    44
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
    45
8852
0576439ef859 add and use the integrated version check
koda
parents: 8834
diff changeset
    46
if(NOT CMAKE_Pascal_COMPILER_VERSION)
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    47
    execute_process(COMMAND ${CMAKE_Pascal_COMPILER} -iV
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    48
                    OUTPUT_VARIABLE CMAKE_Pascal_COMPILER_VERSION
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    49
                    OUTPUT_STRIP_TRAILING_WHITESPACE
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    50
                    ) # we assume no error for something so simple
9413
37fcb9a796e6 this should prevent duplication of CMAKE_Pascal_FLAGS
koda
parents: 8859
diff changeset
    51
    set(CMAKE_Pascal_COMPILER_ARG1 "-l- -v0ewn")
8852
0576439ef859 add and use the integrated version check
koda
parents: 8834
diff changeset
    52
endif(NOT CMAKE_Pascal_COMPILER_VERSION)
0576439ef859 add and use the integrated version check
koda
parents: 8834
diff changeset
    53
mark_as_advanced(CMAKE_Pascal_COMPILER_VERSION)
0576439ef859 add and use the integrated version check
koda
parents: 8834
diff changeset
    54
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    55
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
    56
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    57
# 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
    58
if(${CMAKE_VERSION} VERSION_LESS 2.8.10)
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    59
    configure_file(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    60
                   "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakePascalCompiler.cmake"
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    61
                   IMMEDIATE )
8764
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    62
else(${CMAKE_VERSION} VERSION_LESS 2.8.10)
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    63
    configure_file(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    64
                  "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMAKE_VERSION}/CMakePascalCompiler.cmake"
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    65
                   IMMEDIATE )
8764
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    66
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
    67
8859
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    68
set(CMAKE_Pascal_COMPILER_ENV_VAR "FPC")
bead90828a94 cmake netiquette
koda
parents: 8852
diff changeset
    69