WINDOWS_EXPORT_ALL_SYMBOLS: Fix support for Visual Studio with ClangCL

Thread `CMAKE_NM` to the generated `__create_def` commands.

Closes: #27994
This commit is contained in:
Chuck Atkins
2026-08-05 10:58:20 -04:00
parent ca1dc92e36
commit 6d6e58a15e
6 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -639,7 +639,7 @@ void cmFastbuildNormalTargetGenerator::GenerateModuleDefinitionInfo(
std::string const obj_list_file = mdi->DefFile + ".objs";
auto const nm_executable = GetMakefile()->GetDefinition("CMAKE_NM");
if (!nm_executable.IsEmpty()) {
if (!cmIsOff(nm_executable)) {
execNode.ExecArguments += " --nm=";
execNode.ExecArguments += ConvertToFastbuildPath(*nm_executable);
}
+1 -1
View File
@@ -72,7 +72,7 @@ public:
std::string const& GetPlatformToolsetString() const;
/** Return true when using a Visual Studio clang-cl toolset. */
bool IsClangClToolset() const;
bool IsClangClToolset() const override;
/** The toolset version props file, if any. */
std::string const& GetPlatformToolsetVersionProps() const;
+5
View File
@@ -733,6 +733,11 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
{ cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file });
cmValue const nmExecutable =
gt->Target->GetMakefile()->GetDefinition("CMAKE_NM");
if (!cmIsOff(nmExecutable) && this->IsClangClToolset()) {
commandLines[0].emplace_back(cmStrCat("--nm=", *nmExecutable));
}
cmCustomCommand command;
command.SetOutputs(outputs);
command.SetCommandLines(commandLines);
+3
View File
@@ -156,6 +156,9 @@ public:
protected:
cmGlobalVisualStudioGenerator(cmake* cm);
/** Return true when using a Visual Studio clang-cl toolset. */
virtual bool IsClangClToolset() const { return false; }
virtual bool InitializePlatform(cmMakefile* mf);
void AddExtraIDETargets() override;
+1 -1
View File
@@ -2424,7 +2424,7 @@ void cmMakefileTargetGenerator::GenDefFile(
this->LocalGenerator->MaybeRelativeToCurBinDir(objlist_file),
cmOutputConverter::SHELL);
cmValue const nm_executable = this->Makefile->GetDefinition("CMAKE_NM");
if (cmNonempty(nm_executable)) {
if (!cmIsOff(nm_executable)) {
cmd += " --nm=";
cmd += this->LocalCommonGenerator->ConvertToOutputFormat(
*nm_executable, cmOutputConverter::SHELL);
+1 -1
View File
@@ -1534,7 +1534,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
obj_list_file, cmOutputConverter::SHELL);
cmValue nm_executable = this->GetMakefile()->GetDefinition("CMAKE_NM");
if (cmNonempty(nm_executable)) {
if (!cmIsOff(nm_executable)) {
cmd += " --nm=";
cmd += this->LocalCommonGenerator->ConvertToOutputFormat(
*nm_executable, cmOutputConverter::SHELL);