summaryrefslogtreecommitdiffstats
path: root/Source/cmExtraCodeBlocksGenerator.cxx
diff options
context:
space:
mode:
authorAlexandr (Sagrer) Gridnev <sagrer@yandex.ru>2017-08-18 21:22:54 (GMT)
committerAlexandr (Sagrer) Gridnev <sagrer@yandex.ru>2017-09-14 10:21:59 (GMT)
commitfb19b7789aba9d7e9bd5d6c679c20e1f27e9a986 (patch)
tree172c3e38dfa6ad3ee5f4fc15c8a5c796ab422a72 /Source/cmExtraCodeBlocksGenerator.cxx
parentd6b49ee6767e8b21eee08d218ca5f599ad8f978b (diff)
downloadCMake-fb19b7789aba9d7e9bd5d6c679c20e1f27e9a986.zip
CMake-fb19b7789aba9d7e9bd5d6c679c20e1f27e9a986.tar.gz
CMake-fb19b7789aba9d7e9bd5d6c679c20e1f27e9a986.tar.bz2
CodeBlocks: add option to exclude external files
Add variable `CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES` to optionally exclude files from outside the project root from the project file written by the CodeBlocks extra generator. This optionally restores logic that had been removed by commit v2.8.3~40^2 (CodeBlocks Generator: Do not omit files in the project file listing, 2010-10-05) in response to QTCREATORBUG-2250. Issue: #12110 Fixes: #17188
Diffstat (limited to 'Source/cmExtraCodeBlocksGenerator.cxx')
-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);
}