cmake_modules/CMakeTestPascalCompiler.cmake
author koda
Tue, 19 Mar 2013 18:32:22 +0100
branchcmake_pascal
changeset 8819 8e25b820b360
parent 8758 cb3b470f1000
child 8859 bead90828a94
permissions -rw-r--r--
below this i cannot break the loop
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
# This file is used by EnableLanguage in cmGlobalGenerator to determine that
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
     2
# the FreePascal can actually compile and link the most basic of programs.
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
     3
# If not, a fatal error is set, cmake stops processing commands and will not
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
     4
# generate any makefiles or projects.
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
     5
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
     6
IF(NOT CMAKE_Pascal_COMPILER_WORKS)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
     7
  MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER}")
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
     8
  FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/testpascalcompiler.pas
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
     9
  "program testPascalCompiler;
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    10
   begin
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    11
   end.
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    12
  ")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    13
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    14
  FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    15
  "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    16
   set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    17
   project(test Pascal)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    18
   add_executable(testpascalcompiler testpascalcompiler.pas)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    19
  ")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    20
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    21
# To avoid try_compile recurse error, use any binary directory other
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    22
# than ${CMAKE_BINARY_DIR}. The choice of
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    23
# bindir = ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp is
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    24
# especially advantageous since it makes an in-source build which
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    25
# means that no special variables need to be set to find files.
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    26
  try_compile(CMAKE_Pascal_COMPILER_WORKS
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    27
              ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    28
              ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    29
              projectName
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    30
              OUTPUT_VARIABLE RESULT_OUTPUT
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    31
              )
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    32
  SET(PASCAL_TEST_WAS_RUN 1)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    33
ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    34
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    35
IF(NOT CMAKE_Pascal_COMPILER_WORKS)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    36
  MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- broken")
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    37
  FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    38
    "Determining if the Pascal compiler works failed with "
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    39
    "the following output:\n${RESULT_OUTPUT}\n\n")
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    40
  MESSAGE(FATAL_ERROR "The Pascal builder \"${CMAKE_Pascal_COMPILER}\" "
8752
48cf2ccb83c6 with lot of hackery, use add_executable on pascal files, SUCCSS
koda
parents: 8750
diff changeset
    41
    "is not able to compile and link a simple test program.\nIt fails "
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    42
    "with the following output:\n ${RESULT_OUTPUT}\n\n"
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    43
    "CMake will not be able to correctly generate this project.")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    44
ELSE(NOT CMAKE_Pascal_COMPILER_WORKS)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    45
  IF(PASCAL_TEST_WAS_RUN)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    46
    MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- works")
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    47
    FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    48
      "Determining if the Pascal compiler works passed with "
8758
cb3b470f1000 better support for cmake directory and fpc output paths
koda
parents: 8754
diff changeset
    49
      "the following output:\n${RESULT_OUTPUT}\n\n")
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    50
  ENDIF(PASCAL_TEST_WAS_RUN)
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    51
  SET(CMAKE_Pascal_COMPILER_WORKS 1 CACHE INTERNAL "")
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    52
ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)