From 43844c5d82398c443a7f1d4c7aea23d470d1a6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Tue, 7 Dec 2021 14:34:24 +0100 Subject: [PATCH 01/21] FindPython: Add support for Python 3.11 --- Modules/FindPython/Support.cmake | 2 +- Modules/FindPythonInterp.cmake | 2 +- Modules/FindPythonLibs.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index ce25cfc7093..b7a0ef6bdbf 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -22,7 +22,7 @@ if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) message (FATAL_ERROR "FindPython: INTERNAL ERROR") endif() if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "3") - set(_${_PYTHON_PREFIX}_VERSIONS 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) + set(_${_PYTHON_PREFIX}_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "2") set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) else() diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index efe0f11901b..4fc40c89dc8 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -54,7 +54,7 @@ unset(_Python_NAMES) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonInterp_FIND_VERSION) if(PythonInterp_FIND_VERSION_COUNT GREATER 1) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 396f0d2ed40..c0caf347b69 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -79,7 +79,7 @@ set(CMAKE_FIND_FRAMEWORK LAST) set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) -set(_PYTHON3_VERSIONS 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) +set(_PYTHON3_VERSIONS 3.11 3.10 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0) if(PythonLibs_FIND_VERSION) if(PythonLibs_FIND_VERSION_COUNT GREATER 1) From 38b00f88014a0866e2aa650550977b4bc676b355 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Fri, 10 Dec 2021 21:23:17 -0800 Subject: [PATCH 02/21] Android: Fix linking android_support for pre-21 system STL This typo was introduced in commit 4dca078829 (Android: Link c++abi and android_support when necessary, 2020-10-29, v3.20.0-rc1~541^2). Fixes: #23004 --- Modules/Platform/Android-Common.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Platform/Android-Common.cmake b/Modules/Platform/Android-Common.cmake index 39da933003e..f1deaca63e0 100644 --- a/Modules/Platform/Android-Common.cmake +++ b/Modules/Platform/Android-Common.cmake @@ -56,7 +56,7 @@ if(CMAKE_ANDROID_STL_TYPE) if(_ANDROID_STL_EXCEPTIONS OR _ANDROID_STL_RTTI) string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -lc++abi") if(CMAKE_SYSTEM_VERSION LESS 21) - list(APPEND CMAKE_${lang}_STANDARD_LIBRARIES "-landroid_support") + string(APPEND CMAKE_${lang}_STANDARD_LIBRARIES " -landroid_support") endif() endif() endmacro() From d176ff71c03f62d993d2fbad6aa416e64e336453 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 15 Dec 2021 10:16:59 -0500 Subject: [PATCH 03/21] FindBoost: Add support for Boost 1.78 Update the list of known versions. Run the command cmake -DBOOST_DIR=/path/to/boost_1_78_0 \ -P Utilities/Scripts/BoostScanDeps.cmake to extract dependencies from the 1.78.0 source tree. The dependencies differ from those of 1.77: * The `log` component no longer depends on `date_time`. Fixes: #23016 --- Modules/FindBoost.cmake | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 38faca24aaf..0ad342f0e6a 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1350,7 +1350,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - else() + elseif(Boost_VERSION_STRING VERSION_LESS 1.78.0) set(_Boost_CONTRACT_DEPENDENCIES thread chrono) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) @@ -1365,6 +1365,21 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) + else() + set(_Boost_CONTRACT_DEPENDENCIES thread chrono) + set(_Boost_COROUTINE_DEPENDENCIES context) + set(_Boost_FIBER_DEPENDENCIES context) + set(_Boost_IOSTREAMS_DEPENDENCIES regex) + set(_Boost_JSON_DEPENDENCIES container) + set(_Boost_LOG_DEPENDENCIES log_setup filesystem thread regex chrono atomic) + set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l) + set(_Boost_MPI_DEPENDENCIES serialization) + set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) + set(_Boost_NUMPY_DEPENDENCIES python${component_python_version}) + set(_Boost_THREAD_DEPENDENCIES chrono atomic) + set(_Boost_TIMER_DEPENDENCIES chrono) + set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic) + set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.78.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() @@ -1638,7 +1653,7 @@ else() # _Boost_COMPONENT_HEADERS. See the instructions at the top of # _Boost_COMPONENT_DEPENDENCIES. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74" + "1.78.0" "1.78" "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74" "1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69" "1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65" "1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60" From 612c0d49f4042303b2c666ec8ca6d02deea637a4 Mon Sep 17 00:00:00 2001 From: "William R. Dieter" Date: Wed, 8 Dec 2021 21:33:25 -0800 Subject: [PATCH 04/21] VS: Fix detecting icx.exe with Intel Compiler toolsets newer than 2021 The logic added by commit 7808cbd644 (CMakeDetermineCompilerId: support Intel DPC++ compiler toolset for VS gen, 2020-12-06, v3.20.0-rc1~330^2) matches a specific toolset known to be the `icx.exe` compiler, and assumes all other Intel C++ compilers (that are not DPC++) must be `icl.exe`. Since `icx.exe` is officially replacing `icl.exe`, use a regex that matches the now-fixed set of toolsets known to use `icl.exe`. Any other Intel C++ compiler will be assumed to be `icx.exe`. Signed-off-by: William R. Dieter --- Modules/CMakeDetermineCompilerId.cmake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 30b4aec90b6..e564517c0b9 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -319,15 +319,13 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_cl "$(CLToolExe)") elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") set(id_cl clang.exe) - # Executable names have been chosen according documentation - # URL: (https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-dpcpp-compiler/top.html#top_GUID-A9B4C91D-97AC-450D-9742-9D895BC8AEE1) elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel") if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "DPC\\+\\+ Compiler") set(id_cl dpcpp.exe) - elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler 2021") - set(id_cl icx.exe) - elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler") + elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler ([8-9]\\.|1[0-9]\\.|XE)") set(id_cl icl.exe) + elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler") + set(id_cl icx.exe) endif() else() set(id_cl cl.exe) From 840fa28d3d308828ebc3516e436f2f9c7ee5bfa1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 16 Dec 2021 07:46:48 -0500 Subject: [PATCH 05/21] ci: Explicitly disable Java tests on Windows Avoid searching for a Java installation on Windows hosts. This will allow some CI hosts to have Java for other projects. We already do this on macOS. While at it, clarify the macOS setting. --- .gitlab/ci/configure_macos_common.cmake | 2 +- .gitlab/ci/configure_windows_common.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/configure_macos_common.cmake b/.gitlab/ci/configure_macos_common.cmake index 37cd51c2052..e78c9cec334 100644 --- a/.gitlab/ci/configure_macos_common.cmake +++ b/.gitlab/ci/configure_macos_common.cmake @@ -2,7 +2,7 @@ # detect that Java is available and working, but a test machine then not have a # working Java installed. To work around this, just act as if Java is not # available on any CI machine. -set(CMake_TEST_Java 0 CACHE FILEPATH "") +set(CMake_TEST_Java OFF CACHE BOOL "") # Qt binaries get placed inside the source directory, which causes them to not # be included in the install-time rpath, but we still want them in the diff --git a/.gitlab/ci/configure_windows_common.cmake b/.gitlab/ci/configure_windows_common.cmake index 45250acbe20..112846a9ad8 100644 --- a/.gitlab/ci/configure_windows_common.cmake +++ b/.gitlab/ci/configure_windows_common.cmake @@ -1,4 +1,5 @@ set(BUILD_QtDialog ON CACHE BOOL "") set(CMAKE_PREFIX_PATH "$ENV{CI_PROJECT_DIR}/.gitlab/qt" CACHE STRING "") +set(CMake_TEST_Java OFF CACHE BOOL "") include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake") From d4bb6c0c7fe8e3ee5aaa275cf939d074f959119b Mon Sep 17 00:00:00 2001 From: Oleg Sidorkin Date: Thu, 16 Dec 2021 21:24:00 +0300 Subject: [PATCH 06/21] FindBoost: Add support for Python 3.10 Regexps in FindBoost assumed that python's minor version had only one digit. That became not true for 3.10. Fixes: #23025 --- Modules/FindBoost.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 0ad342f0e6a..75cbbf56bc7 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -390,7 +390,7 @@ cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var) function(_boost_get_existing_target component target_var) set(names "${component}") - if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$") + if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9]+)?$") # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc. list(APPEND names "${CMAKE_MATCH_1}${CMAKE_MATCH_2}" # python @@ -407,7 +407,7 @@ function(_boost_get_existing_target component target_var) if(TARGET "${prefix}::${name}") # The target may be an INTERFACE library that wraps around a single other # target for compatibility. Unwrap this layer so we can extract real info. - if("${name}" MATCHES "^(python|numpy|mpi_python)([1-9])([0-9])$") + if("${name}" MATCHES "^(python|numpy|mpi_python)([1-9])([0-9]+)$") set(name_nv "${CMAKE_MATCH_1}") if(TARGET "${prefix}::${name_nv}") get_property(type TARGET "${prefix}::${name}" PROPERTY TYPE) @@ -430,7 +430,7 @@ endfunction() function(_boost_get_canonical_target_name component target_var) string(TOLOWER "${component}" component) - if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$") + if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9]+)?$") # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc. set(${target_var} "Boost::${CMAKE_MATCH_1}${CMAKE_MATCH_2}" PARENT_SCOPE) else() @@ -1004,7 +1004,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) # against the new release. # Handle Python version suffixes - if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$") + if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9]+)\$") set(component "${CMAKE_MATCH_1}") set(component_python_version "${CMAKE_MATCH_2}") endif() @@ -1408,7 +1408,7 @@ endfunction() # function(_Boost_COMPONENT_HEADERS component _hdrs) # Handle Python version suffixes - if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$") + if(component MATCHES "^(python|mpi_python|numpy)([0-9]+|[0-9]\\.[0-9]+)\$") set(component "${CMAKE_MATCH_1}") set(component_python_version "${CMAKE_MATCH_2}") endif() @@ -2165,7 +2165,7 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) if(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\$") set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}") set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}") - elseif(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\\.?([0-9])\$") + elseif(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\\.?([0-9]+)\$") set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}") set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}") set(COMPONENT_PYTHON_VERSION_MINOR "${CMAKE_MATCH_3}") From ae6b25d920325585f0e7f56d23d2b0f8e0b39af8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 17 Dec 2021 12:59:51 -0500 Subject: [PATCH 07/21] FindGLUT: Provide legacy GLUT_INCLUDE_DIR result in pkg-config code path Since commit f90d15458a (FindGLUT: Use pkg-config to find flags if available, 2021-06-11, v3.22.0-rc1~469^2) we return early if pkg-config provides the information. During review of that commit, code to populate the legacy `GLUT_INCLUDE_DIR` result variable was removed from that code path. Add code to provide it. Also fix the test case to use `GLUT_INCLUDE_DIR`, the result variable documented officially by the module. Fixes: #23018 --- Modules/FindGLUT.cmake | 2 ++ Tests/FindGLUT/Test/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index dd0975d3951..636f1ea3b14 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -71,6 +71,8 @@ find_package(PkgConfig) if(PKG_CONFIG_FOUND) pkg_check_modules(GLUT glut) if(GLUT_FOUND) + # In the non-pkg-config code path we only provide GLUT_INCLUDE_DIR. + set(GLUT_INCLUDE_DIR "${GLUT_INCLUDE_DIRS}") _add_glut_target_simple() FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_FOUND) return() diff --git a/Tests/FindGLUT/Test/CMakeLists.txt b/Tests/FindGLUT/Test/CMakeLists.txt index 0f4e5367397..f6440b250f3 100644 --- a/Tests/FindGLUT/Test/CMakeLists.txt +++ b/Tests/FindGLUT/Test/CMakeLists.txt @@ -9,7 +9,7 @@ target_link_libraries(testglut_tgt GLUT::GLUT) add_test(NAME testglut_tgt COMMAND testglut_tgt) add_executable(testglut_var main.c) -target_include_directories(testglut_var PRIVATE ${GLUT_INCLUDE_DIRS}) +target_include_directories(testglut_var PRIVATE ${GLUT_INCLUDE_DIR}) target_link_libraries(testglut_var PRIVATE ${GLUT_LIBRARIES}) add_test(NAME testglut_var COMMAND testglut_var) From d45667d45943e1b768b25921f8e481cfafa487a4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 20 Dec 2021 09:03:05 -0500 Subject: [PATCH 08/21] FindBoost: Do not warn about now-supported version 1.78 In commit d176ff71c0 (FindBoost: Add support for Boost 1.78, 2021-12-15) we forgot to update the future-version check. Issue: #23016 --- Modules/FindBoost.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 75cbbf56bc7..c3142d66aac 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1380,7 +1380,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.78.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) + if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.79.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() From 85a07b4b49a88facc04035cb9f4b30f5c4ee28ac Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 22 Dec 2021 03:50:01 -0500 Subject: [PATCH 09/21] ci: Explicitly disable Java tests on VS builds Extend the change from commit 840fa28d3d (ci: Explicitly disable Java tests on Windows, 2021-12-16) to cover VS builds too. --- .gitlab/ci/configure_windows_vs2022_x64.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab/ci/configure_windows_vs2022_x64.cmake b/.gitlab/ci/configure_windows_vs2022_x64.cmake index f6ece57c884..7c024a8e09b 100644 --- a/.gitlab/ci/configure_windows_vs2022_x64.cmake +++ b/.gitlab/ci/configure_windows_vs2022_x64.cmake @@ -1,3 +1,4 @@ set(CMake_TEST_WIX_NO_VERIFY "ON" CACHE BOOL "") +set(CMake_TEST_Java OFF CACHE BOOL "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") From c2777ed00854ce692e4bc83f5c4f5774efd9cd65 Mon Sep 17 00:00:00 2001 From: Jukka Jalkanen <1000jalkanen@gmail.com> Date: Tue, 28 Dec 2021 14:25:04 +0200 Subject: [PATCH 10/21] ASM: Fix identification of armasm 6.17+ Spelling of "ARM Compiler" changed to "Arm Compiler". --- Modules/CMakeDetermineASMCompiler.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index a1814b7dd81..d03cbef010f 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -104,7 +104,7 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS ARMCC) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_ARMCC ) - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ARMCC "(ARM Compiler)|(ARM Assembler)") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ARMCC "(ARM Compiler)|(ARM Assembler)|(Arm Compiler)") list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS NASM) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_NASM "-v") From 41bebbe50a66dfe7bb32365bd119e7e679d0faf1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 11 Jan 2022 12:38:16 -0500 Subject: [PATCH 11/21] file: Restore error capture in undocumented READ_ELF mode Revise the error message added by commit 115ff6a347 (cmELF: Include the ELF parsing code unconditionally, 2021-06-17, v3.22.0-rc1~557^2) to honor the `CAPTURE_ERROR` option. This is needed by the call site in `BundleUtilities` to suppress errors on non-ELF files. Fixes: #23074 --- Source/cmFileCommand.cxx | 11 ++++++++--- Tests/RunCMake/file/READ_ELF-stderr.txt | 21 +++++++++++++++++++-- Tests/RunCMake/file/READ_ELF.cmake | 2 ++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index fd0595d88eb..c3ae2289388 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1213,9 +1213,14 @@ bool HandleReadElfCommand(std::vector const& args, cmELF elf(fileNameArg.c_str()); if (!elf) { - status.SetError(cmStrCat("READ_ELF given FILE \"", fileNameArg, - "\" that is not a valid ELF file.")); - return false; + if (arguments.Error.empty()) { + status.SetError(cmStrCat("READ_ELF given FILE:\n ", fileNameArg, + "\nthat is not a valid ELF file.")); + return false; + } + status.GetMakefile().AddDefinition(arguments.Error, + "not a valid ELF file"); + return true; } if (!arguments.RPath.empty()) { diff --git a/Tests/RunCMake/file/READ_ELF-stderr.txt b/Tests/RunCMake/file/READ_ELF-stderr.txt index 7b328049bd2..fd02ca1947a 100644 --- a/Tests/RunCMake/file/READ_ELF-stderr.txt +++ b/Tests/RunCMake/file/READ_ELF-stderr.txt @@ -1,2 +1,19 @@ -.*file READ_ELF must be called with at least three additional arguments\. -.*file READ_ELF given FILE "XXX" that does not exist\. +^CMake Error at READ_ELF.cmake:1 \(file\): + file READ_ELF must be called with at least three additional arguments\. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at READ_ELF.cmake:2 \(file\): + file READ_ELF given FILE "XXX" that does not exist\. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) ++ +CMake Error at READ_ELF.cmake:4 \(file\): + file READ_ELF given FILE: + + [^ +]*/Tests/RunCMake/file/READ_ELF.cmake + + that is not a valid ELF file\. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file/READ_ELF.cmake b/Tests/RunCMake/file/READ_ELF.cmake index cd02c9b6233..8778fc2c8f3 100644 --- a/Tests/RunCMake/file/READ_ELF.cmake +++ b/Tests/RunCMake/file/READ_ELF.cmake @@ -1,2 +1,4 @@ file(READ_ELF XXX) file(READ_ELF XXX RPATH YYY) +file(READ_ELF ${CMAKE_CURRENT_LIST_FILE} RPATH YYY CAPTURE_ERROR err) +file(READ_ELF ${CMAKE_CURRENT_LIST_FILE} RPATH YYY) From 3a8b6653dcd3b860957f6dfbe7d764b695b29d28 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 11 Jan 2022 16:31:42 -0500 Subject: [PATCH 12/21] MSVC: Use -external:I flag without space to support Clang tools Since commit f29e1874ad (Compiler/MSVC: use the `-external:I` flag for system includes, 2020-05-19, v3.22.0-rc1~593^2) we use the new flag followed by the include directory as a separate argument. Some versions of `clang-cl` and `clang-tidy` do not support the flag unless the include directory is attached to it, so use that form instead. Fixes: #22979 --- Modules/Compiler/MSVC-C.cmake | 2 +- Modules/Compiler/MSVC-CXX.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index a53df46648e..df3691c692f 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -77,6 +77,6 @@ endif() # The `/external:I` flag was made non-experimental in 19.29.30036.3. if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) - set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-external:I ") + set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-external:I") set(_CMAKE_INCLUDE_SYSTEM_FLAG_C_WARNING "-external:W0 ") endif () diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index bcaec69e815..17cbc3c5c02 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -84,6 +84,6 @@ endif() # The `/external:I` flag was made non-experimental in 19.29.30036.3. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.29.30036.3) - set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-external:I ") + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-external:I") set(_CMAKE_INCLUDE_SYSTEM_FLAG_CXX_WARNING "-external:W0 ") endif () From 9e24437c912f52a7afcba58cdd51b74c7dab3861 Mon Sep 17 00:00:00 2001 From: Benjamin Sluis Date: Tue, 11 Jan 2022 07:43:23 -0800 Subject: [PATCH 13/21] VS: Remove the '/guard:cf' flag from v143 link flag table Apply the change from commit db35e3cfd6 (VS: Fix support for '/guard:cf' linker flag for v142, 2019-01-24, v3.14.0-rc1~74^2~2) to the v143 flag table. The entry for `LinkControlFlowGuard` in `v143_Link.json` does not work when used in a `.vcxproj` file. Drop our link flag table entries for this toolset so that the flag will be passed via `AdditionalOptions`. Also add a test case. --- Templates/MSBuild/FlagTables/v143_Link.json | 7 ---- Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 + .../VsControlFlowGuardLinkSetting-check.cmake | 40 +++++++++++++++++++ .../VsControlFlowGuardLinkSetting.cmake | 7 ++++ 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting-check.cmake create mode 100644 Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting.cmake diff --git a/Templates/MSBuild/FlagTables/v143_Link.json b/Templates/MSBuild/FlagTables/v143_Link.json index 71d58f885aa..4422f55bda8 100644 --- a/Templates/MSBuild/FlagTables/v143_Link.json +++ b/Templates/MSBuild/FlagTables/v143_Link.json @@ -977,13 +977,6 @@ "value": "true", "flags": [] }, - { - "name": "LinkControlFlowGuard", - "switch": "guard:cf", - "comment": "Control Flow Guard", - "value": "true", - "flags": [] - }, { "name": "LinkGuardEHContMetadata", "switch": "guard:ehcont", diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index d5ed136ac1d..e11a24a96e6 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -41,6 +41,7 @@ run_cmake(VsDeployEnabled) run_cmake(VsSettings) run_cmake(VsSourceSettingsTool) run_cmake(VsPlatformToolset) +run_cmake(VsControlFlowGuardLinkSetting) run_cmake(VsWinRTByDefault) diff --git a/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting-check.cmake b/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting-check.cmake new file mode 100644 index 00000000000..c13858bd95c --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting-check.cmake @@ -0,0 +1,40 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/ControlFlowGuardProject.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ControlFlowGuardProject.vcxproj does not exist.") + return() +endif() + +set(Is_in_link_section 0) +set(HAS_ControlFlowGuardSetting 0) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *([^<>]+)") + set(RunCMake_TEST_FAILED "Project file ControlFlowGuardProject.vcxproj contains the invalid link property.") + return() + break() + endif() + if(line MATCHES "^ *") + # The start of the link section of the vcxproj file + set(Is_in_link_section 1) + continue() + endif() + if(line MATCHES "^ *") + # The end of the link section of the vcxproj file + set(Is_in_link_section 0) + continue() + endif() + if(Is_in_link_section) + if(line MATCHES "^ *([^<>]+)") + if("${CMAKE_MATCH_1}" MATCHES ".*/guard:cf.*") + set(HAS_ControlFlowGuardSetting 1) + break() + endif() + endif() + endif() +endforeach() + +if(NOT HAS_ControlFlowGuardSetting) + set(RunCMake_TEST_FAILED "Project file ControlFlowGuardProject.vcxproj does not have '/guard:cf' specified in the property.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting.cmake b/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting.cmake new file mode 100644 index 00000000000..31e69acd377 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting.cmake @@ -0,0 +1,7 @@ +enable_language(CXX) + +# Add the Control Flow Guard compiler and linker option +add_compile_options("/guard:cf") +string(APPEND CMAKE_SHARED_LINKER_FLAGS " /guard:cf") + +add_library(ControlFlowGuardProject SHARED foo.cpp) From 6a0ce19ce1cb594cdec19bacc9fc7a38156e38da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Wed, 19 Jan 2022 17:26:14 +0100 Subject: [PATCH 14/21] FortranCInterface: Fix compatibility with GCC gfortran 12 LTO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since version 12.0 the GCC Fortran compiler has implemented "WG5/N1942", which causes, if link-time opmization is enabled, obfuscation of hard-coded string values in the compiler objects and its resulting ELF-binaries. This causes the CMake-internal detection of the mangling scheme for the naming of subroutines to fail. Thus we must ensure to have any link-time optimization features to be disabled on the executable file we perform the detection on. The static libraries, however, must be build with LTO and non-LTO objects, as that will ensure the verify step will operate on IPO objects, if building those is requested by the system compiler flags. Fixes: #23123 Signed-off-by: Björn Esser --- Modules/FortranCInterface/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index 13e4498ad9c..ce0bc10c8ef 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -102,6 +102,19 @@ set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) add_executable(FortranCInterface main.F call_sub.f ${call_mod}) target_link_libraries(FortranCInterface PUBLIC symbols) +# If IPO is enabled here, GCC gfortran >= 12.0 will obfuscate +# the strings of the return values in the compiled executable, +# which we use to regex match against later. +# The static libraries must be build with IPO and non-IPO objects, +# as that will ensure the verify step will operate on IPO objects, +# if requested by the system compiler flags. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND + CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12) + target_compile_options(FortranCInterface PRIVATE "-fno-lto") + target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects") + target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects") +endif() + file(GENERATE OUTPUT exe-$.cmake CONTENT [[ set(FortranCInterface_EXE "$") ]]) From e13dd52535bd68c33106dfc9027ce15cabf68ccf Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sun, 23 Jan 2022 23:08:44 +0200 Subject: [PATCH 15/21] XL: Detect default extensions mode for legacy compiler The legacy non-Clang variant seems to support a GNU-like extensions mode, which is the default. Enable detection for it. --- Modules/CMakeCCompilerId.c.in | 2 +- Modules/CMakeCXXCompilerId.cpp.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 30ad9824eed..0cb8724fb88 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -61,7 +61,7 @@ const char* info_language_standard_default = const char* info_language_extensions_default = "INFO" ":" "extensions_default[" /* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */ -#if (defined(__clang__) || defined(__GNUC__) || \ +#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ defined(__TI_COMPILER_VERSION__)) && \ !defined(__STRICT_ANSI__) && !defined(_MSC_VER) "ON" diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index e7a54874264..4904249addd 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -67,7 +67,7 @@ const char* info_language_standard_default = "INFO" ":" "standard_default[" const char* info_language_extensions_default = "INFO" ":" "extensions_default[" /* !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. */ -#if (defined(__clang__) || defined(__GNUC__) || \ +#if (defined(__clang__) || defined(__GNUC__) || defined(__xlC__) || \ defined(__TI_COMPILER_VERSION__)) && \ !defined(__STRICT_ANSI__) && !defined(_MSC_VER) "ON" From 3a089cd2560db80f9534b9c86a0a7af495533466 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 22 Jan 2022 17:40:10 +0200 Subject: [PATCH 16/21] CMP0128: Prefix test names with mode Makes clear that these tests are for the NEW behaviour. --- ...NewExtensionsStandardDefault-build-check.cmake} | 0 ...e => CMP0128NewExtensionsStandardDefault.cmake} | 0 ...28NewExtensionsStandardUnset-build-check.cmake} | 0 ...ake => CMP0128NewExtensionsStandardUnset.cmake} | 0 ... CMP0128NewNoUnnecessaryFlag-build-check.cmake} | 0 ...lag.cmake => CMP0128NewNoUnnecessaryFlag.cmake} | 0 Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 14 +++++++------- 7 files changed, 7 insertions(+), 7 deletions(-) rename Tests/RunCMake/CompileFeatures/{ExtensionsStandardDefault-build-check.cmake => CMP0128NewExtensionsStandardDefault-build-check.cmake} (100%) rename Tests/RunCMake/CompileFeatures/{ExtensionsStandardDefault.cmake => CMP0128NewExtensionsStandardDefault.cmake} (100%) rename Tests/RunCMake/CompileFeatures/{ExtensionsStandardUnset-build-check.cmake => CMP0128NewExtensionsStandardUnset-build-check.cmake} (100%) rename Tests/RunCMake/CompileFeatures/{ExtensionsStandardUnset.cmake => CMP0128NewExtensionsStandardUnset.cmake} (100%) rename Tests/RunCMake/CompileFeatures/{NoUnnecessaryFlag-build-check.cmake => CMP0128NewNoUnnecessaryFlag-build-check.cmake} (100%) rename Tests/RunCMake/CompileFeatures/{NoUnnecessaryFlag.cmake => CMP0128NewNoUnnecessaryFlag.cmake} (100%) diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault-build-check.cmake similarity index 100% rename from Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault-build-check.cmake rename to Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake similarity index 100% rename from Tests/RunCMake/CompileFeatures/ExtensionsStandardDefault.cmake rename to Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset-build-check.cmake similarity index 100% rename from Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset-build-check.cmake rename to Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake similarity index 100% rename from Tests/RunCMake/CompileFeatures/ExtensionsStandardUnset.cmake rename to Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag-build-check.cmake similarity index 100% rename from Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake rename to Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag-build-check.cmake diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake similarity index 100% rename from Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake rename to Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index ebd981b3d5f..fc2fa06f297 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -68,7 +68,7 @@ macro(mangle_flags variable) list(APPEND flags "${result}") endmacro() -function(test_extensions_opposite) +function(test_cmp0128_new_extensions_opposite) if(extensions_opposite) set(flag_ext "_EXT") endif() @@ -83,16 +83,16 @@ function(test_extensions_opposite) # Make sure we enable/disable extensions when: # 1. LANG_STANDARD is unset. - set(name ExtensionsStandardUnset) + set(name CMP0128NewExtensionsStandardUnset) set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) test_build(--verbose) # 2. LANG_STANDARD matches CMAKE_LANG_STANDARD_DEFAULT. - set(name ExtensionsStandardDefault) + set(name CMP0128NewExtensionsStandardDefault) test_build(--verbose) endfunction() -function(test_no_unnecessary_flag) +function(test_cmp0128_new_no_unnecessary_flag) set(standard_flag "${${lang}${${lang}_STANDARD_DEFAULT}_FLAG}") set(extension_flag "${${lang}${${lang}_STANDARD_DEFAULT}_EXT_FLAG}") @@ -103,7 +103,7 @@ function(test_no_unnecessary_flag) mangle_flags(standard_flag) mangle_flags(extension_flag) - set(name NoUnnecessaryFlag) + set(name CMP0128NewNoUnnecessaryFlag) set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) test_build(--verbose) endfunction() @@ -144,8 +144,8 @@ function(test_lang lang ext) set(extensions_opposite ON) endif() - test_extensions_opposite() - test_no_unnecessary_flag() + test_cmp0128_new_extensions_opposite() + test_cmp0128_new_no_unnecessary_flag() test_cmp0128_warn_match() test_cmp0128_warn_unset() endfunction() From b2c25de8e0e2d53d3ff2ad37ed33d4b8a9bf8b1a Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 22 Jan 2022 17:45:14 +0200 Subject: [PATCH 17/21] CMP0128: Avoid test code duplication --- Tests/RunCMake/CompileFeatures/CMP0128Common.cmake | 7 +++++++ .../CMP0128NewExtensionsStandardDefault.cmake | 7 ------- .../CMP0128NewExtensionsStandardUnset.cmake | 7 ------- .../CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake | 7 ------- Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake | 2 -- Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake | 2 -- Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake | 4 +++- 7 files changed, 10 insertions(+), 26 deletions(-) create mode 100644 Tests/RunCMake/CompileFeatures/CMP0128Common.cmake diff --git a/Tests/RunCMake/CompileFeatures/CMP0128Common.cmake b/Tests/RunCMake/CompileFeatures/CMP0128Common.cmake new file mode 100644 index 00000000000..b309d746aa4 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128Common.cmake @@ -0,0 +1,7 @@ +enable_language(@lang@) + +# Make sure the compile command is not hidden. +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") + +add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake index 32578d1f968..5b7358a8e9e 100644 --- a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardDefault.cmake @@ -1,9 +1,2 @@ -enable_language(@lang@) - -# Make sure the compile command is not hidden. -string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") -string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") - set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) set(CMAKE_@lang@_STANDARD @standard_default@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake index 99bb3f069aa..6923c11925b 100644 --- a/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewExtensionsStandardUnset.cmake @@ -1,8 +1 @@ -enable_language(@lang@) - -# Make sure the compile command is not hidden. -string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") -string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") - set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake index 8ef3a7206d2..73c06414e70 100644 --- a/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128NewNoUnnecessaryFlag.cmake @@ -1,9 +1,2 @@ -enable_language(@lang@) - -# Make sure the compile command is not hidden. -string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") -string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") - set(CMAKE_@lang@_EXTENSIONS @extensions_default@) set(CMAKE_@lang@_STANDARD @standard_default@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake index 0a5606ac7b2..7974093e751 100644 --- a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake @@ -1,7 +1,5 @@ -enable_language(@lang@) cmake_policy(SET CMP0128 OLD) set(CMAKE_POLICY_WARNING_CMP0128 ON) set(CMAKE_@lang@_EXTENSIONS @extensions_default@) set(CMAKE_@lang@_STANDARD @standard_default@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake index cd7af2c00e4..33425a16210 100644 --- a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake @@ -1,6 +1,4 @@ -enable_language(@lang@) cmake_policy(SET CMP0128 OLD) set(CMAKE_POLICY_WARNING_CMP0128 ON) set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) -add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index fc2fa06f297..35b01e31c89 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -35,11 +35,13 @@ elseif (cxx_std_98 IN_LIST CXX_FEATURES AND cxx_std_11 IN_LIST CXX_FEATURES) endif() configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt" "${RunCMake_BINARY_DIR}/CMakeLists.txt" COPYONLY) +file(READ "${RunCMake_SOURCE_DIR}/CMP0128Common.cmake" cmp0128_common) function(test_build) set(test ${name}-${lang}) - configure_file("${RunCMake_SOURCE_DIR}/${name}.cmake" "${RunCMake_BINARY_DIR}/${test}.cmake" @ONLY) + file(READ "${RunCMake_SOURCE_DIR}/${name}.cmake" cmake) + file(CONFIGURE OUTPUT "${RunCMake_BINARY_DIR}/${test}.cmake" CONTENT "${cmake}${cmp0128_common}" @ONLY) if(EXISTS "${RunCMake_SOURCE_DIR}/${name}-build-check.cmake") configure_file("${RunCMake_SOURCE_DIR}/${name}-build-check.cmake" "${RunCMake_BINARY_DIR}/${test}-build-check.cmake" @ONLY) endif() From ee1396e29e98dbd3a4517ce364a534c80bc6fb4a Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 22 Jan 2022 17:29:45 +0200 Subject: [PATCH 18/21] CMP0128: Add flag in OLD mode even when standard matches the default Commit 4a0485be (cmStandardLevelResolver: Avoid unnecessary flags, fix unset level logic, 2021-04-29) unintentionally changed the behavior by modifying the code to match a pre-existing comment. The resulting behavior change however matches the intentions of CMP0128, so we simply need to guard it. Fixes #23122. --- Help/release/3.22.rst | 6 ++++++ Source/cmStandardLevelResolver.cxx | 5 +++-- .../CMP0128OldSameStandard-build-check.cmake | 12 ++++++++++++ .../CMP0128OldSameStandard.cmake | 1 + .../CompileFeatures/RunCMakeTest.cmake | 18 ++++++++++++++++++ 5 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake create mode 100644 Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake diff --git a/Help/release/3.22.rst b/Help/release/3.22.rst index fcb655d196b..4cc34fae76c 100644 --- a/Help/release/3.22.rst +++ b/Help/release/3.22.rst @@ -142,3 +142,9 @@ Other Changes This became available as of VS 16.10 (toolchain version 14.29.30037). * The :cpack_gen:`CPack NSIS Generator` now requires NSIS 3.03 or later. + +3.22.2 +------ + +* The ``OLD`` behavior of :policy:`CMP0128` was fixed to add flags even when + the specified standard matches the compiler default. diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index 61416e063fa..acc2ed298ba 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -206,8 +206,9 @@ struct StandardLevelComputer // If the standard requested is older than the compiler's default or the // extension mode doesn't match then we need to use a flag. - if (stdIt < defaultStdIt || - (cmp0128 == cmPolicies::NEW && ext != defaultExt)) { + if ((cmp0128 != cmPolicies::NEW && stdIt <= defaultStdIt) || + (cmp0128 == cmPolicies::NEW && + (stdIt < defaultStdIt || ext != defaultExt))) { auto offset = std::distance(cm::cbegin(stds), stdIt); return cmStrCat("CMAKE_", this->Language, stdsStrings[offset], "_", type, "_COMPILE_OPTION"); diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake new file mode 100644 index 00000000000..8074b9d3ca1 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard-build-check.cmake @@ -0,0 +1,12 @@ +foreach(flag @flags@) + string(FIND "${actual_stdout}" "${flag}" position) + + if(NOT position EQUAL -1) + set(found TRUE) + break() + endif() +endforeach() + +if(NOT found) + set(RunCMake_TEST_FAILED "No compile flags from \"@flags@\" found for LANG_STANDARD=default.") +endif() diff --git a/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake new file mode 100644 index 00000000000..3be0f10b290 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128OldSameStandard.cmake @@ -0,0 +1 @@ +set(CMAKE_@lang@_STANDARD @standard_default@) diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 35b01e31c89..ad9619e9fe4 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -70,6 +70,23 @@ macro(mangle_flags variable) list(APPEND flags "${result}") endmacro() +function(test_cmp0128_old_same_standard) + if(extensions_default) + set(flag_ext "_EXT") + endif() + + set(flag "${${lang}${${lang}_STANDARD_DEFAULT}${flag_ext}_FLAG}") + + if(NOT flag) + return() + endif() + + mangle_flags(flag) + + set(name CMP0128OldSameStandard) + test_build(--verbose) +endfunction() + function(test_cmp0128_new_extensions_opposite) if(extensions_opposite) set(flag_ext "_EXT") @@ -148,6 +165,7 @@ function(test_lang lang ext) test_cmp0128_new_extensions_opposite() test_cmp0128_new_no_unnecessary_flag() + test_cmp0128_old_same_standard() test_cmp0128_warn_match() test_cmp0128_warn_unset() endfunction() From 1461eff8991ea8e06b47a7e0800a5ae132633e6a Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 24 Jan 2022 12:41:27 -0500 Subject: [PATCH 19/21] Help: Add missing 3.22.1 section to the release notes 3.22.1 had no release notes because there were no changes to documented features or interfaces. Now that we have a 3.22.2 section, add one for the previous patch release to avoid confusion. --- Help/release/3.22.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Help/release/3.22.rst b/Help/release/3.22.rst index 4cc34fae76c..a82d3969557 100644 --- a/Help/release/3.22.rst +++ b/Help/release/3.22.rst @@ -143,6 +143,13 @@ Other Changes * The :cpack_gen:`CPack NSIS Generator` now requires NSIS 3.03 or later. +3.22.1 +------ + +This version made no changes to documented features or interfaces. +Some implementation updates were made to support ecosystem changes +and/or fix regressions. + 3.22.2 ------ From 8cb32fc8ad849a1b80d0da39084df263a42fb8b5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 25 Jan 2022 05:06:40 -0500 Subject: [PATCH 20/21] gitlab-ci: update macOS jobs to use Xcode 13.2 --- .gitlab/os-macos.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml index c3a1c25d3e1..9eca6f84020 100644 --- a/.gitlab/os-macos.yml +++ b/.gitlab/os-macos.yml @@ -7,7 +7,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci ext/$CI_CONCURRENT_ID" # TODO: Factor this out so that each job selects the Xcode version to # use so that different versions can be tested in a single pipeline. - DEVELOPER_DIR: "/Applications/Xcode-13.1.app/Contents/Developer" + DEVELOPER_DIR: "/Applications/Xcode-13.2.app/Contents/Developer" # Avoid conflicting with other projects running on the same machine. SCCACHE_SERVER_PORT: 4227 @@ -87,7 +87,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-13.1 + - xcode-13.2 - nonconcurrent .macos_x86_64_builder_tags_package: @@ -95,7 +95,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-13.1 + - xcode-13.2 - nonconcurrent - finder @@ -104,7 +104,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos - shell - - xcode-13.1 + - xcode-13.2 - concurrent .macos_arm64_builder_tags: @@ -112,7 +112,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos-arm64 - shell - - xcode-13.1 + - xcode-13.2 - nonconcurrent .macos_arm64_builder_ext_tags: @@ -120,7 +120,7 @@ - cmake # Since this is a bare runner, pin to a project. - macos-arm64 - shell - - xcode-13.1 + - xcode-13.2 - concurrent ## macOS-specific scripts From 8428e39ed9cddb3b7f1a6f7a58cb8617503183d2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 25 Jan 2022 08:45:06 -0500 Subject: [PATCH 21/21] CMake 3.22.2 --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 489d2ecc901..646b63d2b97 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 22) -set(CMake_VERSION_PATCH 1) +set(CMake_VERSION_PATCH 2) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0)