From 24dcf0c0072d6e0ca5a1203a54b574d1db9e5a7d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Jan 2013 22:16:46 +0100 Subject: Make sure generator expressions can be used with target_include_directories. Handle the case that a generator expression is used before treating a non-target as an error. --- Source/cmTargetPropCommandBase.cxx | 12 ++++++++++++ .../CMakeCommands/target_include_directories/CMakeLists.txt | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 69aaf17..7f15dcb 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -66,6 +66,14 @@ bool cmTargetPropCommandBase } //---------------------------------------------------------------------------- +static bool isGeneratorExpression(const std::string &lib) +{ + const std::string::size_type openpos = lib.find("$<"); + return (openpos != std::string::npos) + && (lib.find(">", openpos) != std::string::npos); +} + +//---------------------------------------------------------------------------- bool cmTargetPropCommandBase ::ProcessContentArgs(std::vector const& args, unsigned int &argIndex, bool prepend) @@ -105,6 +113,10 @@ bool cmTargetPropCommandBase content += sep + "$Property + ">"; } + else if(isGeneratorExpression(args[i])) + { + content += sep + args[i]; + } else if (!this->HandleNonTargetArg(content, sep, args[i], args[0])) { return false; diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index a0f2ee0..8fa2eae 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -33,7 +33,12 @@ target_include_directories(target_include_directories PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/poison" ) target_include_directories(target_include_directories - BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cure" + BEFORE PUBLIC "$<$:${CMAKE_CURRENT_BINARY_DIR}/cure>" +) + +# Has no effect because the target is not defined: +target_include_directories(target_include_directories + BEFORE PUBLIC "$<$:${CMAKE_CURRENT_BINARY_DIR}/poison>" ) add_library(importedlib UNKNOWN IMPORTED) -- cgit v0.12