diff options
25 files changed, 76 insertions, 29 deletions
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 62c4b7c..6f137c4 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -93,7 +93,7 @@ Format An optional array of strings representing the names of presets to inherit from. The preset will inherit all of the fields from the ``inherits`` presets by default (except ``name``, ``hidden``, ``inherits``, - ``description``, and ``longDescription``), but can override them as + ``description``, and ``displayName``), but can override them as desired. If multiple ``inherits`` presets provide conflicting values for the same field, the earlier preset in the ``inherits`` list will be preferred. Presets in ``CMakePresets.json`` may not inherit from presets diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 7af0171..7e17277 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -275,8 +275,10 @@ function(FIND_PACKAGE_CHECK_VERSION version result) unset (${FPCV_RESULT_MESSAGE_VARIABLE} PARENT_SCOPE) endif() - if (CMAKE_FIND_PACKAGE_NAME) - set (package ${CMAKE_FIND_PACKAGE_NAME}) + if (_CMAKE_FPHSA_PACKAGE_NAME) + set (package "${_CMAKE_FPHSA_PACKAGE_NAME}") + elseif (CMAKE_FIND_PACKAGE_NAME) + set (package "${CMAKE_FIND_PACKAGE_NAME}") else() message (FATAL_ERROR "find_package_check_version(): Cannot be used outside a 'Find Module'") endif() @@ -436,6 +438,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) "will be used.") endif() + # to propagate package name to FIND_PACKAGE_CHECK_VERSION + set(_CMAKE_FPHSA_PACKAGE_NAME "${_NAME}") + # now that we collected all arguments, process them if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") diff --git a/Modules/Internal/CheckCompilerFlag.cmake b/Modules/Internal/CheckCompilerFlag.cmake index f790d87..6b2a11e 100644 --- a/Modules/Internal/CheckCompilerFlag.cmake +++ b/Modules/Internal/CheckCompilerFlag.cmake @@ -11,20 +11,20 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var) - if(_lang STREQUAL C) + if(_lang STREQUAL "C") set(_lang_src "int main(void) { return 0; }") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C") - elseif(_lang STREQUAL CXX) + elseif(_lang STREQUAL "CXX") set(_lang_src "int main() { return 0; }") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+") - elseif(_lang STREQUAL CUDA) + elseif(_lang STREQUAL "CUDA") set(_lang_src "__host__ int main() { return 0; }") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+" # Host GNU FAIL_REGEX "argument unused during compilation: .*") # Clang - elseif(_lang STREQUAL Fortran) + elseif(_lang STREQUAL "Fortran") set(_lang_src " program test\n stop\n end program") set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Fortran") - elseif(_lang STREQUAL OBJC) + elseif(_lang STREQUAL "OBJC") set(_lang_src [=[ #ifndef __OBJC__ # error "Not an Objective-C compiler" @@ -32,7 +32,7 @@ function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var) int main(void) { return 0; }]=]) set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C" # GNU FAIL_REGEX "argument unused during compilation: .*") # Clang - elseif(_lang STREQUAL OBJCXX) + elseif(_lang STREQUAL "OBJCXX") set(_lang_src [=[ #ifndef __OBJC__ # error "Not an Objective-C++ compiler" @@ -40,7 +40,7 @@ int main(void) { return 0; }]=]) int main(void) { return 0; }]=]) set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C\\+\\+" # GNU FAIL_REGEX "argument unused during compilation: .*") # Clang - elseif(_lang STREQUAL ISPC) + elseif(_lang STREQUAL "ISPC") set(_lang_src "float func(uniform int32, float a) { return a / 2.25; }") else() message (SEND_ERROR "check_compiler_flag: ${_lang}: unknown language.") diff --git a/Modules/Internal/CheckSourceCompiles.cmake b/Modules/Internal/CheckSourceCompiles.cmake index 91c8964..3b2152a 100644 --- a/Modules/Internal/CheckSourceCompiles.cmake +++ b/Modules/Internal/CheckSourceCompiles.cmake @@ -10,25 +10,25 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) if(NOT DEFINED "${_var}") - if(_lang STREQUAL C) + if(_lang STREQUAL "C") set(_lang_textual "C") set(_lang_ext "c") - elseif(_lang STREQUAL CXX) + elseif(_lang STREQUAL "CXX") set(_lang_textual "C++") set(_lang_ext "cxx") - elseif(_lang STREQUAL CUDA) + elseif(_lang STREQUAL "CUDA") set(_lang_textual "CUDA") set(_lang_ext "cu") - elseif(_lang STREQUAL Fortran) + elseif(_lang STREQUAL "Fortran") set(_lang_textual "Fortran") set(_lang_ext "F90") - elseif(_lang STREQUAL ISPC) + elseif(_lang STREQUAL "ISPC") set(_lang_textual "ISPC") set(_lang_ext "ispc") - elseif(_lang STREQUAL OBJC) + elseif(_lang STREQUAL "OBJC") set(_lang_textual "Objective-C") set(_lang_ext "m") - elseif(_lang STREQUAL OBJCXX) + elseif(_lang STREQUAL "OBJCXX") set(_lang_textual "Objective-C++") set(_lang_ext "mm") else() diff --git a/Modules/Internal/CheckSourceRuns.cmake b/Modules/Internal/CheckSourceRuns.cmake index 3a4b758..676f3d0 100644 --- a/Modules/Internal/CheckSourceRuns.cmake +++ b/Modules/Internal/CheckSourceRuns.cmake @@ -10,22 +10,22 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var) if(NOT DEFINED "${_var}") - if(_lang STREQUAL C) + if(_lang STREQUAL "C") set(_lang_textual "C") set(_lang_ext "c") - elseif(_lang STREQUAL CXX) + elseif(_lang STREQUAL "CXX") set(_lang_textual "C++") set(_lang_ext "cxx") - elseif(_lang STREQUAL CUDA) + elseif(_lang STREQUAL "CUDA") set(_lang_textual "CUDA") set(_lang_ext "cu") - elseif(_lang STREQUAL Fortran) + elseif(_lang STREQUAL "Fortran") set(_lang_textual "Fortran") set(_lang_ext "F90") - elseif(_lang STREQUAL OBJC) + elseif(_lang STREQUAL "OBJC") set(_lang_textual "Objective-C") set(_lang_ext "m") - elseif(_lang STREQUAL OBJCXX) + elseif(_lang STREQUAL "OBJCXX") set(_lang_textual "Objective-C++") set(_lang_ext "mm") else() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ba378fb..ca56d3a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -2,9 +2,12 @@ # file Copyright.txt or https://cmake.org/licensing for details. # To ensure maximum portability across various compilers and platforms -# deactivate any compiler extensions -set(CMAKE_C_EXTENSIONS FALSE) -set(CMAKE_CXX_EXTENSIONS FALSE) +# deactivate any compiler extensions. Skip this for QNX, where additional +# work is needed to build without compiler extensions. +if (NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") + set(CMAKE_C_EXTENSIONS FALSE) + set(CMAKE_CXX_EXTENSIONS FALSE) +endif() include(CheckIncludeFile) # Check if we can build support for ELF parsing. diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 7000b79..615bf20 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -539,10 +539,13 @@ add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILE add_RunCMake_test(target_include_directories) add_RunCMake_test(target_sources) add_RunCMake_test(CheckCompilerFlag -DCMake_TEST_CUDA=${CMake_TEST_CUDA} - -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) + -DCMake_TEST_ISPC=${CMake_TEST_ISPC} + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) add_RunCMake_test(CheckSourceCompiles -DCMake_TEST_CUDA=${CMake_TEST_CUDA} - -DCMake_TEST_ISPC=${CMake_TEST_ISPC}) -add_RunCMake_test(CheckSourceRuns -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) + -DCMake_TEST_ISPC=${CMake_TEST_ISPC} + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) +add_RunCMake_test(CheckSourceRuns -DCMake_TEST_CUDA=${CMake_TEST_CUDA} + -DCMAKE_Fortran_COMPILER_ID=${CMAKE_Fortran_COMPILER_ID}) set_property(TEST RunCMake.CheckCompilerFlag RunCMake.CheckSourceCompiles RunCMake.CheckSourceRuns diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake index 095fd54..6483f11 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake @@ -2,6 +2,8 @@ enable_language (C) include(CheckCompilerFlag) +set(C 1) # test that this is tolerated + check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid C compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake index a40699c..681a546 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake @@ -2,6 +2,8 @@ enable_language (CUDA) include(CheckCompilerFlag) +set(CUDA 1) # test that this is tolerated + check_compiler_flag(CUDA "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CUDA compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake index bbc104e..60e9755 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake @@ -2,6 +2,8 @@ enable_language (CXX) include(CheckCompilerFlag) +set(CXX 1) # test that this is tolerated + check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CXX compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake index 220ee29..7bb88b1 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake @@ -1,6 +1,8 @@ enable_language (Fortran) include(CheckCompilerFlag) +set(Fortran 1) # test that this is tolerated + check_compiler_flag(Fortran "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid Fortran compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake index e9344ca..f250f8d 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake @@ -1,6 +1,8 @@ enable_language (OBJC) include(CheckCompilerFlag) +set(OBJC 1) # test that this is tolerated + check_compiler_flag(OBJC "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid OBJC compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake index 503a1de..bc940a6 100644 --- a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake @@ -1,6 +1,8 @@ enable_language (OBJCXX) include(CheckCompilerFlag) +set(OBJCXX 1) # test that this is tolerated + check_compiler_flag(OBJCXX "-_this_is_not_a_flag_" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid OBJCXX compile flag didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake index cf46189..4f73622 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake @@ -2,6 +2,8 @@ enable_language (C) include(CheckSourceCompiles) +set(C 1) # test that this is tolerated + check_source_compiles(C "I don't build" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid C source didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake index 1e6e6b2..2190649 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake @@ -2,6 +2,8 @@ enable_language (CUDA) include(CheckSourceCompiles) +set(CUDA 1) # test that this is tolerated + check_source_compiles(CUDA "I don't build" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CUDA source didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake index ec01d42..97c9c30 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake @@ -2,6 +2,8 @@ enable_language (CXX) include(CheckSourceCompiles) +set(CXX 1) # test that this is tolerated + check_source_compiles(CXX "I don't build" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "invalid CXX source didn't fail.") diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake index 1d4e16d..48dc525 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake @@ -3,6 +3,8 @@ enable_language (Fortran) include(CheckSourceCompiles) +set(Fortran 1) # test that this is tolerated + check_source_compiles(Fortran [=[ PROGRAM TEST_HAVE_PRINT PRINT *, 'Hello' diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake index 2f53cfc4..76a5009 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake @@ -1,6 +1,8 @@ enable_language (OBJC) include(CheckSourceCompiles) +set(OBJC 1) # test that this is tolerated + check_source_compiles(OBJC [[ #import <Foundation/Foundation.h> int main() { diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake index 805d513..814237e 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake @@ -1,6 +1,8 @@ enable_language (OBJCXX) include(CheckSourceCompiles) +set(OBJCXX 1) # test that this is tolerated + check_source_compiles(OBJCXX [[ #include <vector> #import <Foundation/Foundation.h> diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake index 3029ac2..96a1027 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake @@ -2,6 +2,8 @@ enable_language (C) include(CheckSourceRuns) +set(C 1) # test that this is tolerated + check_source_runs(C "int main() {return 2;}" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "C check_source_runs succeeded, but should have failed.") diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake index 01e5ac8..ea5f4f9 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake @@ -2,6 +2,8 @@ enable_language (CUDA) include(CheckSourceRuns) +set(CUDA 1) # test that this is tolerated + check_source_runs(CUDA "int main() {return 2;}" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "CUDA check_source_runs succeeded, but should have failed.") diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake index d47ddda..c4bef6e 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake @@ -2,6 +2,8 @@ enable_language (CXX) include(CheckSourceRuns) +set(CXX 1) # test that this is tolerated + check_source_runs(CXX "int main() {return 2;}" SHOULD_FAIL) if(SHOULD_FAIL) message(SEND_ERROR "CXX check_source_runs succeeded, but should have failed.") diff --git a/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake index 2a1fdfe..50e8ec8 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake @@ -3,6 +3,8 @@ enable_language (Fortran) include(CheckSourceRuns) +set(Fortran 1) # test that this is tolerated + check_source_runs(Fortran [=[ PROGRAM TEST_HAVE_PRINT PRINT *, 'Hello' diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake index 55f28f3..b828352 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake @@ -1,6 +1,8 @@ enable_language (OBJC) include(CheckSourceRuns) +set(OBJC 1) # test that this is tolerated + check_source_runs(OBJC [[ #import <Foundation/Foundation.h> int main() { diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake index a218acd..8a56f13 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake @@ -1,6 +1,8 @@ enable_language (OBJCXX) include(CheckSourceRuns) +set(OBJCXX 1) # test that this is tolerated + check_source_runs(OBJCXX [[ #include <vector> #import <Foundation/Foundation.h> |