summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-17 13:11:10 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-04-17 13:11:10 (GMT)
commit2fca2b23107c1e57116cea0dad6c4f9dd9c0c146 (patch)
treea42968db3ef60334a22bfda67684b85813195a92
parent51a8a37443ce491ccccc871702721ba2a69de3bf (diff)
parent3b673586f520cf87ae6a0a923a88ad9dadb80b52 (diff)
downloadCMake-2fca2b23107c1e57116cea0dad6c4f9dd9c0c146.zip
CMake-2fca2b23107c1e57116cea0dad6c4f9dd9c0c146.tar.gz
CMake-2fca2b23107c1e57116cea0dad6c4f9dd9c0c146.tar.bz2
Merge topic 'fix-CMP0052'
3b673586 CMP0052: Make the warning message more informative. 5baa8159 CMP0052: Test that include dirs in install locations cause no warnings. 9e0b3153 CMP0052: Do not warn when include dir is not in source or build tree
-rw-r--r--Source/cmExportFileGenerator.cxx15
-rw-r--r--Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt5
-rw-r--r--Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt1
-rw-r--r--Tests/RunCMake/include_directories/DirInInstallPrefix.cmake9
-rw-r--r--Tests/RunCMake/include_directories/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt5
7 files changed, 34 insertions, 5 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 42fce6d..2db4086 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -277,6 +277,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
" \"" << *li << "\"";
target->GetMakefile()->IssueMessage(messageType, e.str());
}
+ bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
+ bool inSource = isSubDirectory(li->c_str(), topSourceDir);
if (isSubDirectory(li->c_str(), installDir))
{
// The include directory is inside the install tree. If the
@@ -284,8 +286,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
// fall through to the checks below that the include directory is not
// also inside the source tree or build tree.
bool shouldContinue =
- isSubDirectory(installDir, topBinaryDir)
- || isSubDirectory(installDir, topSourceDir);
+ (!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
+ (!inSource || isSubDirectory(installDir, topSourceDir));
if (!shouldContinue)
{
@@ -299,7 +301,10 @@ static bool checkInterfaceDirs(const std::string &prepro,
s << "Directory:\n \"" << *li << "\"\nin "
"INTERFACE_INCLUDE_DIRECTORIES of target \""
<< target->GetName() << "\" is a subdirectory of the install "
- "directory:\n \"" << installDir << "\"";
+ "directory:\n \"" << installDir << "\"\nhowever it is also "
+ "a subdirectory of the " << (inBinary ? "build" : "source")
+ << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
+ << "\"" << std::endl;
target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
s.str());
}
@@ -317,7 +322,7 @@ static bool checkInterfaceDirs(const std::string &prepro,
continue;
}
}
- if (isSubDirectory(li->c_str(), topBinaryDir))
+ if (inBinary)
{
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
@@ -326,7 +331,7 @@ static bool checkInterfaceDirs(const std::string &prepro,
}
if (!inSourceBuild)
{
- if (isSubDirectory(li->c_str(), topSourceDir))
+ if (inSource)
{
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt
index f6d408c..054bff5 100644
--- a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt
@@ -12,4 +12,9 @@ CMake Warning \(dev\) in CMakeLists.txt:
of the install directory:
".*Tests/RunCMake/include_directories/prefix"
+
+ however it is also a subdirectory of the build tree:
+
+ ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build"
+
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake
new file mode 100644
index 0000000..d6f08bd
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake
@@ -0,0 +1,9 @@
+
+add_library(testTarget empty.cpp)
+target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/dir")
+
+install(TARGETS testTarget EXPORT testTargets
+ DESTINATION lib
+)
+
+install(EXPORT testTargets DESTINATION lib/cmake)
diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake
index 434beb9..c5b29d0 100644
--- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake
+++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake
@@ -13,6 +13,9 @@ run_cmake(install_config)
run_cmake(incomplete-genex)
run_cmake(export-NOWARN)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/DirInInstallPrefix/prefix")
+run_cmake(DirInInstallPrefix)
+
configure_file(
"${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_BINARY_DIR}/copy/CMakeLists.txt"
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt
index 78710c0..0b13fd8 100644
--- a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt
@@ -12,4 +12,9 @@ CMake Warning \(dev\) in CMakeLists.txt:
of the install directory:
".*Tests/RunCMake/include_directories/prefix"
+
+ however it is also a subdirectory of the source tree:
+
+ ".*Tests/RunCMake/include_directories/prefix/src"
+
This warning is for project developers. Use -Wno-dev to suppress it.