mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 12:49:36 -06:00
Ninja: Fix WINDOWS_EXPORT_ALL_SYMBOLS with PRE_LINK build event
Previously the `__create_def` command could fail in cases where a `PRE_LINK` custom command changes the working directory. Fixes: #26973
This commit is contained in:
@@ -1450,6 +1450,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
}
|
||||
}
|
||||
|
||||
// If we have any PRE_LINK commands, we need to go back to CMAKE_BINARY_DIR
|
||||
// for the link commands.
|
||||
if (!preLinkCmdLines.empty()) {
|
||||
std::string const homeOutDir = localGen.ConvertToOutputFormat(
|
||||
localGen.GetBinaryDirectory(), cmOutputConverter::SHELL);
|
||||
preLinkCmdLines.push_back("cd " + homeOutDir);
|
||||
}
|
||||
|
||||
// maybe create .def file from list of objects
|
||||
cmGeneratorTarget::ModuleDefinitionInfo const* mdi =
|
||||
gt->GetModuleDefinitionInfo(config);
|
||||
@@ -1490,13 +1498,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
|
||||
fout << src->GetFullPath() << "\n";
|
||||
}
|
||||
}
|
||||
// If we have any PRE_LINK commands, we need to go back to CMAKE_BINARY_DIR
|
||||
// for the link commands.
|
||||
if (!preLinkCmdLines.empty()) {
|
||||
std::string const homeOutDir = localGen.ConvertToOutputFormat(
|
||||
localGen.GetBinaryDirectory(), cmOutputConverter::SHELL);
|
||||
preLinkCmdLines.push_back("cd " + homeOutDir);
|
||||
}
|
||||
|
||||
vars["PRE_LINK"] = localGen.BuildCommandLine(
|
||||
preLinkCmdLines, config, fileConfig, "pre-link", this->GeneratorTarget);
|
||||
|
||||
@@ -3,3 +3,4 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
# Try msvc "big" object format.
|
||||
target_compile_options(autoexport2 PRIVATE /bigobj)
|
||||
endif()
|
||||
add_custom_command(TARGET autoexport2 PRE_LINK COMMAND ${CMAKE_COMMAND} -E true)
|
||||
|
||||
Reference in New Issue
Block a user