summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2024-03-11 17:10:43 (GMT)
committerBrad King <brad.king@kitware.com>2024-03-13 15:13:21 (GMT)
commit801ae06952fc090d07c666b1e56573cae648f599 (patch)
treed99cc5103040c2900f914fd385fbe40a584df612 /Source
parent939ac5287e9a04398a8eb01243e14e00d13d38ef (diff)
downloadCMake-801ae06952fc090d07c666b1e56573cae648f599.zip
CMake-801ae06952fc090d07c666b1e56573cae648f599.tar.gz
CMake-801ae06952fc090d07c666b1e56573cae648f599.tar.bz2
LINKER_TYPE: Support MOLD only on GCC versions that support it
Fixes: #25748
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx22
-rw-r--r--Source/cmLocalGenerator.cxx21
2 files changed, 34 insertions, 9 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 46c9082..a40af8b 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -5,6 +5,7 @@
#include <algorithm>
#include <array>
#include <cassert>
+#include <cctype>
#include <cerrno>
#include <cstddef>
#include <cstdio>
@@ -5585,11 +5586,22 @@ std::string cmGeneratorTarget::GetLinkerTool(const std::string& lang,
linkerTool = this->Makefile->GetDefinition("CMAKE_LINKER");
if (linkerType != "DEFAULT"_s) {
- this->LocalGenerator->IssueMessage(
- MessageType::FATAL_ERROR,
- cmStrCat("LINKER_TYPE '", linkerType,
- "' is unknown. Did you forget to define '", usingLinker,
- "' variable?"));
+ auto isCMakeLinkerType = [](const std::string& type) -> bool {
+ return std::all_of(type.cbegin(), type.cend(),
+ [](char c) { return std::isupper(c); });
+ };
+ if (isCMakeLinkerType(linkerType)) {
+ this->LocalGenerator->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("LINKER_TYPE '", linkerType,
+ "' is unknown or not supported by this toolchain."));
+ } else {
+ this->LocalGenerator->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("LINKER_TYPE '", linkerType,
+ "' is unknown. Did you forget to define the '", usingLinker,
+ "' variable?"));
+ }
}
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 1dd2f4a..d38ed50 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -5,6 +5,7 @@
#include <algorithm>
#include <array>
#include <cassert>
+#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <initializer_list>
@@ -3357,10 +3358,22 @@ void cmLocalGenerator::AppendLinkerTypeFlags(std::string& flags,
this->AppendFlags(flags, linkerFlags);
}
} else if (linkerType != "DEFAULT"_s) {
- this->IssueMessage(MessageType::FATAL_ERROR,
- cmStrCat("LINKER_TYPE '", linkerType,
- "' is unknown. Did you forget to define '",
- usingLinker, "' variable?"));
+ auto isCMakeLinkerType = [](const std::string& type) -> bool {
+ return std::all_of(type.cbegin(), type.cend(),
+ [](char c) { return std::isupper(c); });
+ };
+ if (isCMakeLinkerType(linkerType)) {
+ this->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("LINKER_TYPE '", linkerType,
+ "' is unknown or not supported by this toolchain."));
+ } else {
+ this->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("LINKER_TYPE '", linkerType,
+ "' is unknown. Did you forget to define the '", usingLinker,
+ "' variable?"));
+ }
}
}