diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-03-22 07:00:00 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2020-03-25 13:10:46 (GMT) |
commit | c84cf42897e4d95706d4f750c2ad085c84a259f2 (patch) | |
tree | 980169e295b16dbc56fe3577b48913fd4a9c2e8a /Source/cmState.cxx | |
parent | d13d5c11cf8b5878c5e63b067e73a2175f01d93f (diff) | |
download | CMake-c84cf42897e4d95706d4f750c2ad085c84a259f2.zip CMake-c84cf42897e4d95706d4f750c2ad085c84a259f2.tar.gz CMake-c84cf42897e4d95706d4f750c2ad085c84a259f2.tar.bz2 |
cmState::GetGlobalProperty: return cmProp
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r-- | Source/cmState.cxx | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx index b1fa772..1ba1d10 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -573,7 +573,7 @@ void cmState::AppendGlobalProperty(const std::string& prop, this->GlobalProperties.AppendProperty(prop, value, asString); } -const char* cmState::GetGlobalProperty(const std::string& prop) +cmProp cmState::GetGlobalProperty(const std::string& prop) { if (prop == "CACHE_VARIABLES") { std::vector<std::string> cacheKeys = this->GetCacheEntryKeys(); @@ -597,41 +597,59 @@ const char* cmState::GetGlobalProperty(const std::string& prop) } #define STRING_LIST_ELEMENT(F) ";" #F if (prop == "CMAKE_C_KNOWN_FEATURES") { - return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_C90_KNOWN_FEATURES") { - return &FOR_EACH_C90_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_C90_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_C99_KNOWN_FEATURES") { - return &FOR_EACH_C99_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_C99_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_C11_KNOWN_FEATURES") { - return &FOR_EACH_C11_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_C11_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_CXX_KNOWN_FEATURES") { - return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_CXX98_KNOWN_FEATURES") { - return &FOR_EACH_CXX98_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_CXX98_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_CXX11_KNOWN_FEATURES") { - return &FOR_EACH_CXX11_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_CXX11_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_CXX14_KNOWN_FEATURES") { - return &FOR_EACH_CXX14_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_CXX14_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } if (prop == "CMAKE_CUDA_KNOWN_FEATURES") { - return &FOR_EACH_CUDA_FEATURE(STRING_LIST_ELEMENT)[1]; + static const std::string s_out( + &FOR_EACH_CUDA_FEATURE(STRING_LIST_ELEMENT)[1]); + return &s_out; } #undef STRING_LIST_ELEMENT - cmProp retVal = this->GlobalProperties.GetPropertyValue(prop); - return retVal ? retVal->c_str() : nullptr; + return this->GlobalProperties.GetPropertyValue(prop); } bool cmState::GetGlobalPropertyAsBool(const std::string& prop) { - return cmIsOn(this->GetGlobalProperty(prop)); + cmProp p = this->GetGlobalProperty(prop); + return p && cmIsOn(*p); } void cmState::SetSourceDirectory(std::string const& sourceDirectory) |