summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-15 12:52:34 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-09-15 12:53:04 (GMT)
commit188cdb98a73f31c5eb6c2b3896777184ad101e0f (patch)
tree251eed9a692b2a704def117763fd1d71cef8a363 /Source
parent4644ab3995ddb677e2ebe430965ca887a3db82c8 (diff)
parentfb19b7789aba9d7e9bd5d6c679c20e1f27e9a986 (diff)
downloadCMake-188cdb98a73f31c5eb6c2b3896777184ad101e0f.zip
CMake-188cdb98a73f31c5eb6c2b3896777184ad101e0f.tar.gz
CMake-188cdb98a73f31c5eb6c2b3896777184ad101e0f.tar.bz2
Merge topic 'codeblocks-exclude-external'
fb19b778 CodeBlocks: add option to exclude external files Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1159
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx20
1 files changed, 20 insertions, 0 deletions
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 48d07ad..9c9b75b 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -235,7 +235,14 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
// We don't want paths with CMakeFiles in them
// or do we?
// In speedcrunch those where purely internal
+ //
+ // Also we can disable external (outside the project) files by setting ON
+ // CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable.
+ const bool excludeExternal =
+ cmSystemTools::IsOn(it.second[0]->GetMakefile()->GetSafeDefinition(
+ "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES"));
if (!splitted.empty() &&
+ (!excludeExternal || (relative.find("..") == std::string::npos)) &&
relative.find("CMakeFiles") == std::string::npos) {
tree.InsertPath(splitted, 1, fileName);
}
@@ -380,6 +387,19 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile(
std::string const& fullPath = s->GetFullPath();
+ // Check file position relative to project root dir.
+ const std::string& relative = cmSystemTools::RelativePath(
+ (*lg).GetSourceDirectory(), fullPath.c_str());
+ // Do not add this file if it has ".." in relative path and
+ // if CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable is on.
+ const bool excludeExternal =
+ cmSystemTools::IsOn((*lg).GetMakefile()->GetSafeDefinition(
+ "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES"));
+ if (excludeExternal &&
+ (relative.find("..") != std::string::npos)) {
+ continue;
+ }
+
if (isCFile) {
cFiles.push_back(fullPath);
}