Make it an error for INSTALL_PREFIX to be evaluated.

An empty string is not likely going to produce expected results
in any evaluation context. It is replaced by preprocessing
currently.
This commit is contained in:
Stephen Kelly 2013-01-30 17:49:47 +01:00
parent 7ceeba992b
commit df4d2b28b2
7 changed files with 20 additions and 5 deletions

View File

@ -621,14 +621,17 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode
{
InstallPrefixNode() {}
virtual bool GeneratesContent() const { return false; }
virtual bool GeneratesContent() const { return true; }
virtual int NumExpectedParameters() const { return 0; }
std::string Evaluate(const std::vector<std::string> &,
cmGeneratorExpressionContext *,
const GeneratorExpressionContent *,
cmGeneratorExpressionContext *context,
const GeneratorExpressionContent *content,
cmGeneratorExpressionDAGChecker *) const
{
reportError(context, content->GetOriginalExpression(),
"INSTALL_PREFIX is a marker for install(EXPORT) only. It "
"should never be evaluated.");
return std::string();
}

View File

@ -89,7 +89,6 @@ add_custom_target(check-part2 ALL
-Dtest_install_interface=$<INSTALL_INTERFACE:install>
-Dtest_target_name_1=$<TARGET_NAME:tgt,ok>
-Dtest_target_name_2=$<TARGET_NAME:tgt:ok>
-Dtest_install_prefix=$<INSTALL_PREFIX>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 2)"
VERBATIM

View File

@ -26,4 +26,3 @@ check(test_build_interface "build")
check(test_install_interface "")
check(test_target_name_1 "tgt,ok")
check(test_target_name_2 "tgt:ok")
check(test_install_prefix "")

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,9 @@
CMake Error at BadInstallPrefix.cmake:1 \(add_custom_target\):
Error evaluating generator expression:
\$<INSTALL_PREFIX>
INSTALL_PREFIX is a marker for install\(EXPORT\) only. It should never be
evaluated.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,3 @@
add_custom_target(check ALL COMMAND check
$<INSTALL_PREFIX>/include
VERBATIM)

View File

@ -7,3 +7,4 @@ run_cmake(BadNOT)
run_cmake(BadStrEqual)
run_cmake(BadZero)
run_cmake(BadTargetName)
run_cmake(BadInstallPrefix)