cmake_modules/CMakeDeterminePascalCompiler.cmake
author koda
Fri, 22 Mar 2013 10:43:43 +0100
branchcmake_pascal
changeset 8834 edceeafff671
parent 8764 f16bcb3dba9e
child 8852 0576439ef859
permissions -rw-r--r--
no need of ar and ranlib for pascal
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
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
     8
IF(NOT CMAKE_Pascal_COMPILER)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
     9
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    10
  # prefer the environment variable FPC
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    11
  IF($ENV{FPC} MATCHES ".+")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    12
    GET_FILENAME_COMPONENT(CMAKE_Pascal_COMPILER_INIT $ENV{FPC} PROGRAM PROGRAM_ARGS CMAKE_Pascal_FLAGS_ENV_INIT)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    13
    IF(CMAKE_Pascal_FLAGS_ENV_INIT)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    14
      SET(CMAKE_Pascal_COMPILER_ARG1 "${CMAKE_Pascal_FLAGS_ENV_INIT}" CACHE STRING "First argument to Pascal compiler")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    15
    ENDIF(CMAKE_Pascal_FLAGS_ENV_INIT)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    16
    IF(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    17
    ELSE(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
8752
48cf2ccb83c6 with lot of hackery, use add_executable on pascal files, SUCCSS
koda
parents: 8750
diff changeset
    18
      MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable FPC:\n$ENV{FPC}.")
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    19
    ENDIF(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    20
  ENDIF($ENV{FPC} MATCHES ".+")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    21
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    22
  # next try prefer the compiler specified by the generator
8752
48cf2ccb83c6 with lot of hackery, use add_executable on pascal files, SUCCSS
koda
parents: 8750
diff changeset
    23
  IF(CMAKE_GENERATOR_PASCAL)
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    24
    IF(NOT CMAKE_Pascal_COMPILER_INIT)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    25
      SET(CMAKE_Pascal_COMPILER_INIT ${CMAKE_GENERATOR_PASCAL})
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    26
    ENDIF(NOT CMAKE_Pascal_COMPILER_INIT)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    27
  ENDIF(CMAKE_GENERATOR_PASCAL)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    28
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    29
  # finally list compilers to try
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    30
  IF(CMAKE_Pascal_COMPILER_INIT)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    31
    SET(CMAKE_Pascal_COMPILER_LIST ${CMAKE_Pascal_COMPILER_INIT})
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    32
  ELSE(CMAKE_Pascal_COMPILER_INIT)
8752
48cf2ccb83c6 with lot of hackery, use add_executable on pascal files, SUCCSS
koda
parents: 8750
diff changeset
    33
    SET(CMAKE_Pascal_COMPILER_LIST fpc)
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    34
  ENDIF(CMAKE_Pascal_COMPILER_INIT)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    35
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    36
  # Find the compiler.
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    37
  FIND_PROGRAM(CMAKE_Pascal_COMPILER NAMES ${CMAKE_Pascal_COMPILER_LIST} DOC "Pascal compiler")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    38
  IF(CMAKE_Pascal_COMPILER_INIT AND NOT CMAKE_Pascal_COMPILER)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    39
    SET(CMAKE_Pascal_COMPILER "${CMAKE_Pascal_COMPILER_INIT}" CACHE FILEPATH "Pascal compiler" FORCE)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    40
  ENDIF(CMAKE_Pascal_COMPILER_INIT AND NOT CMAKE_Pascal_COMPILER)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    41
ENDIF(NOT CMAKE_Pascal_COMPILER)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    42
MARK_AS_ADVANCED(CMAKE_Pascal_COMPILER)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    43
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    44
GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_Pascal_COMPILER}" PATH)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    45
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    46
# 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
    47
if(${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
    48
  CONFIGURE_FILE(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    49
                 "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakePascalCompiler.cmake"
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    50
                 IMMEDIATE )
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    51
else(${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
    52
  CONFIGURE_FILE(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    53
                "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMAKE_VERSION}/CMakePascalCompiler.cmake"
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    54
                 IMMEDIATE )
f16bcb3dba9e the default CMake(Lang)Compiler.cmake location changed since 2.8.10
koda
parents: 8754
diff changeset
    55
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
    56
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    57
SET(CMAKE_Pascal_COMPILER_ENV_VAR "FPC")