mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
install: Don't ignore EXCLUDE_FROM_ALL when used with ALL_COMPONENTS
Fixes: #23494
This commit is contained in:
@@ -165,14 +165,22 @@ void cmInstallGenerator::AddInstallRule(
|
||||
}
|
||||
|
||||
std::string cmInstallGenerator::CreateComponentTest(
|
||||
const std::string& component, bool exclude_from_all)
|
||||
const std::string& component, bool exclude_from_all, bool all_components)
|
||||
{
|
||||
if (all_components) {
|
||||
if (exclude_from_all) {
|
||||
return "CMAKE_INSTALL_COMPONENT";
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string result = "CMAKE_INSTALL_COMPONENT STREQUAL \"";
|
||||
result += component;
|
||||
result += "\"";
|
||||
if (!exclude_from_all) {
|
||||
result += " OR NOT CMAKE_INSTALL_COMPONENT";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -181,10 +189,11 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
|
||||
// Track indentation.
|
||||
Indent indent;
|
||||
|
||||
std::string component_test = this->CreateComponentTest(
|
||||
this->Component, this->ExcludeFromAll, this->AllComponents);
|
||||
|
||||
// Begin this block of installation.
|
||||
if (!this->AllComponents) {
|
||||
std::string component_test =
|
||||
this->CreateComponentTest(this->Component, this->ExcludeFromAll);
|
||||
if (!component_test.empty()) {
|
||||
os << indent << "if(" << component_test << ")\n";
|
||||
}
|
||||
|
||||
@@ -193,7 +202,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
|
||||
this->AllComponents ? indent : indent.Next());
|
||||
|
||||
// End this block of installation.
|
||||
if (!this->AllComponents) {
|
||||
if (!component_test.empty()) {
|
||||
os << indent << "endif()\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,8 @@ protected:
|
||||
void GenerateScript(std::ostream& os) override;
|
||||
|
||||
std::string CreateComponentTest(const std::string& component,
|
||||
bool exclude_from_all);
|
||||
bool exclude_from_all,
|
||||
bool all_components = false);
|
||||
|
||||
using TweakMethod =
|
||||
std::function<void(std::ostream& os, Indent indent,
|
||||
|
||||
@@ -1 +1 @@
|
||||
check_installed([[^empty1.txt;empty2.txt$]])
|
||||
check_installed([[^empty1.txt;empty3.txt$]])
|
||||
|
||||
@@ -1 +1 @@
|
||||
check_installed([[^empty1.txt;empty2.txt$]])
|
||||
check_installed([[^empty1.txt;empty2.txt;empty3.txt$]])
|
||||
|
||||
@@ -1 +1 @@
|
||||
check_installed([[^empty1.txt;empty2.txt$]])
|
||||
check_installed([[^empty1.txt;empty2.txt;empty3.txt$]])
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
|
||||
install(
|
||||
SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/install_script.cmake"
|
||||
ALL_COMPONENTS
|
||||
)
|
||||
|
||||
install(
|
||||
CODE "write_empty_file(empty2.txt)"
|
||||
ALL_COMPONENTS
|
||||
)
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
install(
|
||||
CODE "write_empty_file(empty3.txt)"
|
||||
ALL_COMPONENTS
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user