Browse Source

target_include_directories: Allow relative path with genex

Treat paths which are relative and which contain a generator
expression which is not at the beginning as relative to the
source directory.

This matches the behavior of paths which are relative but contain
no generator expression at all.

Previously this would generate a relative path with the IMPORTED
target on export(), which would be a reported as a non-existent
path on import. If used directly in the buildsystem, it would be
reported as a relative path, which is also an error. There is no
need for a policy in this case.
Stephen Kelly 12 years ago
parent
commit
38afc82e76

+ 1 - 1
Source/cmTargetIncludeDirectoriesCommand.cxx

@@ -50,7 +50,7 @@ std::string cmTargetIncludeDirectoriesCommand
     it != content.end(); ++it)
     it != content.end(); ++it)
     {
     {
     if (cmSystemTools::FileIsFullPath(it->c_str())
     if (cmSystemTools::FileIsFullPath(it->c_str())
-        || cmGeneratorExpression::Find(*it) != std::string::npos)
+        || cmGeneratorExpression::Find(*it) == 0)
       {
       {
       dirs += sep + *it;
       dirs += sep + *it;
       }
       }

+ 2 - 1
Tests/CMakeCommands/target_include_directories/CMakeLists.txt

@@ -45,7 +45,8 @@ add_executable(consumer
 target_include_directories(consumer
 target_include_directories(consumer
   PRIVATE
   PRIVATE
     $<TARGET_PROPERTY:target_include_directories,INTERFACE_INCLUDE_DIRECTORIES>
     $<TARGET_PROPERTY:target_include_directories,INTERFACE_INCLUDE_DIRECTORIES>
-  relative_dir
+    relative_dir
+    relative_dir/$<TARGET_PROPERTY:NAME>
 )
 )
 
 
 # Test no items
 # Test no items

+ 5 - 0
Tests/CMakeCommands/target_include_directories/consumer.cpp

@@ -3,6 +3,7 @@
 #include "publicinclude.h"
 #include "publicinclude.h"
 #include "interfaceinclude.h"
 #include "interfaceinclude.h"
 #include "relative_dir.h"
 #include "relative_dir.h"
+#include "consumer.h"
 
 
 #ifdef PRIVATEINCLUDE_DEFINE
 #ifdef PRIVATEINCLUDE_DEFINE
 #error Unexpected PRIVATEINCLUDE_DEFINE
 #error Unexpected PRIVATEINCLUDE_DEFINE
@@ -24,4 +25,8 @@
 #error Expected RELATIVE_DIR_DEFINE
 #error Expected RELATIVE_DIR_DEFINE
 #endif
 #endif
 
 
+#ifndef CONSUMER_DEFINE
+#error Expected CONSUMER_DEFINE
+#endif
+
 int main() { return 0; }
 int main() { return 0; }

+ 2 - 0
Tests/CMakeCommands/target_include_directories/relative_dir/consumer/consumer.h

@@ -0,0 +1,2 @@
+
+#define CONSUMER_DEFINE