cmake_modules/CMakeDeterminePascalCompiler.cmake
author koda
Mon, 18 Mar 2013 00:58:13 +0100
branchcmake_pascal
changeset 8750 d9e57426e759
child 8752 48cf2ccb83c6
permissions -rw-r--r--
barebone cmake config file to support pascal files, based off plplot's ada files
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.
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
     4
# use environment variable Pascal first if defined by user, next use 
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})
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    18
      MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable FPC:\n$ENV{FPC}.") 
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
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    23
  IF(CMAKE_GENERATOR_PASCAL) 
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)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    33
    SET(CMAKE_Pascal_COMPILER_LIST fpc ppc386 ppcx64 ppcppc ppcarm)  
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
#FIND_PROGRAM(GNAT_EXECUTABLE_BUILDER NAMES gnatmake PATHS ${COMPILER_LOCATION} )
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    47
FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION} )
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    48
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    49
FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    50
IF(NOT CMAKE_RANLIB)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    51
   SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    52
ENDIF(NOT CMAKE_RANLIB)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    53
MARK_AS_ADVANCED(CMAKE_RANLIB)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    54
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    55
# configure variables set in this file for fast reload later on
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    56
#CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakePascalCompiler.cmake.in 
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    57
CONFIGURE_FILE(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in 
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    58
               "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMAKE_VERSION}/CMakePascalCompiler.cmake"
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    59
               IMMEDIATE)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    60
MARK_AS_ADVANCED(CMAKE_AR)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    61
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    62
SET(CMAKE_Pascal_COMPILER_ENV_VAR "FPC")