Commit 08cb4fa4 authored by Stephen Kelly's avatar Stephen Kelly Committed by Brad King

Process generator expressions in the INCLUDE_DIRECTORIES property.

This use of generator expressions, like all others to come which operate
on target properties, must initalize the dag checker.
parent 0ef091d9
......@@ -17,6 +17,8 @@
#include "cmComputeLinkInformation.h"
#include "cmGlobalGenerator.h"
#include "cmSourceFile.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionDAGChecker.h"
#include <assert.h>
......@@ -289,11 +291,27 @@ std::vector<std::string> cmGeneratorTarget::GetIncludeDirectories()
{
std::vector<std::string> includes;
const char *prop = this->Target->GetProperty("INCLUDE_DIRECTORIES");
if(prop)
if(!prop)
{
cmSystemTools::ExpandListArgument(prop, includes);
return includes;
}
const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt);
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
this->GetName(),
"INCLUDE_DIRECTORIES", 0, 0);
cmSystemTools::ExpandListArgument(ge.Parse(prop)
.Evaluate(this->Makefile,
config,
false,
this,
&dagChecker),
includes);
std::set<std::string> uniqueIncludes;
std::vector<std::string> orderedAndUniqueIncludes;
for(std::vector<std::string>::const_iterator
......
......@@ -55,6 +55,11 @@ bool cmIncludeDirectoryCommand
return true;
}
static bool StartsWithGeneratorExpression(const std::string &input)
{
return input[0] == '$' && input[1] == '<';
}
// do a lot of cleanup on the arguments because this is one place where folks
// sometimes take the output of a program and pass it directly into this
// command not thinking that a single argument could be filled with spaces
......@@ -105,7 +110,7 @@ void cmIncludeDirectoryCommand::AddDirectory(const char *i,
cmSystemTools::ConvertToUnixSlashes(ret);
if(!cmSystemTools::FileIsFullPath(ret.c_str()))
{
if(ret[0] != '$' && ret[1] != '<')
if(!StartsWithGeneratorExpression(ret))
{
std::string tmp = this->Makefile->GetStartDirectory();
tmp += "/";
......
......@@ -12,13 +12,21 @@ create_header(bar)
create_header(bat)
create_header(foo)
create_header(baz)
create_header(bang)
create_header(bing)
create_header(bung)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories("${CMAKE_CURRENT_BINARY_DIR}/bar")
include_directories("$<1:${CMAKE_CURRENT_BINARY_DIR}/bang>")
add_executable(TargetIncludeDirectories main.cpp)
set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bat")
set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo")
set_property(TARGET TargetIncludeDirectories APPEND PROPERTY
INCLUDE_DIRECTORIES "$<1:${CMAKE_CURRENT_BINARY_DIR}/bing>")
include_directories("${CMAKE_CURRENT_BINARY_DIR}/baz")
include_directories("$<1:${CMAKE_CURRENT_BINARY_DIR}/bung>")
include_directories("sing$<1:/ting>")
......@@ -3,6 +3,10 @@
#include "bat.h"
#include "foo.h"
#include "baz.h"
#include "bang.h"
#include "bing.h"
#include "bung.h"
#include "ting.h"
int main(int, char**)
{
......
......@@ -46,6 +46,7 @@ macro(add_RunCMake_test test)
endmacro()
add_RunCMake_test(GeneratorExpression)
add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages)
add_RunCMake_test(ObjectLibrary)
......
CMake Error:
Error evaluating generator expression:
\$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>
Self reference on target "TargetPropertyGeneratorExpressions".$
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
"int main(int, char **) { return 0; }\n")
add_executable(TargetPropertyGeneratorExpressions
"${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
include_directories("$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>")
CMake Error:
Error evaluating generator expression:
\$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>
Self reference on target "TargetPropertyGeneratorExpressions".$
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
"int main(int, char **) { return 0; }\n")
add_executable(TargetPropertyGeneratorExpressions
"${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
set_property(TARGET TargetPropertyGeneratorExpressions PROPERTY
INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:INCLUDE_DIRECTORIES>"
)
CMake Error:
Error evaluating generator expression:
\$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>
Self reference on target "TargetPropertyGeneratorExpressions".$
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
"int main(int, char **) { return 0; }\n")
add_executable(TargetPropertyGeneratorExpressions
"${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
include_directories(
"$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>")
CMake Error:
Error evaluating generator expression:
\$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>
Self reference on target "TargetPropertyGeneratorExpressions".$
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp"
"int main(int, char **) { return 0; }\n")
add_executable(TargetPropertyGeneratorExpressions
"${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
set_property(TARGET TargetPropertyGeneratorExpressions PROPERTY
INCLUDE_DIRECTORIES
"$<TARGET_PROPERTY:TargetPropertyGeneratorExpressions,INCLUDE_DIRECTORIES>"
)
cmake_minimum_required(VERSION 2.8)
project(${RunCMake_TEST} CXX)
# MSVC creates extra targets which pollute the stderr unless we set this.
set(CMAKE_SUPPRESS_REGENERATION TRUE)
include(${RunCMake_TEST}.cmake)
include(RunCMake)
run_cmake(BadSelfReference1)
run_cmake(BadSelfReference2)
run_cmake(BadSelfReference3)
run_cmake(BadSelfReference4)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment