cmake_modules/CMakeTestPascalCompiler.cmake
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15859 7b1d6dfa3173
parent 8866 26424c644306
permissions -rw-r--r--
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.
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
8859
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
     6
if(NOT CMAKE_Pascal_COMPILER_WORKS)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
     7
    message(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER}")
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
     8
    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/testpascalcompiler.pas
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
     9
         "program testPascalCompiler;
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    10
          begin
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    11
          end.
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    12
         ")
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    13
8859
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    14
    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    15
         "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    16
          set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    17
          project(test Pascal)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    18
          add_executable(testpascalcompiler testpascalcompiler.pas)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    19
         ")
8750
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.
8859
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    26
    try_compile(CMAKE_Pascal_COMPILER_WORKS
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    27
                ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    28
                ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
8866
26424c644306 this makes Xcode generator test pass
koda
parents: 8859
diff changeset
    29
                test
8859
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    30
                OUTPUT_VARIABLE RESULT_OUTPUT
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    31
                )
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    32
    set(PASCAL_TEST_WAS_RUN 1)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    33
endif(NOT CMAKE_Pascal_COMPILER_WORKS)
8750
d9e57426e759 barebone cmake config file to support pascal files, based off plplot's ada files
koda
parents:
diff changeset
    34
8859
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    35
if(NOT CMAKE_Pascal_COMPILER_WORKS)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    36
    message(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- broken")
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    37
    file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    38
         "Determining if the Pascal compiler works failed with "
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    39
         "the following output:\n${RESULT_OUTPUT}\n\n")
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    40
    message(FATAL_ERROR "The Pascal builder \"${CMAKE_Pascal_COMPILER}\" "
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    41
            "is not able to compile and link a simple test program.\nIt fails "
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    42
            "with the following output:\n ${RESULT_OUTPUT}\n\n"
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    43
            "CMake will not be able to correctly generate this project.")
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    44
else(NOT CMAKE_Pascal_COMPILER_WORKS)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    45
    if(PASCAL_TEST_WAS_RUN)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    46
        message(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- works")
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    47
        file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    48
             "Determining if the Pascal compiler works passed with "
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    49
             "the following output:\n${RESULT_OUTPUT}\n\n")
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    50
    endif(PASCAL_TEST_WAS_RUN)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    51
    set(CMAKE_Pascal_COMPILER_WORKS 1 CACHE INTERNAL "")
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    52
endif(NOT CMAKE_Pascal_COMPILER_WORKS)
bead90828a94 cmake netiquette
koda
parents: 8758
diff changeset
    53