cmake_modules/CMakeTestPascalCompiler.cmake
branchcmake_pascal
changeset 8758 cb3b470f1000
parent 8754 0c08d07e791a
child 8859 bead90828a94
equal deleted inserted replaced
8756:671f6ef4f7f1 8758:cb3b470f1000
     1 # This file is used by EnableLanguage in cmGlobalGenerator to determine that
     1 # This file is used by EnableLanguage in cmGlobalGenerator to determine that
     2 # the Ada builder GNAT_EXECUTABLE_BUILDER = gnatmake can actually compile
     2 # the FreePascal can actually compile and link the most basic of programs.
     3 # and link the most basic of programs.  If not, a fatal error is set and
     3 # If not, a fatal error is set, cmake stops processing commands and will not
     4 # cmake stops processing commands and will not generate any makefiles or
     4 # generate any makefiles or projects.
     5 # projects.
       
     6 
     5 
     7 IF(NOT CMAKE_Pascal_COMPILER_WORKS)
     6 IF(NOT CMAKE_Pascal_COMPILER_WORKS)
     8   MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER}")
     7   MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER}")
     9   FILE(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/testpascalcompiler.pas
     8   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/testpascalcompiler.pas
    10   "program testPascalCompiler;
     9   "program testPascalCompiler;
    11    begin
    10    begin
    12    end.
    11    end.
    13   ")
    12   ")
    14 
    13 
    15   FILE(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt
    14   FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt
    16   "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
    15   "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
    17    set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE)
    16    set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE)
    18    project(test Pascal)
    17    project(test Pascal)
    19    add_executable(testpascalcompiler testpascalcompiler.pas)
    18    add_executable(testpascalcompiler testpascalcompiler.pas)
    20   ")
    19   ")
    21 
    20 
    22 # To avoid try_compile recurse error, use any binary directory other than
    21 # To avoid try_compile recurse error, use any binary directory other
    23 # ${CMAKE_BINARY_DIR}.  The choice of
    22 # than ${CMAKE_BINARY_DIR}. The choice of
    24 # bindir = ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp is
    23 # bindir = ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp is
    25 # especially advantageous since it makes an in-source build which
    24 # especially advantageous since it makes an in-source build which
    26 # means that no special variables need to be set to find files.
    25 # means that no special variables need to be set to find files.
    27   try_compile(CMAKE_Pascal_COMPILER_WORKS
    26   try_compile(CMAKE_Pascal_COMPILER_WORKS
    28   ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
    27               ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
    29   ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
    28               ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
    30   projectName
    29               projectName
    31   OUTPUT_VARIABLE OUTPUT
    30               OUTPUT_VARIABLE RESULT_OUTPUT
    32   )
    31               )
    33   SET(PASCAL_TEST_WAS_RUN 1)
    32   SET(PASCAL_TEST_WAS_RUN 1)
    34 ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)
    33 ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)
    35 
    34 
    36 IF(NOT CMAKE_Pascal_COMPILER_WORKS)
    35 IF(NOT CMAKE_Pascal_COMPILER_WORKS)
    37   MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- broken")
    36   MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- broken")
    38   FILE(APPEND ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log
    37   FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log
    39     "Determining if the Pascal compiler works failed with "
    38     "Determining if the Pascal compiler works failed with "
    40     "the following output:\n${OUTPUT}\n\n")
    39     "the following output:\n${RESULT_OUTPUT}\n\n")
    41   MESSAGE(FATAL_ERROR "The Pascal builder \"${CMAKE_Pascal_COMPILER}\" "
    40   MESSAGE(FATAL_ERROR "The Pascal builder \"${CMAKE_Pascal_COMPILER}\" "
    42     "is not able to compile and link a simple test program.\nIt fails "
    41     "is not able to compile and link a simple test program.\nIt fails "
    43     "with the following output:\n ${OUTPUT}\n\n"
    42     "with the following output:\n ${RESULT_OUTPUT}\n\n"
    44     "CMake will not be able to correctly generate this project.")
    43     "CMake will not be able to correctly generate this project.")
    45 ELSE(NOT CMAKE_Pascal_COMPILER_WORKS)
    44 ELSE(NOT CMAKE_Pascal_COMPILER_WORKS)
    46   IF(PASCAL_TEST_WAS_RUN)
    45   IF(PASCAL_TEST_WAS_RUN)
    47     MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- works")
    46     MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- works")
    48     FILE(APPEND ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
    47     FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
    49       "Determining if the Pascal compiler works passed with "
    48       "Determining if the Pascal compiler works passed with "
    50       "the following output:\n${OUTPUT}\n\n")
    49       "the following output:\n${RESULT_OUTPUT}\n\n")
    51   ENDIF(PASCAL_TEST_WAS_RUN)
    50   ENDIF(PASCAL_TEST_WAS_RUN)
    52   SET(CMAKE_Pascal_COMPILER_WORKS 1 CACHE INTERNAL "")
    51   SET(CMAKE_Pascal_COMPILER_WORKS 1 CACHE INTERNAL "")
    53 ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)
    52 ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)