summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-09-25 19:12:14 (GMT)
committerBrad King <brad.king@kitware.com>2023-09-25 20:06:36 (GMT)
commite43918b4caf8de881cb24a0a7494e086202cff34 (patch)
tree5712d13ab722a6914ed2e5433eaa7739034f6cca
parent479450512253e904c077c5e77fc04bc916466930 (diff)
downloadCMake-e43918b4caf8de881cb24a0a7494e086202cff34.zip
CMake-e43918b4caf8de881cb24a0a7494e086202cff34.tar.gz
CMake-e43918b4caf8de881cb24a0a7494e086202cff34.tar.bz2
HIP: Fix linking mixed-lang binary with CXX compiler and Makefile generators
Following commit 6377a43814 (CUDA: Support response files with nvcc, 2022-06-01, v3.25.0-rc1~636^2), while determining the compiler ABI, do not use response files, so that we can extract implicit link flags. Fixes: #25272
-rw-r--r--Source/cmCoreTryCompile.cxx14
-rw-r--r--Tests/HIP/MixedLanguage/CMakeLists.txt4
2 files changed, 14 insertions, 4 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 0674d5a..ee40bd5 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -732,10 +732,16 @@ cm::optional<cmTryCompileResult> cmCoreTryCompile::TryCompileCode(
// The link and compile lines for ABI detection step need to not use
// response files so we can extract implicit includes given to
// the underlying host compiler
- if (testLangs.find("CUDA") != testLangs.end()) {
- fprintf(fout, "set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES OFF)\n");
- fprintf(fout, "set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)\n");
- fprintf(fout, "set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS OFF)\n");
+ static std::array<std::string, 2> const noRSP{ { "CUDA", "HIP" } };
+ for (std::string const& lang : noRSP) {
+ if (testLangs.find(lang) != testLangs.end()) {
+ fprintf(fout, "set(CMAKE_%s_USE_RESPONSE_FILE_FOR_INCLUDES OFF)\n",
+ lang.c_str());
+ fprintf(fout, "set(CMAKE_%s_USE_RESPONSE_FILE_FOR_LIBRARIES OFF)\n",
+ lang.c_str());
+ fprintf(fout, "set(CMAKE_%s_USE_RESPONSE_FILE_FOR_OBJECTS OFF)\n",
+ lang.c_str());
+ }
}
}
fprintf(fout, "set(CMAKE_VERBOSE_MAKEFILE 1)\n");
diff --git a/Tests/HIP/MixedLanguage/CMakeLists.txt b/Tests/HIP/MixedLanguage/CMakeLists.txt
index 4f6dd3b..af58ade 100644
--- a/Tests/HIP/MixedLanguage/CMakeLists.txt
+++ b/Tests/HIP/MixedLanguage/CMakeLists.txt
@@ -17,3 +17,7 @@ set_target_properties(MixedStaticLib PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_executable(HIPMixedLanguage main.cxx)
target_link_libraries(HIPMixedLanguage PRIVATE MixedStaticLib MixedSharedLib)
+
+add_executable(HIPMixedLanguageCXX main.cxx)
+target_link_libraries(HIPMixedLanguageCXX PRIVATE MixedStaticLib MixedSharedLib)
+set_property(TARGET HIPMixedLanguageCXX PROPERTY LINKER_LANGUAGE CXX)