summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-11 10:59:38 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-11 11:05:55 (GMT)
commit0f48fbaa72fa254faaed6b586fcaa5d3c5c77798 (patch)
tree38520add1b903a77bdd51af9789c3cab9c869148
parentfd02538974dd952a8639d371c2c0067d30d5469a (diff)
downloadCMake-0f48fbaa72fa254faaed6b586fcaa5d3c5c77798.zip
CMake-0f48fbaa72fa254faaed6b586fcaa5d3c5c77798.tar.gz
CMake-0f48fbaa72fa254faaed6b586fcaa5d3c5c77798.tar.bz2
install: Revert CODE,SCRIPT support for generator expressions
Revert commit v3.13.0-rc1~441^2 (install: Teach CODE,SCRIPT modes to evaluate generator expressions, 2018-05-29). Unfortunately it has been found to break existing code in a real project, e.g. install(CODE [[ message("$<FOOBAR>") ]]) Address this regression by reverting support for the 3.13 release series. Support can be restored later with a policy for compatibility. Issue: #15785 Fixes: #18435
-rw-r--r--Help/command/install.rst4
-rw-r--r--Help/release/3.13.rst3
-rw-r--r--Source/cmInstallScriptGenerator.cxx40
-rw-r--r--Source/cmInstallScriptGenerator.h13
-rw-r--r--Tests/RunCMake/install/CODE-genex-bad-result.txt1
-rw-r--r--Tests/RunCMake/install/CODE-genex-bad-stderr.txt6
-rw-r--r--Tests/RunCMake/install/CODE-genex-bad.cmake1
-rw-r--r--Tests/RunCMake/install/CODE-genex-check.cmake7
-rw-r--r--Tests/RunCMake/install/CODE-genex.cmake2
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake2
10 files changed, 9 insertions, 70 deletions
diff --git a/Help/command/install.rst b/Help/command/install.rst
index 08c5718..98074d0 100644
--- a/Help/command/install.rst
+++ b/Help/command/install.rst
@@ -442,10 +442,6 @@ example, the code
will print a message during installation.
-The contents of ``SCRIPT`` or ``CODE`` may use "generator expressions" with
-the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
-manual for available expressions.
-
Installing Exports
^^^^^^^^^^^^^^^^^^
diff --git a/Help/release/3.13.rst b/Help/release/3.13.rst
index b08f21d..0e05807 100644
--- a/Help/release/3.13.rst
+++ b/Help/release/3.13.rst
@@ -61,9 +61,6 @@ Commands
* The :command:`add_link_options` command was created to add link
options in the current directory.
-* The :command:`install(CODE)` and :command:`install(SCRIPT)` commands
- learned to support generator expressions.
-
* The :command:`install(TARGETS)` command learned to install targets
created outside the current directory.
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index 3a90f4c..f7e6e44 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallScriptGenerator.h"
-#include "cmGeneratorExpression.h"
#include "cmScriptGenerator.h"
#include <ostream>
@@ -17,47 +16,24 @@ cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
, Script(script)
, Code(code)
{
- // We need per-config actions if the script has generator expressions.
- if (cmGeneratorExpression::Find(Script) != std::string::npos) {
- this->ActionsPerConfig = true;
- }
}
cmInstallScriptGenerator::~cmInstallScriptGenerator()
{
}
-void cmInstallScriptGenerator::Compute(cmLocalGenerator* lg)
+void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
{
- this->LocalGenerator = lg;
-}
+ Indent indent;
+ std::string component_test =
+ this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
+ os << indent << "if(" << component_test << ")\n";
-void cmInstallScriptGenerator::AddScriptInstallRule(std::ostream& os,
- Indent indent,
- std::string const& script)
-{
if (this->Code) {
- os << indent.Next() << script << "\n";
- } else {
- os << indent.Next() << "include(\"" << script << "\")\n";
- }
-}
-
-void cmInstallScriptGenerator::GenerateScriptActions(std::ostream& os,
- Indent indent)
-{
- if (this->ActionsPerConfig) {
- this->cmInstallGenerator::GenerateScriptActions(os, indent);
+ os << indent.Next() << this->Script << "\n";
} else {
- this->AddScriptInstallRule(os, indent, this->Script);
+ os << indent.Next() << "include(\"" << this->Script << "\")\n";
}
-}
-void cmInstallScriptGenerator::GenerateScriptForConfig(
- std::ostream& os, const std::string& config, Indent indent)
-{
- cmGeneratorExpression ge;
- std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(this->Script);
- this->AddScriptInstallRule(os, indent,
- cge->Evaluate(this->LocalGenerator, config));
+ os << indent << "endif()\n\n";
}
diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h
index 534bc1d..fe0f7c6 100644
--- a/Source/cmInstallScriptGenerator.h
+++ b/Source/cmInstallScriptGenerator.h
@@ -6,13 +6,10 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmInstallGenerator.h"
-#include "cmScriptGenerator.h"
#include <iosfwd>
#include <string>
-class cmLocalGenerator;
-
/** \class cmInstallScriptGenerator
* \brief Generate target installation rules.
*/
@@ -23,18 +20,10 @@ public:
const char* component, bool exclude_from_all);
~cmInstallScriptGenerator() override;
- void Compute(cmLocalGenerator* lg) override;
-
protected:
- void GenerateScriptActions(std::ostream& os, Indent indent) override;
- void GenerateScriptForConfig(std::ostream& os, const std::string& config,
- Indent indent) override;
- void AddScriptInstallRule(std::ostream& os, Indent indent,
- std::string const& script);
-
+ void GenerateScript(std::ostream& os) override;
std::string Script;
bool Code;
- cmLocalGenerator* LocalGenerator;
};
#endif
diff --git a/Tests/RunCMake/install/CODE-genex-bad-result.txt b/Tests/RunCMake/install/CODE-genex-bad-result.txt
deleted file mode 100644
index d00491f..0000000
--- a/Tests/RunCMake/install/CODE-genex-bad-result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/Tests/RunCMake/install/CODE-genex-bad-stderr.txt b/Tests/RunCMake/install/CODE-genex-bad-stderr.txt
deleted file mode 100644
index 9844158..0000000
--- a/Tests/RunCMake/install/CODE-genex-bad-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error:
- Error evaluating generator expression:
-
- \$<NOTAGENEX>
-
- Expression did not evaluate to a known generator expression
diff --git a/Tests/RunCMake/install/CODE-genex-bad.cmake b/Tests/RunCMake/install/CODE-genex-bad.cmake
deleted file mode 100644
index 1663b39..0000000
--- a/Tests/RunCMake/install/CODE-genex-bad.cmake
+++ /dev/null
@@ -1 +0,0 @@
-install(CODE "message(\"$<NOTAGENEX>\")")
diff --git a/Tests/RunCMake/install/CODE-genex-check.cmake b/Tests/RunCMake/install/CODE-genex-check.cmake
deleted file mode 100644
index 422c532..0000000
--- a/Tests/RunCMake/install/CODE-genex-check.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake
- OUTPUT_VARIABLE out ERROR_VARIABLE err)
-if(NOT out MATCHES "-- Install configuration: .*-- codegenexlib")
- string(REGEX REPLACE "\n" "\n " out " ${out}")
- string(APPEND RunCMake_TEST_FAILED
- "\"-- codegenexlib\" was not found:\n${out}")
-endif()
diff --git a/Tests/RunCMake/install/CODE-genex.cmake b/Tests/RunCMake/install/CODE-genex.cmake
deleted file mode 100644
index 3b8513d..0000000
--- a/Tests/RunCMake/install/CODE-genex.cmake
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library( codegenexlib INTERFACE )
-install(CODE "message( STATUS \"$<TARGET_PROPERTY:codegenexlib,NAME>\")")
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index 91524a6..ec022ca 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -65,8 +65,6 @@ run_cmake(CMP0062-NEW)
run_cmake(CMP0062-WARN)
run_cmake(TARGETS-NAMELINK_COMPONENT-bad-all)
run_cmake(TARGETS-NAMELINK_COMPONENT-bad-exc)
-run_cmake(CODE-genex)
-run_cmake(CODE-genex-bad)
if(NOT RunCMake_GENERATOR STREQUAL "Xcode" OR NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
run_install_test(FILES-TARGET_OBJECTS)