Merge topic 'cuda_11' into release-3.19
046e454fdd CUDA: Error if can't determine toolkit library root
440dc98b07 CUDA: Clang CUDA 11.1 support
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5525
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)