Imported Upstream version 3.21.5 upstream/3.21.5
authorJinWang An <jinwang.an@samsung.com>
Tue, 27 Dec 2022 08:20:01 +0000 (17:20 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 27 Dec 2022 08:20:01 +0000 (17:20 +0900)
21 files changed:
Help/command/add_library.rst
Help/command/try_compile.rst
Help/command/try_run.rst
Help/manual/cmake-generator-expressions.7.rst
Help/release/3.21.rst
Modules/CMakeDetermineCompilerId.cmake
Modules/CMakeFindBinUtils.cmake
Modules/CMakeFortranCompiler.cmake.in
Modules/FindThreads.cmake
Modules/Platform/Windows-GNU.cmake
Modules/UseSWIG.cmake
Source/CMakeVersion.cmake
Source/cmDependsFortran.cxx
Source/cmMakefileTargetGenerator.cxx
Source/cmScanDepFormat.cxx
Source/cmakemain.cxx
Templates/MSBuild/FlagTables/v143_Link.json
Tests/RunCMake/VS10Project/RunCMakeTest.cmake
Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting-check.cmake [new file with mode: 0644]
Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting.cmake [new file with mode: 0644]
Tests/UseSWIG/CMakeLists.txt

index dfc6500..1235155 100644 (file)
@@ -166,6 +166,8 @@ itself and is not included as a target in the generated buildsystem.
   call are ``PRIVATE`` to the interface library and do not appear in its
   :prop_tgt:`INTERFACE_SOURCES` target property.
 
+.. _`add_library imported libraries`:
+
 Imported Libraries
 ^^^^^^^^^^^^^^^^^^
 
@@ -205,7 +207,8 @@ The ``<type>`` must be one of:
     :prop_tgt:`IMPORTED_IMPLIB_<CONFIG>`) specifies the location of the
     DLL import library file (``.lib`` or ``.dll.a``) on disk, and the
     ``IMPORTED_LOCATION`` is the location of the ``.dll`` runtime
-    library (and is optional).
+    library (and is optional, but needed by the :genex:`TARGET_RUNTIME_DLLS`
+    generator expression).
 
   Additional usage requirements may be specified in ``INTERFACE_*`` properties.
 
index 06da910..08f8d5b 100644 (file)
@@ -19,10 +19,6 @@ Try Compiling Whole Projects
 Try building a project.  The success or failure of the ``try_compile``,
 i.e. ``TRUE`` or ``FALSE`` respectively, is returned in ``<resultVar>``.
 
-.. versionadded:: 3.14
-  The name of the ``<resultVar>`` is defined by the user.  Previously, it had
-  a fixed name ``RESULT_VAR``.
-
 In this form, ``<srcdir>`` should contain a complete CMake project with a
 ``CMakeLists.txt`` file and all sources.  The ``<bindir>`` and ``<srcdir>``
 will not be deleted after this command is run.  Specify ``<targetName>`` to
@@ -51,10 +47,6 @@ Try building an executable or static library from one or more source files
 variable).  The success or failure of the ``try_compile``, i.e. ``TRUE`` or
 ``FALSE`` respectively, is returned in ``<resultVar>``.
 
-.. versionadded:: 3.14
-  The name of the ``<resultVar>`` is defined by the user.  Previously, it had
-  a fixed name ``RESULT_VAR``.
-
 In this form, one or more source files must be provided.  If
 :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is unset or is set to ``EXECUTABLE``,
 the sources must include a definition for ``main`` and CMake will create a
index 404de98..fc41cdd 100644 (file)
@@ -30,11 +30,6 @@ executable was built, but failed to run, then ``<runResultVar>`` will be
 set to ``FAILED_TO_RUN``.  See the :command:`try_compile` command for
 information on how the test project is constructed to build the source file.
 
-.. versionadded:: 3.14
-  The names of the result variables ``<runResultVar>`` and
-  ``<compileResultVar>`` are defined by the user.  Previously, they had
-  fixed names ``RUN_RESULT_VAR`` and ``COMPILE_RESULT_VAR``.
-
 The options are:
 
 ``CMAKE_FLAGS <flags>...``
index 5d508cb..d3cbd49 100644 (file)
@@ -1068,7 +1068,7 @@ which is just the string ``tgt``.
 
   .. code-block:: cmake
 
-    find_package(foo REQUIRED)
+    find_package(foo CONFIG REQUIRED) # package generated by install(EXPORT)
 
     add_executable(exe main.c)
     target_link_libraries(exe PRIVATE foo::foo foo::bar)
@@ -1077,6 +1077,15 @@ which is just the string ``tgt``.
       COMMAND_EXPAND_LISTS
       )
 
+  .. note::
+
+    :ref:`Imported Targets` are supported only if they know the location
+    of their ``.dll`` files.  An imported ``SHARED`` or ``MODULE`` library
+    must have :prop_tgt:`IMPORTED_LOCATION` set to its ``.dll`` file.  See
+    the :ref:`add_library imported libraries <add_library imported libraries>`
+    section for details.  Many :ref:`Find Modules` produce imported targets
+    with the ``UNKNOWN`` type and therefore will be ignored.
+
 .. genex:: $<INSTALL_PREFIX>
 
   Content of the install prefix when the target is exported via
index e1c6172..ae954b2 100644 (file)
@@ -334,3 +334,10 @@ Changes made since CMake 3.21.0 include the following.
 * The :generator:`Visual Studio 17 2022` generator is now based on the
   "Visual Studio 2022" release candidates.  Previously it was based on
   preview versions.
+
+3.21.5
+------
+
+This version made no changes to documented features or interfaces.
+Some implementation updates were made to support ecosystem changes
+and/or fix regressions.
index 30b4aec..e564517 100644 (file)
@@ -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)
index 8e9237a..f3c2345 100644 (file)
@@ -85,7 +85,7 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND
     list(PREPEND _CMAKE_MT_NAMES "llvm-mt")
     list(PREPEND _CMAKE_LINKER_NAMES "lld-link")
     list(APPEND _CMAKE_TOOL_VARS NM)
-  elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" MATCHES "^xIntel")
+  elseif("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xIntel")
     list(PREPEND _CMAKE_AR_NAMES "xilib")
     list(PREPEND _CMAKE_LINKER_NAMES "xilink")
   endif()
index 06ee528..d474f96 100644 (file)
@@ -5,6 +5,7 @@ set(CMAKE_Fortran_COMPILER_VERSION "@CMAKE_Fortran_COMPILER_VERSION@")
 set(CMAKE_Fortran_COMPILER_WRAPPER "@CMAKE_Fortran_COMPILER_WRAPPER@")
 set(CMAKE_Fortran_PLATFORM_ID "@CMAKE_Fortran_PLATFORM_ID@")
 set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@")
+set(CMAKE_Fortran_COMPILER_FRONTEND_VARIANT "@CMAKE_Fortran_COMPILER_FRONTEND_VARIANT@")
 set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@")
 @_SET_CMAKE_Fortran_XL_CPP@
 @_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID@
index c6a3451..ffd3352 100644 (file)
@@ -164,18 +164,21 @@ if(CMAKE_HAVE_PTHREAD_H)
     elseif(CMAKE_CXX_COMPILER_LOADED)
       CHECK_CXX_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD)
     endif()
-    if(CMAKE_HAVE_LIBC_PTHREAD)
+
+    # Check for -pthread first if enabled. This is the recommended
+    # way, but not backwards compatible as one must also pass -pthread
+    # as compiler flag then.
+    if(THREADS_PREFER_PTHREAD_FLAG)
+      _check_pthreads_flag()
+    endif()
+
+    if(Threads_FOUND)
+      # do nothing, we are done
+    elseif(CMAKE_HAVE_LIBC_PTHREAD)
       set(CMAKE_THREAD_LIBS_INIT "")
       set(CMAKE_HAVE_THREADS_LIBRARY 1)
       set(Threads_FOUND TRUE)
     else()
-      # Check for -pthread first if enabled. This is the recommended
-      # way, but not backwards compatible as one must also pass -pthread
-      # as compiler flag then.
-      if (THREADS_PREFER_PTHREAD_FLAG)
-         _check_pthreads_flag()
-      endif ()
-
       if(CMAKE_SYSTEM MATCHES "GHS-MULTI")
         _check_threads_lib(posix pthread_create CMAKE_HAVE_PTHREADS_CREATE)
       endif()
index d000380..a04882f 100644 (file)
@@ -148,7 +148,7 @@ macro(__windows_compiler_gnu_abi lang)
 
     # Query the VS Installer tool for locations of VS 2017 and above.
     set(_vs_installer_paths "")
-    foreach(vs RANGE 16 15 -1) # change the first number to the largest supported version
+    foreach(vs RANGE 17 15 -1) # change the first number to the largest supported version
       cmake_host_system_information(RESULT _vs_dir QUERY VS_${vs}_DIR)
       if(_vs_dir)
         list(APPEND _vs_installer_paths "${_vs_dir}/VC/Auxiliary/Build")
index 5c8f152..b48c33c 100644 (file)
@@ -676,7 +676,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
     ${swig_custom_products}
     ${swig_cleanup_command}
     # Let's create the ${outdir} at execution time, in case dir contains $(OutDir)
-    COMMAND "${CMAKE_COMMAND}" -E make_directory ${outdir} ${outfiledir}
+    COMMAND "${CMAKE_COMMAND}" -E make_directory "${workingdir}" "${outdir}" "${outfiledir}"
     ${swig_timestamp_command}
     COMMAND "${CMAKE_COMMAND}" -E env "SWIG_LIB=${SWIG_DIR}" "${SWIG_EXECUTABLE}"
     "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
index 3ca26b7..5dbcc82 100644 (file)
@@ -1,7 +1,7 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
 set(CMake_VERSION_MINOR 21)
-set(CMake_VERSION_PATCH 4)
+set(CMake_VERSION_PATCH 5)
 #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 [==[f65cebf51a CMake 3.21.4]==])
+  set(git_info [==[6fe5df13c2 CMake 3.21.5]==])
 
   # 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]* "
index bca26b9..a64dc27 100644 (file)
@@ -648,7 +648,7 @@ bool cmDependsFortran::ModulesDiffer(const std::string& modFile,
         return true;
       }
     }
-  } else if (compilerId == "Intel") {
+  } else if (compilerId == "Intel" || compilerId == "IntelLLVM") {
     const char seq[2] = { '\n', '\0' };
     const int seqlen = 2;
 
index a3e5553..9458277 100644 (file)
@@ -16,6 +16,8 @@
 #include <cmext/algorithm>
 #include <cmext/string_view>
 
+#include "cm_codecvt.hxx"
+
 #include "cmComputeLinkInformation.h"
 #include "cmCustomCommand.h"
 #include "cmCustomCommandGenerator.h"
@@ -2046,11 +2048,22 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
   const char* name, std::string const& options,
   std::vector<std::string>& makefile_depends)
 {
+  // FIXME: Find a better way to determine the response file encoding,
+  // perhaps using tool-specific platform information variables.
+  // For now, use the makefile encoding as a heuristic.
+  codecvt::Encoding responseEncoding =
+    this->GlobalGenerator->GetMakefileEncoding();
+  // Non-MSVC tooling may not understand a BOM.
+  if (responseEncoding == codecvt::UTF8_WITH_BOM &&
+      !this->Makefile->IsOn("MSVC")) {
+    responseEncoding = codecvt::UTF8;
+  }
+
   // Create the response file.
   std::string responseFileNameFull =
     cmStrCat(this->TargetBuildDirectoryFull, '/', name);
-  cmGeneratedFileStream responseStream(
-    responseFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
+  cmGeneratedFileStream responseStream(responseFileNameFull, false,
+                                       responseEncoding);
   responseStream.SetCopyIfDifferent(true);
   responseStream << options << "\n";
 
index 6fcbce5..82a374a 100644 (file)
@@ -97,7 +97,7 @@ bool cmScanDepFormat_P1689_Parse(std::string const& arg_pp,
   }
 
   Json::Value const& version = ppi["version"];
-  if (version.asUInt() != 0) {
+  if (version.asUInt() > 1) {
     cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ",
                                   arg_pp, ": version ", version.asString()));
     return false;
index 64d93df..95ad320 100644 (file)
@@ -161,11 +161,11 @@ void cmakemainMessageCallback(const std::string& m,
   // cannot use it to print messages.  Another implementation will
   // be needed to print colored messages on Windows.
   static_cast<void>(md);
-  std::cerr << m << cmakemainGetStack(cm) << "\n";
+  std::cerr << m << cmakemainGetStack(cm) << '\n' << std::flush;
 #else
   cmsysTerminal_cfprintf(md.desiredColor, stderr, "%s", m.c_str());
   fflush(stderr); // stderr is buffered in some cases.
-  std::cerr << cmakemainGetStack(cm) << "\n";
+  std::cerr << cmakemainGetStack(cm) << '\n' << std::flush;
 #endif
 }
 
index 71d58f8..4422f55 100644 (file)
     "flags": []
   },
   {
-    "name": "LinkControlFlowGuard",
-    "switch": "guard:cf",
-    "comment": "Control Flow Guard",
-    "value": "true",
-    "flags": []
-  },
-  {
     "name": "LinkGuardEHContMetadata",
     "switch": "guard:ehcont",
     "comment": "Enable EH Continuation Metadata",
index d5ed136..e11a24a 100644 (file)
@@ -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 (file)
index 0000000..c13858b
--- /dev/null
@@ -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 "^ *<LinkControlFlowGuard>([^<>]+)</LinkControlFlowGuard>")
+      set(RunCMake_TEST_FAILED "Project file ControlFlowGuardProject.vcxproj contains the invalid <LinkControlFlowGuard> link property.")
+      return()
+    break()
+  endif()
+  if(line MATCHES "^ *<Link>")
+    # The start of the link section of the vcxproj file
+    set(Is_in_link_section 1)
+    continue()
+  endif()
+  if(line MATCHES "^ *</Link>")
+    # 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 "^ *<AdditionalOptions>([^<>]+)</AdditionalOptions>")
+      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 <AdditionalOptions> property.")
+  return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting.cmake b/Tests/RunCMake/VS10Project/VsControlFlowGuardLinkSetting.cmake
new file mode 100644 (file)
index 0000000..31e69ac
--- /dev/null
@@ -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)
index f1b2f32..6c0d5e4 100644 (file)
@@ -76,6 +76,7 @@ if(SWIG_FOUND AND NOT SWIG_VERSION VERSION_LESS "4.0.2"
     ${build_generator_args}
     --build-project TestBasicPython
     --build-options ${build_options} -DSWIG_USE_SWIG_DEPENDENCIES=ON
+                                     "-DSWIG_OUTFILE_DIR=${CMake_BINARY_DIR}/Tests/UseSWIG/BasicPython.Depfile"
     --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
     )
   add_test(NAME UseSWIG.Depfile.BasicPerl COMMAND