mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-03 14:20:27 +00:00
Ninja Multi-Config: Make "install" targets depend on default configs
And add an "install:all" target. Fixes: #20713
This commit is contained in:
@@ -415,6 +415,11 @@ public:
|
|||||||
|
|
||||||
std::set<std::string> GetCrossConfigs(const std::string& config) const;
|
std::set<std::string> GetCrossConfigs(const std::string& config) const;
|
||||||
|
|
||||||
|
const std::set<std::string>& GetDefaultConfigs() const
|
||||||
|
{
|
||||||
|
return this->DefaultConfigs;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Generate() override;
|
void Generate() override;
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,43 @@ void cmLocalNinjaGenerator::Generate()
|
|||||||
if (target->Target->IsPerConfig()) {
|
if (target->Target->IsPerConfig()) {
|
||||||
for (auto const& config : this->GetConfigNames()) {
|
for (auto const& config : this->GetConfigNames()) {
|
||||||
tg->Generate(config);
|
tg->Generate(config);
|
||||||
|
if (target->GetType() == cmStateEnums::GLOBAL_TARGET &&
|
||||||
|
this->GetGlobalGenerator()->IsMultiConfig()) {
|
||||||
|
cmNinjaBuild phonyAlias("phony");
|
||||||
|
this->GetGlobalNinjaGenerator()->AppendTargetOutputs(
|
||||||
|
target.get(), phonyAlias.Outputs, "");
|
||||||
|
this->GetGlobalNinjaGenerator()->AppendTargetOutputs(
|
||||||
|
target.get(), phonyAlias.ExplicitDeps, config);
|
||||||
|
this->GetGlobalNinjaGenerator()->WriteBuild(
|
||||||
|
*this->GetGlobalNinjaGenerator()->GetConfigFileStream(config),
|
||||||
|
phonyAlias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target->GetType() == cmStateEnums::GLOBAL_TARGET &&
|
||||||
|
this->GetGlobalGenerator()->IsMultiConfig()) {
|
||||||
|
if (!this->GetGlobalNinjaGenerator()->GetDefaultConfigs().empty()) {
|
||||||
|
cmNinjaBuild phonyAlias("phony");
|
||||||
|
this->GetGlobalNinjaGenerator()->AppendTargetOutputs(
|
||||||
|
target.get(), phonyAlias.Outputs, "");
|
||||||
|
for (auto const& config :
|
||||||
|
this->GetGlobalNinjaGenerator()->GetDefaultConfigs()) {
|
||||||
|
this->GetGlobalNinjaGenerator()->AppendTargetOutputs(
|
||||||
|
target.get(), phonyAlias.ExplicitDeps, config);
|
||||||
|
}
|
||||||
|
this->GetGlobalNinjaGenerator()->WriteBuild(
|
||||||
|
*this->GetGlobalNinjaGenerator()->GetDefaultFileStream(),
|
||||||
|
phonyAlias);
|
||||||
|
}
|
||||||
|
cmNinjaBuild phonyAlias("phony");
|
||||||
|
this->GetGlobalNinjaGenerator()->AppendTargetOutputs(
|
||||||
|
target.get(), phonyAlias.Outputs, "all");
|
||||||
|
for (auto const& config : this->GetConfigNames()) {
|
||||||
|
this->GetGlobalNinjaGenerator()->AppendTargetOutputs(
|
||||||
|
target.get(), phonyAlias.ExplicitDeps, config);
|
||||||
|
}
|
||||||
|
this->GetGlobalNinjaGenerator()->WriteBuild(
|
||||||
|
*this->GetGlobalNinjaGenerator()->GetDefaultFileStream(),
|
||||||
|
phonyAlias);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tg->Generate("");
|
tg->Generate("");
|
||||||
|
|||||||
@@ -160,10 +160,5 @@ void cmNinjaUtilityTargetGenerator::Generate(const std::string& config)
|
|||||||
// be per-directory and have one at the top-level anyway.
|
// be per-directory and have one at the top-level anyway.
|
||||||
if (genTarget->GetType() != cmStateEnums::GLOBAL_TARGET) {
|
if (genTarget->GetType() != cmStateEnums::GLOBAL_TARGET) {
|
||||||
gg->AddTargetAlias(this->GetTargetName(), genTarget, config);
|
gg->AddTargetAlias(this->GetTargetName(), genTarget, config);
|
||||||
} else if (gg->IsMultiConfig() && genTarget->Target->IsPerConfig()) {
|
|
||||||
cmNinjaBuild phonyAlias("phony");
|
|
||||||
gg->AppendTargetOutputs(genTarget, phonyAlias.Outputs, "");
|
|
||||||
phonyAlias.ExplicitDeps = phonyBuild.Outputs;
|
|
||||||
gg->WriteBuild(this->GetImplFileStream(config), phonyAlias);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
check_files("${RunCMake_TEST_BINARY_DIR}"
|
||||||
|
INCLUDE
|
||||||
|
${TARGET_FILE_exe_Debug}
|
||||||
|
${TARGET_OBJECT_FILES_exe_Debug}
|
||||||
|
|
||||||
|
${TARGET_FILE_mylib_Release}
|
||||||
|
${TARGET_LINKER_FILE_mylib_Debug}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_Debug}
|
||||||
|
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/bin/Debug/${TARGET_FILE_NAME_exe_Debug}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_FILE_NAME_mylib_Debug}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_LINKER_FILE_NAME_mylib_Debug}
|
||||||
|
|
||||||
|
${TARGET_FILE_exe_Release}
|
||||||
|
${TARGET_OBJECT_FILES_exe_Release}
|
||||||
|
|
||||||
|
${TARGET_FILE_mylib_Release}
|
||||||
|
${TARGET_LINKER_FILE_mylib_Release}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_Release}
|
||||||
|
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/bin/Release/${TARGET_FILE_NAME_exe_Release}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_FILE_NAME_mylib_Release}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_LINKER_FILE_NAME_mylib_Release}
|
||||||
|
|
||||||
|
${TARGET_FILE_exe_RelWithDebInfo}
|
||||||
|
${TARGET_OBJECT_FILES_exe_RelWithDebInfo}
|
||||||
|
|
||||||
|
${TARGET_FILE_mylib_RelWithDebInfo}
|
||||||
|
${TARGET_LINKER_FILE_mylib_RelWithDebInfo}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_RelWithDebInfo}
|
||||||
|
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/bin/RelWithDebInfo/${TARGET_FILE_NAME_exe_RelWithDebInfo}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/RelWithDebInfo/${TARGET_FILE_NAME_mylib_RelWithDebInfo}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/RelWithDebInfo/${TARGET_LINKER_FILE_NAME_mylib_RelWithDebInfo}
|
||||||
|
|
||||||
|
EXCLUDE
|
||||||
|
${TARGET_OBJECT_FILES_exe_MinSizeRel}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_MinSizeRel}
|
||||||
|
)
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
check_files("${RunCMake_TEST_BINARY_DIR}"
|
||||||
|
INCLUDE
|
||||||
|
${TARGET_FILE_exe_Debug}
|
||||||
|
${TARGET_OBJECT_FILES_exe_Debug}
|
||||||
|
|
||||||
|
${TARGET_FILE_mylib_Release}
|
||||||
|
${TARGET_LINKER_FILE_mylib_Debug}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_Debug}
|
||||||
|
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/bin/Debug/${TARGET_FILE_NAME_exe_Debug}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_FILE_NAME_mylib_Debug}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Debug/${TARGET_LINKER_FILE_NAME_mylib_Debug}
|
||||||
|
|
||||||
|
${TARGET_FILE_exe_Release}
|
||||||
|
${TARGET_OBJECT_FILES_exe_Release}
|
||||||
|
|
||||||
|
${TARGET_FILE_mylib_Release}
|
||||||
|
${TARGET_LINKER_FILE_mylib_Release}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_Release}
|
||||||
|
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/bin/Release/${TARGET_FILE_NAME_exe_Release}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_FILE_NAME_mylib_Release}
|
||||||
|
${RunCMake_TEST_BINARY_DIR}/install/lib/Release/${TARGET_LINKER_FILE_NAME_mylib_Release}
|
||||||
|
|
||||||
|
EXCLUDE
|
||||||
|
${TARGET_OBJECT_FILES_exe_MinSizeRel}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_MinSizeRel}
|
||||||
|
|
||||||
|
${TARGET_OBJECT_FILES_exe_RelWithDebInfo}
|
||||||
|
${TARGET_OBJECT_FILES_mylib_RelWithDebInfo}
|
||||||
|
)
|
||||||
@@ -263,12 +263,16 @@ run_cmake_build(AdditionalCleanFiles release-clean Release clean)
|
|||||||
run_ninja(AdditionalCleanFiles all-clean build-Debug.ninja clean:all)
|
run_ninja(AdditionalCleanFiles all-clean build-Debug.ninja clean:all)
|
||||||
|
|
||||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Install-build)
|
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Install-build)
|
||||||
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_CROSS_CONFIGS=all")
|
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_TEST_BINARY_DIR}/install;-DCMAKE_CROSS_CONFIGS=all;-DCMAKE_DEFAULT_CONFIGS=Debug\\;Release")
|
||||||
run_cmake_configure(Install)
|
run_cmake_configure(Install)
|
||||||
unset(RunCMake_TEST_OPTIONS)
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
|
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
|
||||||
run_cmake_build(Install release-install Release install)
|
run_cmake_build(Install release-install Release install)
|
||||||
run_ninja(Install debug-in-release-graph-install build-Release.ninja install:Debug)
|
run_ninja(Install debug-in-release-graph-install build-Release.ninja install:Debug)
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/install")
|
||||||
|
run_ninja(Install default-install build.ninja install)
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/install")
|
||||||
|
run_ninja(Install all-install build.ninja install:all)
|
||||||
|
|
||||||
# FIXME Get this working
|
# FIXME Get this working
|
||||||
#set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutoMocExecutable-build)
|
#set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutoMocExecutable-build)
|
||||||
|
|||||||
Reference in New Issue
Block a user