diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2019-01-14 17:27:14 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2019-01-17 14:44:29 (GMT) |
commit | 4568d046c46a7357ab48ddfb1117bad39e65572c (patch) | |
tree | 851a7fbee311593712dfff42fdcf9070a2187427 /Source/cmState.cxx | |
parent | c59eae7ebc5423c2b06befd762f8639b0f23b7a0 (diff) | |
download | CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.zip CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.tar.gz CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.tar.bz2 |
Properties: Add CMAKE_ROLE global property
This property allows scripts to determine whether they're in project
mode, script mode, find-package mode, CTest, or CPack.
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r-- | Source/cmState.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f664000..cf170b0 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -539,6 +539,9 @@ const char* cmState::GetGlobalProperty(const std::string& prop) std::string langs; langs = cmJoin(this->EnabledLanguages, ";"); this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str()); + } else if (prop == "CMAKE_ROLE") { + std::string mode = this->GetModeString(); + this->SetGlobalProperty("CMAKE_ROLE", mode.c_str()); } #define STRING_LIST_ELEMENT(F) ";" #F if (prop == "CMAKE_C_KNOWN_FEATURES") { @@ -643,6 +646,40 @@ unsigned int cmState::GetCacheMinorVersion() const return this->CacheManager->GetCacheMinorVersion(); } +cmState::Mode cmState::GetMode() const +{ + return this->CurrentMode; +} + +std::string cmState::GetModeString() const +{ + return ModeToString(this->CurrentMode); +} + +void cmState::SetMode(cmState::Mode mode) +{ + this->CurrentMode = mode; +} + +std::string cmState::ModeToString(cmState::Mode mode) +{ + switch (mode) { + case Project: + return "PROJECT"; + case Script: + return "SCRIPT"; + case FindPackage: + return "FIND_PACKAGE"; + case CTest: + return "CTEST"; + case CPack: + return "CPACK"; + case Unknown: + return "UNKNOWN"; + } + return "UNKNOWN"; +} + std::string const& cmState::GetBinaryDirectory() const { return this->BinaryDirectory; |