From 773f520dfede5ef9dbeb45dfb069d312f5cb4d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20R=C3=B6hling?= Date: Mon, 30 Sep 2024 00:16:59 +0200 Subject: [PATCH] New upstream version 3.30.4 --- Help/command/file.rst | 4 +- Help/command/project.rst | 17 +- Help/release/3.30.rst | 18 +++ .../shared_internal_commands.cmake | 4 +- Modules/FindMatlab.cmake | 145 ++++++++++++------ Modules/FindPython.cmake | 3 +- Modules/FindPython/Support.cmake | 54 +++---- Modules/FindPython3.cmake | 3 +- Modules/Internal/CPack/CPackNuGet.cmake | 3 + Source/CMakeVersion.cmake | 4 +- Source/cmProjectCommand.cxx | 33 ++-- Tests/RunCMake/project/RunCMakeTest.cmake | 1 + .../project/SameProjectVarsSubdir-stdout.txt | 9 ++ .../project/SameProjectVarsSubdir.cmake | 17 ++ Tests/RunCMake/project/subdir1/CMakeLists.txt | 1 + Tests/RunCMake/project/subdir2/CMakeLists.txt | 12 ++ Utilities/cmlibrhash/librhash/util.h | 2 +- 17 files changed, 228 insertions(+), 102 deletions(-) create mode 100644 Tests/RunCMake/project/SameProjectVarsSubdir-stdout.txt create mode 100644 Tests/RunCMake/project/SameProjectVarsSubdir.cmake create mode 100644 Tests/RunCMake/project/subdir1/CMakeLists.txt create mode 100644 Tests/RunCMake/project/subdir2/CMakeLists.txt diff --git a/Help/command/file.rst b/Help/command/file.rst index 5b9dfac5a..34e97e7f5 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -302,7 +302,9 @@ Writing variable values referenced as ``@VAR@`` or ``${VAR}`` contained therein. The substitution rules behave the same as the :command:`configure_file` command. In order to match :command:`configure_file`'s behavior, generator expressions - are not supported for both ``OUTPUT`` and ``CONTENT``. + are not supported for both ``OUTPUT`` and ``CONTENT``, and the output file + is only modified and its timestamp updated if the content is changed or the + file previously didn't exist. The arguments are: diff --git a/Help/command/project.rst b/Help/command/project.rst index 2b938800c..08694fdfd 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -33,10 +33,23 @@ Also sets the variables: Boolean value indicating whether the project is top-level. -Further variables are set by the optional arguments described in the following. -If any of these arguments is not used, then the corresponding variables are +Further variables are set by the optional arguments described in `Options`_ +further below. Where an option is not given, its corresponding variable is set to the empty string. +Note that variables of the form ``_SOURCE_DIR`` and ``_BINARY_DIR`` +may also be set by other commands before ``project()`` is called (see the +:command:`FetchContent_MakeAvailable` command for one example). +Projects should not rely on ``_SOURCE_DIR`` or +``_BINARY_DIR`` holding a particular value outside of the scope +of the call to ``project()`` or one of its child scopes. + +.. versionchanged:: 3.30.4 + If the variables ``_SOURCE_DIR``, + ``_BINARY_DIR``, or ``_IS_TOP_LEVEL`` are + already set as non-cache variables when ``project( ...)`` + is called, the ``project()`` command will overwrite the previous values. + Options ^^^^^^^ diff --git a/Help/release/3.30.rst b/Help/release/3.30.rst index 50fefe295..4cd2b442e 100644 --- a/Help/release/3.30.rst +++ b/Help/release/3.30.rst @@ -258,8 +258,26 @@ Changes made since CMake 3.30.0 include the following. 3.30.3 ------ +* The :command:`project()` command now sets + :variable:`_SOURCE_DIR`, :variable:`_BINARY_DIR`, + and :variable:`_IS_TOP_LEVEL` as normal variables in addition + to setting them as cache entries. This is needed to preserve support for + some :module:`FetchContent` use cases under policy :policy:`CMP0169`'s + NEW behavior. + * The :module:`FindPython` and :module:`FindPython3` modules now define, respectively, the ``Python_DEFINITIONS`` and ``Python3_DEFINITIONS`` variables on Windows to support development with the free threaded version of Python. The :prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` target property is also defined for the various targets provided by these modules. + +3.30.4 +------ + +* The :command:`project()` command now sets + :variable:`_SOURCE_DIR`, :variable:`_BINARY_DIR`, + and :variable:`_IS_TOP_LEVEL` as normal variables only if they + are already set as normal variables when :command:`project` is invoked. + Cache entries by the same names are always set as before. + This refines 3.30.3's behavior change to restore behavior of nested + directories that call :command:`project` with the same project name. diff --git a/Modules/ExternalProject/shared_internal_commands.cmake b/Modules/ExternalProject/shared_internal_commands.cmake index a709670cf..09b976493 100644 --- a/Modules/ExternalProject/shared_internal_commands.cmake +++ b/Modules/ExternalProject/shared_internal_commands.cmake @@ -1221,7 +1221,9 @@ hash=${hash} endif () set(comment "Performing download step (${steps}) for '${name}'") # already verified by 'download_script' - file(WRITE "${verify_script}" "") + # We use file(CONFIGURE) instead of file(WRITE) to avoid updating the + # timestamp when the file already existed and was empty. + file(CONFIGURE OUTPUT "${verify_script}" CONTENT "") # Rather than adding everything to the RepositoryInfo.txt file, it is # more robust to just depend on the download script. That way, we will diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 45d4681c6..6cdf1a448 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -117,10 +117,12 @@ Imported targets This module defines the following :prop_tgt:`IMPORTED` targets: ``Matlab::mex`` - The ``mex`` library, always available. + The ``mex`` library, always available for MATLAB installations. Available for + MCR installations if provided by MCR. ``Matlab::mx`` - The mx library of Matlab (arrays), always available. + The mx library of Matlab (arrays), always available for MATLAB installations. + Available for MCR installations if provided by MCR. ``Matlab::eng`` Matlab engine library. Available only if the ``ENG_LIBRARY`` component @@ -131,10 +133,12 @@ This module defines the following :prop_tgt:`IMPORTED` targets: is requested. ``Matlab::MatlabEngine`` - Matlab C++ engine library, always available for R2018a and newer. + Matlab C++ engine library, always available for MATLAB R2018a and newer. + Available for MCR installations if provided by MCR. ``Matlab::MatlabDataArray`` - Matlab C++ data array library, always available for R2018a and newer. + Matlab C++ data array library, always available for MATLAB R2018a and newer. + Available for MCR installations if provided by MCR. Variables defined by the module ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -160,9 +164,11 @@ Result variables ``Matlab_INCLUDE_DIRS`` the path of the Matlab libraries headers ``Matlab_MEX_LIBRARY`` - library for mex, always available. + library for mex, always available for MATLAB installations. Available for MCR + installations if provided by MCR. ``Matlab_MX_LIBRARY`` - mx library of Matlab (arrays), always available. + mx library of Matlab (arrays), always available for MATLAB installations. + Available for MCR installations if provided by MCR. ``Matlab_ENG_LIBRARY`` Matlab engine library. Available only if the component ``ENG_LIBRARY`` is requested. @@ -172,11 +178,13 @@ Result variables ``Matlab_ENGINE_LIBRARY`` .. versionadded:: 3.13 - Matlab C++ engine library, always available for R2018a and newer. + Matlab C++ engine library, always available for MATLAB R2018a and newer. + Available for MCR installations if provided by MCR. ``Matlab_DATAARRAY_LIBRARY`` .. versionadded:: 3.13 - Matlab C++ data array library, always available for R2018a and newer. + Matlab C++ data array library, always available for MATLAB R2018a and newer. + Available for MCR installations if provided by MCR. ``Matlab_LIBRARIES`` the whole set of libraries of Matlab ``Matlab_MEX_COMPILER`` @@ -311,6 +319,7 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS) endif() set(MATLAB_VERSIONS_MAPPING + "R2024b=24.2" "R2024a=24.1" "R2023b=23.2" "R2023a=9.14" @@ -635,11 +644,14 @@ function(matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_ string(REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}") if(IS_DIRECTORY "${current_MATLAB_ROOT}") + if(IS_DIRECTORY "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}") + cmake_path(APPEND current_MATLAB_ROOT "v${_matlab_current_version_without_dot}") + endif() _Matlab_VersionInfoXML("${current_MATLAB_ROOT}" _matlab_version_tmp) if("${_matlab_version_tmp}" STREQUAL "unknown") set(_matlab_version_tmp ${_matlab_current_version}) endif() - list(APPEND _matlab_roots_list "MCR" ${_matlab_version_tmp} "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}") + list(APPEND _matlab_roots_list "MCR" ${_matlab_version_tmp} "${current_MATLAB_ROOT}") endif() endforeach() endforeach() @@ -1314,6 +1326,10 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve # set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version") #endif() + if(NOT matlab_or_mcr STREQUAL "UNKNOWN") + set(Matlab_OR_MCR_INTERNAL ${matlab_or_mcr} CACHE INTERNAL "Whether Matlab root contains MATLAB or MCR") + endif() + if(NOT matlab_known_version STREQUAL "NOTFOUND") # the version is known, we just return it set(${matlab_final_version} ${matlab_known_version} PARENT_SCOPE) @@ -1380,6 +1396,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve endif() set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version") set(Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version") + set(Matlab_OR_MCR_INTERNAL ${matlab_or_mcr} CACHE INTERNAL "Whether Matlab root contains MATLAB or MCR") unset(_matlab_current_program) unset(_matlab_current_program CACHE) return() @@ -1419,6 +1436,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve # set the version into the cache set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)") + set(Matlab_OR_MCR_INTERNAL ${matlab_or_mcr} CACHE INTERNAL "Whether Matlab root contains MATLAB or MCR") # warning, just in case several versions found (should not happen) if((list_of_all_versions_length GREATER 1) AND MATLAB_FIND_DEBUG) @@ -1432,6 +1450,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve _Matlab_VersionInfoXML("${matlab_root}" _matlab_version_tmp) if(NOT "${_matlab_version_tmp}" STREQUAL "unknown") set(Matlab_VERSION_STRING_INTERNAL ${_matlab_version_tmp} CACHE INTERNAL "Matlab version (automatically determined)") + set(Matlab_OR_MCR_INTERNAL ${matlab_or_mcr} CACHE INTERNAL "Whether Matlab root contains MATLAB or MCR") endif() endif() # Matlab or MCR @@ -1617,12 +1636,18 @@ if(Matlab_ROOT_DIR) message(WARNING "[MATLAB] the specified path for Matlab_ROOT_DIR does not exist (${Matlab_ROOT_DIR})") endif() else() + if("${Matlab_OR_MCR_INTERNAL}" STREQUAL "") + set(_matlab_cached_matlab_or_mcr "UNKNOWN") + else() + set(_matlab_cached_matlab_or_mcr "${Matlab_OR_MCR_INTERNAL}") + endif() # NOTFOUND indicates the code below to search for the version automatically if("${Matlab_VERSION_STRING_INTERNAL}" STREQUAL "") - list(APPEND _matlab_possible_roots "UNKNOWN" "NOTFOUND" ${Matlab_ROOT_DIR}) # empty version, empty MCR/Matlab indication + set(_matlab_cached_version "NOTFOUND") # empty version, empty MCR/Matlab indication else() - list(APPEND _matlab_possible_roots "UNKNOWN" ${Matlab_VERSION_STRING_INTERNAL} ${Matlab_ROOT_DIR}) # cached version + set(_matlab_cached_version "${Matlab_VERSION_STRING_INTERNAL}") # cached version endif() + list(APPEND _matlab_possible_roots "${_matlab_cached_matlab_or_mcr}" "${_matlab_cached_version}" "${Matlab_ROOT_DIR}") endif() else() @@ -1818,7 +1843,9 @@ function(_Matlab_find_library _matlab_library_prefix) endfunction() -set(_matlab_required_variables) +# the matlab root is required +set(_matlab_required_variables Matlab_ROOT_DIR) +set(Matlab_LIBRARIES) # Order is as follow: # - unconditionally required libraries/headers first @@ -1828,40 +1855,50 @@ set(_matlab_required_variables) # the MEX library/header are required find_path( Matlab_INCLUDE_DIRS - NAMES mex.h + NAMES mex.h matrix.h PATHS ${MATLAB_INCLUDE_DIR_TO_LOOK} NO_DEFAULT_PATH ) list(APPEND _matlab_required_variables Matlab_INCLUDE_DIRS) +_Matlab_find_library( + ${_matlab_lib_prefix_for_search} + Matlab_MEX_LIBRARY + NAMES mex + PATHS ${_matlab_lib_dir_for_search} + NO_DEFAULT_PATH +) +if(Matlab_MEX_LIBRARY) + set(Matlab_MEX_LIBRARY_FOUND TRUE) + list(APPEND Matlab_LIBRARIES ${Matlab_MEX_LIBRARY}) +endif() +if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] mex C library: ${Matlab_MEX_LIBRARY}") +endif() + +# The MX library is required +_Matlab_find_library( + ${_matlab_lib_prefix_for_search} + Matlab_MX_LIBRARY + NAMES mx + PATHS ${_matlab_lib_dir_for_search} + NO_DEFAULT_PATH +) +if(Matlab_MX_LIBRARY) + set(Matlab_MX_LIBRARY_FOUND TRUE) + list(APPEND Matlab_LIBRARIES ${Matlab_MX_LIBRARY}) +endif() +if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] mx C library: ${Matlab_MX_LIBRARY}") +endif() + if(Matlab_Or_MCR STREQUAL "MATLAB" OR Matlab_Or_MCR STREQUAL "UNKNOWN") - _Matlab_find_library( - ${_matlab_lib_prefix_for_search} - Matlab_MEX_LIBRARY - NAMES mex - PATHS ${_matlab_lib_dir_for_search} - NO_DEFAULT_PATH - ) list(APPEND _matlab_required_variables Matlab_MEX_LIBRARY) # the MEX extension is required list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION) - # the matlab root is required - list(APPEND _matlab_required_variables Matlab_ROOT_DIR) - - # The MX library is required - _Matlab_find_library( - ${_matlab_lib_prefix_for_search} - Matlab_MX_LIBRARY - NAMES mx - PATHS ${_matlab_lib_dir_for_search} - NO_DEFAULT_PATH - ) list(APPEND _matlab_required_variables Matlab_MX_LIBRARY) - if(Matlab_MX_LIBRARY) - set(Matlab_MX_LIBRARY_FOUND TRUE) - endif() endif() if(Matlab_HAS_CPP_API) @@ -1877,6 +1914,10 @@ if(Matlab_HAS_CPP_API) ) if(Matlab_ENGINE_LIBRARY) set(Matlab_ENGINE_LIBRARY_FOUND TRUE) + list(APPEND Matlab_LIBRARIES ${Matlab_ENGINE_LIBRARY}) + endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] Engine C++ library: ${Matlab_ENGINE_LIBRARY}") endif() # The MatlabDataArray library is required for R2018a+ @@ -1890,6 +1931,10 @@ if(Matlab_HAS_CPP_API) ) if(Matlab_DATAARRAY_LIBRARY) set(Matlab_DATAARRAY_LIBRARY_FOUND TRUE) + list(APPEND Matlab_LIBRARIES ${Matlab_DATAARRAY_LIBRARY}) + endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] Data array C++ library: ${Matlab_DATAARRAY_LIBRARY}") endif() endif() @@ -1905,6 +1950,10 @@ if("ENG_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS) ) if(Matlab_ENG_LIBRARY) set(Matlab_ENG_LIBRARY_FOUND TRUE) + list(APPEND Matlab_LIBRARIES ${Matlab_ENG_LIBRARY}) + endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] eng C library: ${Matlab_ENG_LIBRARY}") endif() endif() @@ -1919,6 +1968,10 @@ if("MAT_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS) ) if(Matlab_MAT_LIBRARY) set(Matlab_MAT_LIBRARY_FOUND TRUE) + list(APPEND Matlab_LIBRARIES ${Matlab_MAT_LIBRARY}) + endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] mat C library: ${Matlab_MAT_LIBRARY}") endif() endif() @@ -1934,6 +1987,9 @@ if("SIMULINK" IN_LIST Matlab_FIND_COMPONENTS) set(Matlab_SIMULINK_FOUND TRUE) list(APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}") endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] Simulink include dir: ${Matlab_SIMULINK_INCLUDE_DIR}") + endif() endif() # component Matlab program @@ -1948,6 +2004,9 @@ if("MAIN_PROGRAM" IN_LIST Matlab_FIND_COMPONENTS) if(Matlab_MAIN_PROGRAM) set(Matlab_MAIN_PROGRAM_FOUND TRUE) endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] Main program: ${Matlab_MAIN_PROGRAM}") + endif() endif() # component Mex Compiler @@ -1962,6 +2021,9 @@ if("MEX_COMPILER" IN_LIST Matlab_FIND_COMPONENTS) if(Matlab_MEX_COMPILER) set(Matlab_MEX_COMPILER_FOUND TRUE) endif() + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] MEX compiler: ${Matlab_MEX_COMPILER}") + endif() endif() # component MCC Compiler @@ -1976,18 +2038,9 @@ if("MCC_COMPILER" IN_LIST Matlab_FIND_COMPONENTS) if(Matlab_MCC_COMPILER) set(Matlab_MCC_COMPILER_FOUND TRUE) endif() -endif() - -set(Matlab_LIBRARIES - ${Matlab_MEX_LIBRARY} ${Matlab_MX_LIBRARY} - ${Matlab_ENG_LIBRARY} ${Matlab_MAT_LIBRARY}) - -if(Matlab_ENGINE_LIBRARY) - list(APPEND Matlab_LIBRARIES ${Matlab_ENGINE_LIBRARY}) -endif() - -if(Matlab_DATAARRAY_LIBRARY) - list(APPEND Matlab_LIBRARIES ${Matlab_DATAARRAY_LIBRARY}) + if(MATLAB_FIND_DEBUG) + message(STATUS "[MATLAB] MCC compiler: ${Matlab_MCC_COMPILER}") + endif() endif() # internal diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 58e134801..797891b9f 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -332,7 +332,8 @@ Hints .. note:: - If ``Python_FIND_ABI`` is not defined, any ABI will be searched. + If ``Python3_FIND_ABI`` is not defined, any ABI, excluding the + ``gil_disabled`` flag, will be searched. From this 4-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, when ``ANY`` is specified for diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 35a1d6793..faca5ae98 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -225,19 +225,14 @@ function (_PYTHON_GET_REGISTRIES _PYTHON_PGR_REGISTRY_PATHS) endfunction() -function (_PYTHON_GET_ABIFLAGS _PGABIFLAGS) - if (NOT DEFINED _${_PYTHON_PREFIX}_FIND_ABI) - set (${_PGABIFLAGS} "" PARENT_SCOPE) - return() - endif() - +function (_PYTHON_GET_ABIFLAGS _PGA_FIND_ABI _PGABIFLAGS) set (abiflags "") - list (GET _${_PYTHON_PREFIX}_FIND_ABI 0 pydebug) - list (GET _${_PYTHON_PREFIX}_FIND_ABI 1 pymalloc) - list (GET _${_PYTHON_PREFIX}_FIND_ABI 2 unicode) - list (LENGTH _${_PYTHON_PREFIX}_FIND_ABI find_abi_length) + list (GET _PGA_FIND_ABI 0 pydebug) + list (GET _PGA_FIND_ABI 1 pymalloc) + list (GET _PGA_FIND_ABI 2 unicode) + list (LENGTH _PGA_FIND_ABI find_abi_length) if (find_abi_length GREATER 3) - list (GET _${_PYTHON_PREFIX}_FIND_ABI 3 gil) + list (GET _PGA_FIND_ABI 3 gil) else() set (gil "OFF") endif() @@ -302,12 +297,8 @@ function (_PYTHON_GET_PATH_SUFFIXES _PYTHON_PGPS_PATH_SUFFIXES) set (_PGPS_IMPLEMENTATIONS ${_${_PYTHON_PREFIX}_FIND_IMPLEMENTATIONS}) endif() - if (DEFINED _${_PYTHON_PREFIX}_ABIFLAGS) - set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") - list (TRANSFORM abi REPLACE "^$" "") - else() - set (abi "mu" "m" "u" "") - endif() + set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") + list (TRANSFORM abi REPLACE "^$" "") set (path_suffixes) @@ -401,12 +392,8 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES) else() string (REPLACE "." "" name_version ${version}) endif() - if (DEFINED _${_PYTHON_PREFIX}_ABIFLAGS) - set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") - list (TRANSFORM abi REPLACE "^$" "") - else() - set (abi "") - endif() + set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") + list (TRANSFORM abi REPLACE "^$" "") if (abi) set (abinames "${abi}") list (TRANSFORM abinames PREPEND "python${name_version}") @@ -420,16 +407,8 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES) endif() if (_PGN_POSIX) - if (DEFINED _${_PYTHON_PREFIX}_ABIFLAGS) - set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") - list (TRANSFORM abi REPLACE "^$" "") - else() - if (_PGN_INTERPRETER OR _PGN_CONFIG) - set (abi "") - else() - set (abi "mu" "m" "u" "") - endif() - endif() + set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") + list (TRANSFORM abi REPLACE "^$" "") if (abi) if (_PGN_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) @@ -1529,7 +1508,6 @@ if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_LESS "3") set (_${_PYTHON_PREFIX}_ABIFLAGS "") else() unset (_${_PYTHON_PREFIX}_FIND_ABI) - unset (_${_PYTHON_PREFIX}_ABIFLAGS) if (DEFINED ${_PYTHON_PREFIX}_FIND_ABI) # normalization string (TOUPPER "${${_PYTHON_PREFIX}_FIND_ABI}" _${_PYTHON_PREFIX}_FIND_ABI) @@ -1539,8 +1517,14 @@ else() message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_ABI}: invalid value for '${_PYTHON_PREFIX}_FIND_ABI'. Ignore it") unset (_${_PYTHON_PREFIX}_FIND_ABI) endif() + _python_get_abiflags ("${${_PYTHON_PREFIX}_FIND_ABI}" _${_PYTHON_PREFIX}_ABIFLAGS) + else() + if (WIN32) + _python_get_abiflags ("OFF;OFF;OFF;OFF" _${_PYTHON_PREFIX}_ABIFLAGS) + else() + _python_get_abiflags ("ANY;ANY;ANY;OFF" _${_PYTHON_PREFIX}_ABIFLAGS) + endif() endif() - _python_get_abiflags (_${_PYTHON_PREFIX}_ABIFLAGS) endif() unset (${_PYTHON_PREFIX}_SOABI) unset (${_PYTHON_PREFIX}_SOSABI) diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 55d33a248..19b022461 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -330,7 +330,8 @@ Hints .. note:: - If ``Python3_FIND_ABI`` is not defined, any ABI will be searched. + If ``Python3_FIND_ABI`` is not defined, any ABI, excluding the + ``gil_disabled`` flag, will be searched. From this 4-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, when ``ANY`` is specified for diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index bfd3ce554..83a8f4317 100644 --- a/Modules/Internal/CPack/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -404,6 +404,7 @@ function(_cpack_nuget_convert_tfm_to_frameworkname TFM OUTPUT_VAR_NAME) # 2. netstandard13 -> .NETStandard1.3 # 3. netcoreapp21 -> .NETCoreApp2.1 # 4. dotnet50 -> .NETPlatform5.0 + # 5. native0.0 -> native0.0 Support for native C++ and mixed C++/CLI projects if(TFM MATCHES "^net([1-4](.[\.0-9])?)$") # CMAKE_MATCH_1 holds the version part _cpack_nuget_get_dotted_version("${CMAKE_MATCH_1}" dotted_version) set(framework_name ".NETFramework${dotted_version}") @@ -418,6 +419,8 @@ function(_cpack_nuget_convert_tfm_to_frameworkname TFM OUTPUT_VAR_NAME) elseif(TFM MATCHES "^dotnet([0-9]+(\.[0-9]+)*)$") _cpack_nuget_get_dotted_version("${CMAKE_MATCH_1}" dotted_version) set(framework_name ".NETPlatform${dotted_version}") + elseif(TFM STREQUAL "native0.0") + set(framework_name "${TFM}") else() message(FATAL_ERROR "Target Framework Moniker '${TFM}' not recognized") endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7573fe19e..9a1e8c519 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 30) -set(CMake_VERSION_PATCH 3) +set(CMake_VERSION_PATCH 4) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) @@ -21,7 +21,7 @@ endif() if(NOT CMake_VERSION_NO_GIT) # If this source was exported by 'git archive', use its commit info. - set(git_info [==[3cc9cb6ee2 CMake 3.30.3]==]) + set(git_info [==[5e4526d6dd CMake 3.30.4]==]) # Otherwise, try to identify the current development source version. if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* " diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 13070ddf9..da92ea679 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -8,6 +8,8 @@ #include #include +#include + #include "cmsys/RegularExpression.hxx" #include "cmExecutionStatus.h" @@ -56,17 +58,21 @@ bool cmProjectCommand(std::vector const& args, mf.SetProjectName(projectName); - mf.AddCacheDefinition(projectName + "_BINARY_DIR", - mf.GetCurrentBinaryDirectory(), + std::string varName = cmStrCat(projectName, "_BINARY_DIR"_s); + bool nonCacheVarAlreadySet = mf.IsDefinitionSet(varName); + mf.AddCacheDefinition(varName, mf.GetCurrentBinaryDirectory(), "Value Computed by CMake", cmStateEnums::STATIC); - mf.AddDefinition(projectName + "_BINARY_DIR", - mf.GetCurrentBinaryDirectory()); + if (nonCacheVarAlreadySet) { + mf.AddDefinition(varName, mf.GetCurrentBinaryDirectory()); + } - mf.AddCacheDefinition(projectName + "_SOURCE_DIR", - mf.GetCurrentSourceDirectory(), + varName = cmStrCat(projectName, "_SOURCE_DIR"_s); + nonCacheVarAlreadySet = mf.IsDefinitionSet(varName); + mf.AddCacheDefinition(varName, mf.GetCurrentSourceDirectory(), "Value Computed by CMake", cmStateEnums::STATIC); - mf.AddDefinition(projectName + "_SOURCE_DIR", - mf.GetCurrentSourceDirectory()); + if (nonCacheVarAlreadySet) { + mf.AddDefinition(varName, mf.GetCurrentSourceDirectory()); + } mf.AddDefinition("PROJECT_BINARY_DIR", mf.GetCurrentBinaryDirectory()); mf.AddDefinition("PROJECT_SOURCE_DIR", mf.GetCurrentSourceDirectory()); @@ -74,11 +80,14 @@ bool cmProjectCommand(std::vector const& args, mf.AddDefinition("PROJECT_NAME", projectName); mf.AddDefinitionBool("PROJECT_IS_TOP_LEVEL", mf.IsRootMakefile()); - mf.AddCacheDefinition(projectName + "_IS_TOP_LEVEL", - mf.IsRootMakefile() ? "ON" : "OFF", + + varName = cmStrCat(projectName, "_IS_TOP_LEVEL"_s); + nonCacheVarAlreadySet = mf.IsDefinitionSet(varName); + mf.AddCacheDefinition(varName, mf.IsRootMakefile() ? "ON" : "OFF", "Value Computed by CMake", cmStateEnums::STATIC); - mf.AddDefinition(projectName + "_IS_TOP_LEVEL", - mf.IsRootMakefile() ? "ON" : "OFF"); + if (nonCacheVarAlreadySet) { + mf.AddDefinition(varName, mf.IsRootMakefile() ? "ON" : "OFF"); + } // Set the CMAKE_PROJECT_NAME variable to be the highest-level // project name in the tree. If there are two project commands diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index 9c49281c6..e6e1bdb0c 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -45,6 +45,7 @@ run_cmake(ProjectIsTopLevel) run_cmake(ProjectIsTopLevelMultiple) run_cmake(ProjectIsTopLevelSubdirectory) run_cmake(ProjectTwice) +run_cmake(SameProjectVarsSubdir) run_cmake(VersionAndLanguagesEmpty) run_cmake(VersionEmpty) run_cmake(VersionInvalid) diff --git a/Tests/RunCMake/project/SameProjectVarsSubdir-stdout.txt b/Tests/RunCMake/project/SameProjectVarsSubdir-stdout.txt new file mode 100644 index 000000000..73dadfda3 --- /dev/null +++ b/Tests/RunCMake/project/SameProjectVarsSubdir-stdout.txt @@ -0,0 +1,9 @@ +(-- )? SameProjectVarsSubdir_SOURCE_DIR = [^ +]+/subdir1 + SameProjectVarsSubdir_BINARY_DIR = [^ +]+/subdir1 + SameProjectVarsSubdir_IS_TOP_LEVEL = OFF +(-- )? sub2proj_SOURCE_DIR = [^ +]+/subdir2 + sub2proj_BINARY_DIR = [^ +]+/subdir2 diff --git a/Tests/RunCMake/project/SameProjectVarsSubdir.cmake b/Tests/RunCMake/project/SameProjectVarsSubdir.cmake new file mode 100644 index 000000000..36a796064 --- /dev/null +++ b/Tests/RunCMake/project/SameProjectVarsSubdir.cmake @@ -0,0 +1,17 @@ +add_subdirectory(subdir1) + +# Simulate a situation that FetchContent_MakeAvailable() used to be able to +# create, but that should no longer be possible. If depname_SOURCE_DIR and +# depname_BINARY_DIR variables are defined as non-cache variables before the +# project(depname) call, those non-cache variables used to prevent project() +# from setting those variables itself due to CMP0126 (if set to NEW). This only +# showed up if the project(depname) call was not in the dependency's top level +# CMakeLists.txt file, but rather in a subdirectory (googletest is one example +# that used to do this). Since CMake 3.30.3, the dependency's project() call +# should set non-cache variables that will make the variable values visible +# and avoid any masking from variables set before the project() call. We want +# to verify this 3.30.3+ behavior here and in subdir2. +set(sub2proj_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(sub2proj_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + +add_subdirectory(subdir2) diff --git a/Tests/RunCMake/project/subdir1/CMakeLists.txt b/Tests/RunCMake/project/subdir1/CMakeLists.txt new file mode 100644 index 000000000..d6be2299a --- /dev/null +++ b/Tests/RunCMake/project/subdir1/CMakeLists.txt @@ -0,0 +1 @@ +project(${RunCMake_TEST} LANGUAGES NONE) diff --git a/Tests/RunCMake/project/subdir2/CMakeLists.txt b/Tests/RunCMake/project/subdir2/CMakeLists.txt new file mode 100644 index 000000000..c28e0c97b --- /dev/null +++ b/Tests/RunCMake/project/subdir2/CMakeLists.txt @@ -0,0 +1,12 @@ +message(STATUS + " ${RunCMake_TEST}_SOURCE_DIR = ${${RunCMake_TEST}_SOURCE_DIR}\n" + " ${RunCMake_TEST}_BINARY_DIR = ${${RunCMake_TEST}_BINARY_DIR}\n" + " ${RunCMake_TEST}_IS_TOP_LEVEL = ${${RunCMake_TEST}_IS_TOP_LEVEL}" +) + +project(sub2proj LANGUAGES NONE) + +message(STATUS + " sub2proj_SOURCE_DIR = ${sub2proj_SOURCE_DIR}\n" + " sub2proj_BINARY_DIR = ${sub2proj_BINARY_DIR}" +) diff --git a/Utilities/cmlibrhash/librhash/util.h b/Utilities/cmlibrhash/librhash/util.h index a0a0674e8..4da1be69f 100644 --- a/Utilities/cmlibrhash/librhash/util.h +++ b/Utilities/cmlibrhash/librhash/util.h @@ -44,7 +44,7 @@ extern "C" { # define rhash_aligned_free(ptr) _aligned_free(ptr) #elif !defined(NO_STDC_ALIGNED_ALLOC) && (__STDC_VERSION__ >= 201112L || defined(_ISOC11_SOURCE)) \ - && !(defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 15))) \ + && !(defined(__GLIBC__) && (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 16))) \ && !(defined(__ibmxl__) && defined(__clang__) && defined(__linux__)) \ && !defined(__APPLE__) && !defined(__HAIKU__) && !defined(__sun) \ && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 28)