summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt2
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt4
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt2
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake50
4 files changed, 38 insertions, 20 deletions
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
index e3cf711..17ad952 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt
@@ -26,5 +26,5 @@ install(FILES Addition.h DESTINATION include)
install(EXPORT AdditionTargets
FILE MathFunctionsAdditionTargets.cmake
NAMESPACE MathFunctions::
- DESTINATION lib/cmake
+ DESTINATION lib/cmake/MathFunctions
)
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
index 4e3496d..fd95e28 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt
@@ -24,7 +24,7 @@ write_basic_package_version_file(
# create config file
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
- INSTALL_DESTINATION lib/cmake
+ INSTALL_DESTINATION lib/cmake/MathFunctions
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
@@ -32,5 +32,5 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake"
- DESTINATION lib/cmake
+ DESTINATION lib/cmake/MathFunctions
)
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
index ffa1e3d..be5ae65 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt
@@ -26,5 +26,5 @@ install(FILES SquareRoot.h DESTINATION include)
install(EXPORT SquareRootTargets
FILE MathFunctionsSquareRootTargets.cmake
NAMESPACE MathFunctions::
- DESTINATION lib/cmake
+ DESTINATION lib/cmake/MathFunctions
)
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 1be570e..e688bcd 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -1,6 +1,17 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+macro(__determine_compiler_id_test testflags_in userflags)
+ separate_arguments(testflags UNIX_COMMAND "${testflags_in}")
+ CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${userflags}" "${src}")
+ CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}")
+
+ if(NOT CMAKE_${lang}_COMPILER_ID)
+ foreach(file ${COMPILER_${lang}_PRODUCED_FILES})
+ CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}")
+ endforeach()
+ endif()
+endmacro()
# Function to compile a source file to identify the compiler. This is
# used internally by CMake and should not be included by user code.
@@ -24,29 +35,36 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
# Compute the directory in which to run the test.
set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang})
- # Try building with no extra flags and then try each set
- # of helper flags. Stop when the compiler is identified.
- foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "")
- foreach(testflags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST}
- ""
- ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS})
- separate_arguments(testflags UNIX_COMMAND "${testflags}")
- CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${userflags}" "${src}")
- CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}")
+ # If we REQUIRE_SUCCESS, i.e. TEST_FLAGS_FIRST has the correct flags, we still need to
+ # try two combinations: with COMPILER_ID_FLAGS (from user) and without (see issue #21869).
+ if(CMAKE_${lang}_COMPILER_ID_REQUIRE_SUCCESS)
+ # If there COMPILER_ID_FLAGS is empty we can error for the first invocation.
+ if("${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" STREQUAL "")
+ set(__compiler_id_require_success TRUE)
+ endif()
+
+ foreach(userflags ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} "")
+ __determine_compiler_id_test("${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST}" "${userflags}")
if(CMAKE_${lang}_COMPILER_ID)
break()
endif()
- foreach(file ${COMPILER_${lang}_PRODUCED_FILES})
- CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}")
+ set(__compiler_id_require_success TRUE)
+ endforeach()
+ else()
+ # Try building with no extra flags and then try each set
+ # of helper flags. Stop when the compiler is identified.
+ foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "")
+ foreach(testflags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST} "" ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS})
+ __determine_compiler_id_test("${testflags}" "${userflags}")
+ if(CMAKE_${lang}_COMPILER_ID)
+ break()
+ endif()
endforeach()
if(CMAKE_${lang}_COMPILER_ID)
break()
endif()
endforeach()
- if(CMAKE_${lang}_COMPILER_ID)
- break()
- endif()
- endforeach()
+ endif()
# Check if compiler id detection gave us the compiler tool.
if(CMAKE_${lang}_COMPILER_ID_TOOL)
@@ -653,7 +671,7 @@ ${CMAKE_${lang}_COMPILER_ID_OUTPUT}
# Some languages may know the correct/desired set of flags and want to fail right away if they don't work.
# This is currently only used by CUDA.
- if(CMAKE_${lang}_COMPILER_ID_REQUIRE_SUCCESS)
+ if(__compiler_id_require_success)
message(FATAL_ERROR "${MSG}")
endif()