summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2022-05-14 10:28:56 +0200
committerBrad King <brad.king@kitware.com>2022-05-16 09:34:31 -0400
commitb0c8e31b54ca7ab2647e9301a12a73c23f887acb (patch)
tree8ec2ef518f58d5a8bf05212dee597d73ba9dd988
parentde5777090159eb2d74b17ee9f5d3c8ee9678ec4e (diff)
downloadcmake-b0c8e31b54ca7ab2647e9301a12a73c23f887acb.tar.gz
install: Don't ignore EXCLUDE_FROM_ALL when used with ALL_COMPONENTS
Fixes: #23494
-rw-r--r--Source/cmInstallGenerator.cxx19
-rw-r--r--Source/cmInstallGenerator.h3
-rw-r--r--Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake2
-rw-r--r--Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake2
-rw-r--r--Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake2
-rw-r--r--Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake13
6 files changed, 31 insertions, 10 deletions
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index 87110a9c4f..93abd45693 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -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";
}
}
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index d342c99261..9fcd284a91 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -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,
diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake
index 48d8e1aec6..0b5fb8debf 100644
--- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake
+++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-all-check.cmake
@@ -1 +1 @@
-check_installed([[^empty1.txt;empty2.txt$]])
+check_installed([[^empty1.txt;empty3.txt$]])
diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake
index 48d8e1aec6..88e57e3cbf 100644
--- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake
+++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-dev-check.cmake
@@ -1 +1 @@
-check_installed([[^empty1.txt;empty2.txt$]])
+check_installed([[^empty1.txt;empty2.txt;empty3.txt$]])
diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake
index 48d8e1aec6..88e57e3cbf 100644
--- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake
+++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS-uns-check.cmake
@@ -1 +1 @@
-check_installed([[^empty1.txt;empty2.txt$]])
+check_installed([[^empty1.txt;empty2.txt;empty3.txt$]])
diff --git a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake
index aa3f9d1b7a..73c4e35181 100644
--- a/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake
+++ b/Tests/RunCMake/install/SCRIPT-ALL_COMPONENTS.cmake
@@ -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
+)