Merge topic 'cmFileTime-fix-overflow' into release-3.19

b4c994f69c cmFileTime: Fix overflow on time computation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5526
diff --git a/Help/release/3.19.rst b/Help/release/3.19.rst
index 961d6c0..a29dc07 100644
--- a/Help/release/3.19.rst
+++ b/Help/release/3.19.rst
@@ -346,3 +346,5 @@
   it can break projects that were using the property only to
   cause the specified language's compiler to be used.  This has
   been reverted to restore behavior from CMake 3.18 and below.
+
+* CUDA 11.1 support for Clang.
diff --git a/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst b/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst
index 84ba12d..d5893c9 100644
--- a/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst
+++ b/Help/variable/CTEST_CUSTOM_COVERAGE_EXCLUDE.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_COVERAGE_EXCLUDE
 -----------------------------
 
-.. versionadded:: 3.4
-
 A list of regular expressions which will be used to exclude files by their
 path from coverage output by the :command:`ctest_coverage` command.
 
diff --git a/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst b/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst
index 7191ce4..cd65ae3 100644
--- a/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst
+++ b/Help/variable/CTEST_CUSTOM_ERROR_EXCEPTION.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_ERROR_EXCEPTION
 ----------------------------
 
-.. versionadded:: 3.4
-
 A list of regular expressions which will be used to exclude when detecting
 error messages in build outputs by the :command:`ctest_test` command.
 
diff --git a/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst b/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst
index 5d213f2..558f5e5 100644
--- a/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst
+++ b/Help/variable/CTEST_CUSTOM_ERROR_MATCH.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_ERROR_MATCH
 ------------------------
 
-.. versionadded:: 3.4
-
 A list of regular expressions which will be used to detect error messages in
 build outputs by the :command:`ctest_test` command.
 
diff --git a/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst b/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst
index 452d060..614859b 100644
--- a/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst
+++ b/Help/variable/CTEST_CUSTOM_ERROR_POST_CONTEXT.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_ERROR_POST_CONTEXT
 -------------------------------
 
-.. versionadded:: 3.4
-
 The number of lines to include as context which follow an error message by the
 :command:`ctest_test` command. The default is 10.
 
diff --git a/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst b/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst
index b7717dd..74dc47a 100644
--- a/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst
+++ b/Help/variable/CTEST_CUSTOM_ERROR_PRE_CONTEXT.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_ERROR_PRE_CONTEXT
 ------------------------------
 
-.. versionadded:: 3.4
-
 The number of lines to include as context which precede an error message by
 the :command:`ctest_test` command. The default is 10.
 
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
index 31ba099..5aeae88 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE
 --------------------------------------------
 
-.. versionadded:: 3.4
-
 When saving a failing test's output, this is the maximum size, in bytes, that
 will be collected by the :command:`ctest_test` command. Defaults to 307200
 (300 KiB).
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst
index e5be1ad..920cb04 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS
 -------------------------------------
 
-.. versionadded:: 3.4
-
 The maximum number of errors in a single build step which will be detected.
 After this, the :command:`ctest_test` command will truncate the output.
 Defaults to 50.
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst
index b513a5c..a1f1cc1 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS
 ---------------------------------------
 
-.. versionadded:: 3.4
-
 The maximum number of warnings in a single build step which will be detected.
 After this, the :command:`ctest_test` command will truncate the output.
 Defaults to 50.
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
index 08762d8..1fbb8c5 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
 --------------------------------------------
 
-.. versionadded:: 3.4
-
 When saving a passing test's output, this is the maximum size, in bytes, that
 will be collected by the :command:`ctest_test` command. Defaults to 1024
 (1 KiB).
diff --git a/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst b/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst
index 405fc33..578576c 100644
--- a/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst
+++ b/Help/variable/CTEST_CUSTOM_MEMCHECK_IGNORE.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_MEMCHECK_IGNORE
 ----------------------------
 
-.. versionadded:: 3.4
-
 A list of regular expressions to use to exclude tests during the
 :command:`ctest_memcheck` command.
 
diff --git a/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst b/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst
index 5e488a7..40291fe 100644
--- a/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst
+++ b/Help/variable/CTEST_CUSTOM_POST_MEMCHECK.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_POST_MEMCHECK
 --------------------------
 
-.. versionadded:: 3.4
-
 A list of commands to run at the end of the :command:`ctest_memcheck` command.
 
 .. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_CUSTOM_POST_TEST.rst b/Help/variable/CTEST_CUSTOM_POST_TEST.rst
index 7ec42f7..791292c 100644
--- a/Help/variable/CTEST_CUSTOM_POST_TEST.rst
+++ b/Help/variable/CTEST_CUSTOM_POST_TEST.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_POST_TEST
 ----------------------
 
-.. versionadded:: 3.4
-
 A list of commands to run at the end of the :command:`ctest_test` command.
 
 .. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst b/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst
index 99e47bd..00de8aa 100644
--- a/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst
+++ b/Help/variable/CTEST_CUSTOM_PRE_MEMCHECK.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_PRE_MEMCHECK
 -------------------------
 
-.. versionadded:: 3.4
-
 A list of commands to run at the start of the :command:`ctest_memcheck`
 command.
 
diff --git a/Help/variable/CTEST_CUSTOM_PRE_TEST.rst b/Help/variable/CTEST_CUSTOM_PRE_TEST.rst
index 95c6314..6af7152 100644
--- a/Help/variable/CTEST_CUSTOM_PRE_TEST.rst
+++ b/Help/variable/CTEST_CUSTOM_PRE_TEST.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_PRE_TEST
 ----------------------
 
-.. versionadded:: 3.4
-
 A list of commands to run at the start of the :command:`ctest_test` command.
 
 .. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst b/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst
index 27a75d9..57222ca 100644
--- a/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst
+++ b/Help/variable/CTEST_CUSTOM_TESTS_IGNORE.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_TESTS_IGNORE
 -------------------------
 
-.. versionadded:: 3.14
-
 A list of regular expressions to use to exclude tests during the
 :command:`ctest_test` command.
 
diff --git a/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst b/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst
index 539760b..a03d473 100644
--- a/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst
+++ b/Help/variable/CTEST_CUSTOM_WARNING_EXCEPTION.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_WARNING_EXCEPTION
 ------------------------------
 
-.. versionadded:: 3.4
-
 A list of regular expressions which will be used to exclude when detecting
 warning messages in build outputs by the :command:`ctest_build` command.
 
diff --git a/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst b/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst
index 53e7707..18aa6b3 100644
--- a/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst
+++ b/Help/variable/CTEST_CUSTOM_WARNING_MATCH.rst
@@ -1,8 +1,6 @@
 CTEST_CUSTOM_WARNING_MATCH
 --------------------------
 
-.. versionadded:: 3.4
-
 A list of regular expressions which will be used to detect warning messages in
 build outputs by the :command:`ctest_build` command.
 
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 9220551..972adef 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -176,13 +176,15 @@
     # In a non-scattered installation the following are equivalent to CMAKE_CUDA_COMPILER_TOOLKIT_ROOT.
     # We first check for a non-scattered installation to prefer it over a scattered installation.
 
-    # CMAKE_CUDA_COMPILER_LIBRARY_ROOT contains the device library and version file.
-    if(EXISTS "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/version.txt")
+    # CMAKE_CUDA_COMPILER_LIBRARY_ROOT contains the device library.
+    if(EXISTS "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}/nvvm/libdevice")
       set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}")
-    elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt")
+    elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/nvvm/libdevice")
       set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_SYSROOT_LINK}/usr/lib/cuda")
-    elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt")
+    elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/nvvm/libdevice")
       set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "${CMAKE_SYSROOT}/usr/lib/cuda")
+    else()
+      message(FATAL_ERROR "Couldn't find CUDA library root.")
     endif()
 
     # CMAKE_CUDA_COMPILER_TOOLKIT_LIBRARY_ROOT contains the linking stubs necessary for device linking and other low-level library files.
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index 10e31b2..53cab1a 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -96,27 +96,6 @@
     mark_as_advanced(${_name})
 endfunction()
 
-function(__gtest_find_library_configuration _name _lib _cfg_suffix)
-    set(_libs ${_lib})
-    if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD")
-        # The provided /MD project files for Google Test add -md suffixes to the
-        # library names.
-        list(INSERT _libs 0 ${_lib}-md)
-    endif()
-    list(TRANSFORM _libs APPEND "${_cfg_suffix}")
-
-    __gtest_find_library(${_name} ${_libs})
-endfunction()
-
-include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
-function(__gtest_find_and_select_library_configurations _basename _lib)
-    __gtest_find_library_configuration(${_basename}_LIBRARY_RELEASE ${_lib} "")
-    __gtest_find_library_configuration(${_basename}_LIBRARY_DEBUG   ${_lib} "d")
-
-    select_library_configurations(${_basename})
-    set(${_basename}_LIBRARY ${${_basename}_LIBRARY} PARENT_SCOPE)
-endfunction()
-
 macro(__gtest_determine_windows_library_type _var)
     if(EXISTS "${${_var}}")
         file(TO_NATIVE_PATH "${${_var}}" _lib_path)
@@ -208,13 +187,18 @@
 )
 mark_as_advanced(GTEST_INCLUDE_DIR)
 
-# Allow GTEST_LIBRARY and GTEST_MAIN_LIBRARY to be set manually, as the
-# locations of the gtest and gtest_main libraries, respectively.
-if(NOT GTEST_LIBRARY)
-    __gtest_find_and_select_library_configurations(GTEST gtest)
-endif()
-if(NOT GTEST_MAIN_LIBRARY)
-    __gtest_find_and_select_library_configurations(GTEST_MAIN gtest_main)
+if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD")
+    # The provided /MD project files for Google Test add -md suffixes to the
+    # library names.
+    __gtest_find_library(GTEST_LIBRARY            gtest-md  gtest)
+    __gtest_find_library(GTEST_LIBRARY_DEBUG      gtest-mdd gtestd)
+    __gtest_find_library(GTEST_MAIN_LIBRARY       gtest_main-md  gtest_main)
+    __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_main-mdd gtest_maind)
+else()
+    __gtest_find_library(GTEST_LIBRARY            gtest)
+    __gtest_find_library(GTEST_LIBRARY_DEBUG      gtestd)
+    __gtest_find_library(GTEST_MAIN_LIBRARY       gtest_main)
+    __gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
 endif()
 
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 3c4f68c..3776fec 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -831,13 +831,17 @@
       compileCommand.replace(compileCommand.find(langFlags), langFlags.size(),
                              this->GetFlags(lang, this->GetConfigName()));
       std::string langDefines = std::string("$(") + lang + "_DEFINES)";
-      compileCommand.replace(compileCommand.find(langDefines),
-                             langDefines.size(),
-                             this->GetDefines(lang, this->GetConfigName()));
+      std::string::size_type ldPos = compileCommand.find(langDefines);
+      if (ldPos != std::string::npos) {
+        compileCommand.replace(ldPos, langDefines.size(),
+                               this->GetDefines(lang, this->GetConfigName()));
+      }
       std::string langIncludes = std::string("$(") + lang + "_INCLUDES)";
-      compileCommand.replace(compileCommand.find(langIncludes),
-                             langIncludes.size(),
-                             this->GetIncludes(lang, this->GetConfigName()));
+      std::string::size_type liPos = compileCommand.find(langIncludes);
+      if (liPos != std::string::npos) {
+        compileCommand.replace(liPos, langIncludes.size(),
+                               this->GetIncludes(lang, this->GetConfigName()));
+      }
 
       cmProp eliminate[] = {
         this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"),
diff --git a/Tests/RunCMake/ExportCompileCommands/CustomCompileRule.cmake b/Tests/RunCMake/ExportCompileCommands/CustomCompileRule.cmake
new file mode 100644
index 0000000..12368a2
--- /dev/null
+++ b/Tests/RunCMake/ExportCompileCommands/CustomCompileRule.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+add_library(empty STATIC empty.c)
+string(REPLACE "<DEFINES>" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
+string(REPLACE "<INCLUDES>" "" CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
diff --git a/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake b/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake
index b540a04..9e7e732 100644
--- a/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExportCompileCommands/RunCMakeTest.cmake
@@ -1,3 +1,4 @@
 include(RunCMake)
 
 run_cmake_with_options(BeforeProject -DCMAKE_PROJECT_INCLUDE_BEFORE=BeforeProjectBEFORE.cmake)
+run_cmake(CustomCompileRule)