summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCoreTryCompile.cxx')
-rw-r--r--Source/cmCoreTryCompile.cxx44
1 files changed, 38 insertions, 6 deletions
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 6672aa6..8ecf264 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -8,6 +8,7 @@
#include <sstream>
#include <utility>
+#include <cm/string_view>
#include <cmext/string_view>
#include "cmsys/Directory.hxx"
@@ -188,6 +189,8 @@ SETUP_LANGUAGE(cuda_properties, CUDA);
// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
SETUP_LANGUAGE(fortran_properties, Fortran);
// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
+SETUP_LANGUAGE(hip_properties, HIP);
+// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
SETUP_LANGUAGE(objc_properties, OBJC);
// NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
SETUP_LANGUAGE(objcxx_properties, OBJCXX);
@@ -200,6 +203,8 @@ SETUP_LANGUAGE(swift_properties, Swift);
std::string const kCMAKE_CUDA_ARCHITECTURES = "CMAKE_CUDA_ARCHITECTURES";
std::string const kCMAKE_CUDA_RUNTIME_LIBRARY = "CMAKE_CUDA_RUNTIME_LIBRARY";
std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS";
+std::string const kCMAKE_HIP_ARCHITECTURES = "CMAKE_HIP_ARCHITECTURES";
+std::string const kCMAKE_HIP_RUNTIME_LIBRARY = "CMAKE_HIP_RUNTIME_LIBRARY";
std::string const kCMAKE_ISPC_INSTRUCTION_SETS = "CMAKE_ISPC_INSTRUCTION_SETS";
std::string const kCMAKE_ISPC_HEADER_SUFFIX = "CMAKE_ISPC_HEADER_SUFFIX";
std::string const kCMAKE_LINK_SEARCH_END_STATIC =
@@ -217,6 +222,7 @@ std::string const kCMAKE_POSITION_INDEPENDENT_CODE =
std::string const kCMAKE_SYSROOT = "CMAKE_SYSROOT";
std::string const kCMAKE_SYSROOT_COMPILE = "CMAKE_SYSROOT_COMPILE";
std::string const kCMAKE_SYSROOT_LINK = "CMAKE_SYSROOT_LINK";
+std::string const kCMAKE_ARMClang_CMP0123 = "CMAKE_ARMClang_CMP0123";
std::string const kCMAKE_TRY_COMPILE_OSX_ARCHITECTURES =
"CMAKE_TRY_COMPILE_OSX_ARCHITECTURES";
std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES =
@@ -272,6 +278,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
LanguageStandardState cState("C");
LanguageStandardState cudaState("CUDA");
LanguageStandardState cxxState("CXX");
+ LanguageStandardState hipState("HIP");
LanguageStandardState objcState("OBJC");
LanguageStandardState objcxxState("OBJCXX");
std::vector<std::string> targets;
@@ -321,6 +328,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} else if (cState.UpdateIfMatches(argv, i) ||
cxxState.UpdateIfMatches(argv, i) ||
cudaState.UpdateIfMatches(argv, i) ||
+ hipState.UpdateIfMatches(argv, i) ||
objcState.UpdateIfMatches(argv, i) ||
objcxxState.UpdateIfMatches(argv, i)) {
continue;
@@ -426,6 +434,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
if (!cudaState.Validate(this->Makefile)) {
return -1;
}
+ if (!hipState.Validate(this->Makefile)) {
+ return -1;
+ }
if (!cxxState.Validate(this->Makefile)) {
return -1;
}
@@ -552,6 +563,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
fprintf(fout, "cmake_policy(SET CMP0104 OLD)\n");
}
+ /* Set ARMClang cpu/arch policy to match outer project. */
+ if (cmProp cmp0123 =
+ this->Makefile->GetDefinition(kCMAKE_ARMClang_CMP0123)) {
+ fprintf(fout, "cmake_policy(SET CMP0123 %s)\n",
+ *cmp0123 == "NEW"_s ? "NEW" : "OLD");
+ }
+
std::string projectLangs;
for (std::string const& li : testLangs) {
projectLangs += " " + li;
@@ -706,6 +724,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
vars.insert(
&fortran_properties[lang_property_start],
&fortran_properties[lang_property_start + lang_property_size]);
+ vars.insert(&hip_properties[lang_property_start],
+ &hip_properties[lang_property_start + lang_property_size]);
vars.insert(&objc_properties[lang_property_start],
&objc_properties[lang_property_start + lang_property_size]);
vars.insert(
@@ -718,6 +738,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
vars.insert(kCMAKE_CUDA_ARCHITECTURES);
vars.insert(kCMAKE_CUDA_RUNTIME_LIBRARY);
vars.insert(kCMAKE_ENABLE_EXPORTS);
+ vars.insert(kCMAKE_HIP_ARCHITECTURES);
+ vars.insert(kCMAKE_HIP_RUNTIME_LIBRARY);
vars.insert(kCMAKE_ISPC_INSTRUCTION_SETS);
vars.insert(kCMAKE_ISPC_HEADER_SUFFIX);
vars.insert(kCMAKE_LINK_SEARCH_END_STATIC);
@@ -752,6 +774,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
vars.insert(
&fortran_properties[pie_property_start],
&fortran_properties[pie_property_start + pie_property_size]);
+ vars.insert(&hip_properties[pie_property_start],
+ &hip_properties[pie_property_start + pie_property_size]);
vars.insert(&objc_properties[pie_property_start],
&objc_properties[pie_property_start + pie_property_size]);
vars.insert(
@@ -826,6 +850,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
cState.Enabled(testLangs.find("C") != testLangs.end());
cxxState.Enabled(testLangs.find("CXX") != testLangs.end());
cudaState.Enabled(testLangs.find("CUDA") != testLangs.end());
+ hipState.Enabled(testLangs.find("HIP") != testLangs.end());
objcState.Enabled(testLangs.find("OBJC") != testLangs.end());
objcxxState.Enabled(testLangs.find("OBJCXX") != testLangs.end());
@@ -833,7 +858,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool honorStandard = true;
if (cState.DidNone() && cxxState.DidNone() && objcState.DidNone() &&
- objcxxState.DidNone() && cudaState.DidNone()) {
+ objcxxState.DidNone() && cudaState.DidNone() && hipState.DidNone()) {
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0067)) {
case cmPolicies::WARN:
warnCMP0067 = this->Makefile->PolicyOptionalWarningEnabled(
@@ -863,6 +888,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
warnCMP0067, warnCMP0067Variables);
cudaState.LoadUnsetPropertyValues(this->Makefile, honorStandard,
warnCMP0067, warnCMP0067Variables);
+ hipState.LoadUnsetPropertyValues(this->Makefile, honorStandard,
+ warnCMP0067, warnCMP0067Variables);
objcState.LoadUnsetPropertyValues(this->Makefile, honorStandard,
warnCMP0067, warnCMP0067Variables);
objcxxState.LoadUnsetPropertyValues(this->Makefile, honorStandard,
@@ -885,6 +912,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
cState.WriteProperties(fout, targetName);
cxxState.WriteProperties(fout, targetName);
cudaState.WriteProperties(fout, targetName);
+ hipState.WriteProperties(fout, targetName);
objcState.WriteProperties(fout, targetName);
objcxxState.WriteProperties(fout, targetName);
@@ -1015,17 +1043,21 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir)
// cannot delete them immediately. Try a few times.
cmSystemTools::WindowsFileRetry retry =
cmSystemTools::GetWindowsFileRetry();
- while (!cmSystemTools::RemoveFile(fullPath) && --retry.Count &&
- cmSystemTools::FileExists(fullPath)) {
+ cmsys::Status status;
+ while (!((status = cmSystemTools::RemoveFile(fullPath))) &&
+ --retry.Count && cmSystemTools::FileExists(fullPath)) {
cmSystemTools::Delay(retry.Delay);
}
if (retry.Count == 0)
#else
- if (!cmSystemTools::RemoveFile(fullPath))
+ cmsys::Status status = cmSystemTools::RemoveFile(fullPath);
+ if (!status)
#endif
{
- std::string m = "Remove failed on file: " + fullPath;
- cmSystemTools::ReportLastSystemError(m.c_str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("The file:\n ", fullPath,
+ "\ncould not be removed:\n ", status.GetString()));
}
}
}