Imported Upstream version 3.23.5 upstream/3.23.5
authorJinWang An <jinwang.an@samsung.com>
Tue, 27 Dec 2022 08:20:18 +0000 (17:20 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 27 Dec 2022 08:20:18 +0000 (17:20 +0900)
19 files changed:
Help/command/string.rst
Help/release/3.23.rst
Modules/Internal/CPack/NSIS.template.in
Source/CMakeVersion.cmake
Source/Checks/cm_cxx_features.cmake
Source/Checks/cm_cxx_filesystem.cxx
Source/cmCoreTryCompile.cxx
Source/cmGlobalNinjaGenerator.cxx
Source/cmGlobalNinjaGenerator.h
Tests/RunCMake/Ninja/Intl-build-check.cmake [new file with mode: 0644]
Tests/RunCMake/Ninja/Intl-common.cmake [new file with mode: 0644]
Tests/RunCMake/Ninja/Intl.cmake [new file with mode: 0644]
Tests/RunCMake/Ninja/RunCMakeTest.cmake
Tests/RunCMake/try_compile/CMP0128-NEW.cmake [new file with mode: 0644]
Tests/RunCMake/try_compile/CMP0128-WARN.cmake [new file with mode: 0644]
Tests/RunCMake/try_compile/CMP0128-common.cmake [new file with mode: 0644]
Tests/RunCMake/try_compile/Inspect.cmake [new file with mode: 0644]
Tests/RunCMake/try_compile/RunCMakeTest.cmake
Utilities/std/cm/filesystem

index b1ca2cb..86cbd2e 100644 (file)
@@ -491,6 +491,8 @@ specifiers:
   The second of the current minute.  60 represents a leap second. (00-60)
 
 ``%f``
+  .. versionadded:: 3.23
+
   The microsecond of the current second (000000-999999).
 
 ``%U``
index 594bb0b..9dcb002 100644 (file)
@@ -310,8 +310,8 @@ Changes made since CMake 3.23.0 include the following.
   The old ``CPACK_PACKAGEMAKER_CHOICES`` variable is now also set to the
   same content as it was before, but it is formally deprecated.
 
-3.23.3, 3.23.4
---------------
+3.23.3, 3.23.4, 3.23.5
+----------------------
 
 * These versions made no changes to documented features or interfaces.
   Some implementation updates were made to support ecosystem changes
index 23c45c7..701366e 100644 (file)
@@ -931,11 +931,20 @@ Function .onInit
 ;Run the uninstaller
 uninst:
   ClearErrors
-  StrCpy $2 $0 1
-  StrCmp '"' $2 0 +3 ; checks if string is quoted (CPack before v3.20.6 did not quote it)
-  ExecWait '$0 /S'
-  Goto +2
-  ExecWait '"$0" /S'
+  # $0 should _always_ be quoted, however older versions of CMake did not
+  # do this.  We'll conditionally remove the begin/end quotes.
+  # Remove first char if quote
+  StrCpy $2 $0 1 0      # copy first char
+  StrCmp $2 "$\"" 0 +2  # if char is quote
+  StrCpy $0 $0 "" 1     # remove first char
+  # Remove last char if quote
+  StrCpy $2 $0 1 -1     # copy last char
+  StrCmp $2 "$\"" 0 +2  # if char is quote
+  StrCpy $0 $0 -1       # remove last char
+
+  StrLen $2 "\@CPACK_NSIS_UNINSTALL_NAME@.exe"
+  StrCpy $3 $0 -$2 # remove "\@CPACK_NSIS_UNINSTALL_NAME@.exe" from UninstallString to get path
+  ExecWait '"$0" /S _?=$3' ;Do not copy the uninstaller to a temp file
 
   IfErrors uninst_failed inst
 uninst_failed:
index bdc1b7d..518f6fb 100644 (file)
@@ -1,7 +1,7 @@
 # CMake version number components.
 set(CMake_VERSION_MAJOR 3)
 set(CMake_VERSION_MINOR 23)
-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 [==[34a6da34b8 CMake 3.23.4]==])
+  set(git_info [==[91ccfa3302 CMake 3.23.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 f20572e..7917d41 100644 (file)
@@ -80,9 +80,7 @@ if(CMake_HAVE_CXX_MAKE_UNIQUE)
   set(CMake_HAVE_CXX_UNIQUE_PTR 1)
 endif()
 cm_check_cxx_feature(unique_ptr)
-if (NOT CMAKE_CXX_STANDARD LESS "17"
-    AND NOT MSYS # FIXME: RunCMake.cmake_path cases crash with MSYS std::filesystem
-    )
+if (NOT CMAKE_CXX_STANDARD LESS "17")
   if (NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
     cm_check_cxx_feature(filesystem TRY_RUN)
   else()
index ae8acc5..732f28f 100644 (file)
@@ -23,5 +23,16 @@ int main()
   }
 #endif
 
+  // If std::string is copy-on-write, the std::filesystem::path
+  // implementation may accidentally trigger a reallocation and compute
+  // an offset between two allocations, leading to undefined behavior.
+#if defined(__GLIBCXX__) &&                                                   \
+  (!defined(_GLIBCXX_USE_CXX11_ABI) || !_GLIBCXX_USE_CXX11_ABI)
+  std::string p5s1 = "/path";
+  std::string p5s2 = std::move(p5s1);
+  std::filesystem::path p5 = std::string(p5s2);
+  p5.remove_filename();
+#endif
+
   return 0;
 }
index 324ce87..8d7c5fa 100644 (file)
@@ -577,6 +577,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
       fprintf(fout, "cmake_policy(SET CMP0126 OLD)\n");
     }
 
+    /* Set language extensions policy to match outer project.  */
+    if (this->Makefile->GetPolicyStatus(cmPolicies::CMP0128) !=
+        cmPolicies::NEW) {
+      fprintf(fout, "cmake_policy(SET CMP0128 OLD)\n");
+    }
+
     std::string projectLangs;
     for (std::string const& li : testLangs) {
       projectLangs += " " + li;
index 4245037..982b6af 100644 (file)
@@ -1025,19 +1025,6 @@ bool cmGlobalNinjaGenerator::OpenBuildFileStreams()
     return false;
   }
 
-  // New buffer size 8 MiB
-  constexpr auto buildFileStreamBufferSize = 8 * 1024 * 1024;
-
-  // Ensure the buffer is allocated
-  if (!this->BuildFileStreamBuffer) {
-    this->BuildFileStreamBuffer =
-      cm::make_unique<char[]>(buildFileStreamBufferSize);
-  }
-
-  // Enlarge the internal buffer of the `BuildFileStream`
-  this->BuildFileStream->rdbuf()->pubsetbuf(this->BuildFileStreamBuffer.get(),
-                                            buildFileStreamBufferSize);
-
   // Write a comment about this file.
   *this->BuildFileStream
     << "# This file contains all the build statements describing the\n"
index aa2df4d..03387a8 100644 (file)
@@ -529,7 +529,6 @@ private:
   /// The file containing the build statement. (the relationship of the
   /// compilation DAG).
   std::unique_ptr<cmGeneratedFileStream> BuildFileStream;
-  std::unique_ptr<char[]> BuildFileStreamBuffer;
   /// The file containing the rule statements. (The action attached to each
   /// edge of the compilation DAG).
   std::unique_ptr<cmGeneratedFileStream> RulesFileStream;
diff --git a/Tests/RunCMake/Ninja/Intl-build-check.cmake b/Tests/RunCMake/Ninja/Intl-build-check.cmake
new file mode 100644 (file)
index 0000000..77f013c
--- /dev/null
@@ -0,0 +1,5 @@
+include(${RunCMake_SOURCE_DIR}/Intl-common.cmake)
+set(output "${RunCMake_TEST_BINARY_DIR}/${intl}-output.txt")
+if(NOT EXISTS "${output}")
+  set(RunCMake_TEST_FAILED "Expected output does not exist:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/Ninja/Intl-common.cmake b/Tests/RunCMake/Ninja/Intl-common.cmake
new file mode 100644 (file)
index 0000000..7703976
--- /dev/null
@@ -0,0 +1 @@
+set(intl "intl-ë®")
diff --git a/Tests/RunCMake/Ninja/Intl.cmake b/Tests/RunCMake/Ninja/Intl.cmake
new file mode 100644 (file)
index 0000000..50e4ee4
--- /dev/null
@@ -0,0 +1,7 @@
+include(Intl-common.cmake)
+set(input "${CMAKE_CURRENT_BINARY_DIR}/${intl}-input.txt")
+set(output "${CMAKE_CURRENT_BINARY_DIR}/${intl}-output.txt")
+file(WRITE "${input}" "${intl}\n")
+add_custom_command(OUTPUT "${output}"
+  COMMAND ${CMAKE_COMMAND} -E copy "${input}" "${output}")
+add_custom_target(drive ALL DEPENDS "${output}")
index 2a5b556..0825666 100644 (file)
@@ -33,6 +33,15 @@ function(run_NinjaToolMissing)
 endfunction()
 run_NinjaToolMissing()
 
+function(run_Intl)
+  run_cmake(Intl)
+  set(RunCMake_TEST_NO_CLEAN 1)
+  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Intl-build)
+  set(RunCMake_TEST_OUTPUT_MERGE 1)
+  run_cmake_command(Intl-build ${CMAKE_COMMAND} --build .)
+endfunction()
+run_Intl()
+
 function(run_NoWorkToDo)
   run_cmake(NoWorkToDo)
   set(RunCMake_TEST_NO_CLEAN 1)
diff --git a/Tests/RunCMake/try_compile/CMP0128-NEW.cmake b/Tests/RunCMake/try_compile/CMP0128-NEW.cmake
new file mode 100644 (file)
index 0000000..20e389a
--- /dev/null
@@ -0,0 +1,7 @@
+cmake_policy(SET CMP0128 NEW)
+set(check_cxx_std "
+#if __cplusplus > 199711L && __cplusplus <= 201103L
+#  error Compiler is incorrectly in C++11 mode.
+#endif
+")
+include(CMP0128-common.cmake)
diff --git a/Tests/RunCMake/try_compile/CMP0128-WARN.cmake b/Tests/RunCMake/try_compile/CMP0128-WARN.cmake
new file mode 100644 (file)
index 0000000..266bd22
--- /dev/null
@@ -0,0 +1,7 @@
+
+set(check_cxx_std "
+#if __cplusplus <= 199711L || __cplusplus > 201103L
+#  error Compiler is incorrectly not in C++11 mode.
+#endif
+")
+include(CMP0128-common.cmake)
diff --git a/Tests/RunCMake/try_compile/CMP0128-common.cmake b/Tests/RunCMake/try_compile/CMP0128-common.cmake
new file mode 100644 (file)
index 0000000..0b8a12b
--- /dev/null
@@ -0,0 +1,31 @@
+cmake_policy(SET CMP0067 NEW)
+enable_language(CXX)
+
+# Isolate the one try_compile below in the error log.
+set(CMakeError_log "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log")
+file(REMOVE "${CMakeError_log}")
+
+# Add our own -std= flag to the try_compile check.
+set(CMAKE_REQUIRED_FLAGS -std=c++11)
+
+# Tell CMP0128 NEW behavior to append a -std= flag (after ours).
+if(CMAKE_CXX_EXTENSIONS_DEFAULT)
+  set(CMAKE_CXX_EXTENSIONS OFF)
+else()
+  set(CMAKE_CXX_EXTENSIONS ON)
+endif()
+
+include(CheckSourceCompiles)
+check_source_compiles(CXX "
+${check_cxx_std}
+int main()
+{
+  return 0;
+}
+" SRC_COMPILED)
+if(NOT SRC_COMPILED)
+  if(EXISTS "${CMakeError_log}")
+    file(READ "${CMakeError_log}" err_log)
+  endif()
+  message("${err_log}")
+endif()
diff --git a/Tests/RunCMake/try_compile/Inspect.cmake b/Tests/RunCMake/try_compile/Inspect.cmake
new file mode 100644 (file)
index 0000000..added41
--- /dev/null
@@ -0,0 +1,4 @@
+enable_language(CXX)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "
+set(CMAKE_CXX_EXTENSIONS_DEFAULT \"${CMAKE_CXX_EXTENSIONS_DEFAULT}\")
+")
index dcd3799..33d6543 100644 (file)
@@ -114,6 +114,24 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja")
   unset(RunCMake_TEST_NO_CLEAN)
 endif()
 
+# Lookup CMAKE_CXX_EXTENSIONS_DEFAULT.
+# FIXME: Someday we could move this to the top of the file and use it in
+# place of some of the values passed by 'Tests/RunCMake/CMakeLists.txt'.
+run_cmake(Inspect)
+include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake")
+
+# FIXME: Support more compilers and default standard levels.
+if (DEFINED CMAKE_CXX_STANDARD_DEFAULT AND
+    DEFINED CMAKE_CXX_EXTENSIONS_DEFAULT AND (
+    (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.7) OR
+    (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+    ))
+  run_cmake(CMP0128-WARN)
+  if(NOT CMAKE_CXX_STANDARD_DEFAULT EQUAL 11)
+    run_cmake(CMP0128-NEW)
+  endif()
+endif()
+
 if(UNIX)
   run_cmake(CleanupNoFollowSymlink)
 endif()
index ce52fbf..b1cb366 100644 (file)
@@ -809,13 +809,11 @@ public:
 
   path& remove_filename()
   {
-#  if defined(__CYGWIN__)
-    // FIXME: Avoid crash due to CYGWIN/MSYS bug(?).  See CMake Issue 22090.
-    static_cast<void>(this->path_.data());
-#  endif
     auto fname = this->get_filename();
     if (!fname.empty()) {
-      this->path_.erase(fname.data() - this->path_.data());
+      this->path_.erase(fname.data() -
+                        // Avoid C++17 non-const .data() that may reallocate.
+                        static_cast<path_type const&>(this->path_).data());
     }
     return *this;
   }
@@ -829,13 +827,11 @@ public:
 
   path& replace_extension(const path& replacement = path())
   {
-#  if defined(__CYGWIN__)
-    // FIXME: Avoid crash due to CYGWIN/MSYS bug(?).  See CMake Issue 22090.
-    static_cast<void>(this->path_.data());
-#  endif
     auto ext = this->get_filename_fragment(filename_fragment::extension);
     if (!ext.empty()) {
-      this->path_.erase(ext.data() - this->path_.data());
+      this->path_.erase(ext.data() -
+                        // Avoid C++17 non-const .data() that may reallocate.
+                        static_cast<path_type const&>(this->path_).data());
     }
     if (!replacement.path_.empty()) {
       if (replacement.path_[0] != '.') {