summaryrefslogtreecommitdiff
path: root/Source/cmAlgorithms.h
diff options
context:
space:
mode:
authorNicolas Despres <nicolas.despres@gmail.com>2016-05-14 01:18:20 +0200
committerBrad King <brad.king@kitware.com>2016-05-17 09:34:12 -0400
commit8a862a4d4b852c9f61ae4ed7fc46042b00a83123 (patch)
tree591906a0300c9619e57394105455d93126dab939 /Source/cmAlgorithms.h
parent038e7716e58e4cf79bda6ba72b92814a14978a8f (diff)
downloadcmake-8a862a4d4b852c9f61ae4ed7fc46042b00a83123.tar.gz
Ninja: Support embedding of CMake as subninja project
Add a `CMAKE_NINJA_OUTPUT_PATH_PREFIX` variable. When it is set, CMake generates a `build.ninja` file suitable for embedding into another ninja project potentially generated by an alien generator.
Diffstat (limited to 'Source/cmAlgorithms.h')
-rw-r--r--Source/cmAlgorithms.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 76acaca8f6..ee803c8e82 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -379,4 +379,19 @@ std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
return std::reverse_iterator<Iter>(it);
}
+inline bool cmHasSuffix(const std::string& str, const std::string& suffix)
+{
+ if (str.size() < suffix.size()) {
+ return false;
+ }
+ return str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
+}
+
+inline void cmStripSuffixIfExists(std::string& str, const std::string& suffix)
+{
+ if (cmHasSuffix(str, suffix)) {
+ str.resize(str.size() - suffix.size());
+ }
+}
+
#endif