diff options
158 files changed, 2693 insertions, 2441 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 71892ba..2b8c17c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -360,6 +360,11 @@ set(SRCS cmSourceGroup.h cmState.cxx cmState.h + cmStateDirectory.cxx + cmStateDirectory.h + cmStateSnapshot.cxx + cmStateSnapshot.h + cmStateTypes.h cmSystemTools.cxx cmSystemTools.h cmTarget.cxx diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f68167c..223e473 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 7) -set(CMake_VERSION_PATCH 20161019) +set(CMake_VERSION_PATCH 20161020) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index d9ac909..0098a4b 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -231,7 +231,7 @@ public: protected: void StartElement(const std::string& name, const char** /*atts*/) CM_OVERRIDE { - file = name == "file" ? true : false; + file = name == "file"; if (file) { hasFiles = true; } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index d4135ce..09b9c0d 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -8,7 +8,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmXMLSafe.h" #include "cm_auto_ptr.hxx" #include "cmake.h" diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index a3281ab..c305cbf 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -10,6 +10,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTypeMacro.h" #include "cm_auto_ptr.hxx" diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index e5c50b2..224681a 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -7,7 +7,7 @@ #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 8848a70..7ee0f75 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -22,6 +22,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" @@ -280,7 +281,7 @@ void cmCTestScriptHandler::CreateCMake() this->CMake->AddCMakePaths(); this->GlobalGenerator = new cmGlobalGenerator(this->CMake); - cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot(); + cmStateSnapshot snapshot = this->CMake->GetCurrentSnapshot(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); snapshot.GetDirectory().SetCurrentSource(cwd); snapshot.GetDirectory().SetCurrentBinary(cwd); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 06cd77f..d21471d 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -8,6 +8,7 @@ #include "cmCurl.h" #include "cmGeneratedFileStream.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmXMLParser.h" #include "cmake.h" diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 0d0237f..4e6f1e9 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -10,6 +10,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cm_auto_ptr.hxx" diff --git a/Source/CursesDialog/cmCursesBoolWidget.cxx b/Source/CursesDialog/cmCursesBoolWidget.cxx index 5268a5d..80a5b5b 100644 --- a/Source/CursesDialog/cmCursesBoolWidget.cxx +++ b/Source/CursesDialog/cmCursesBoolWidget.cxx @@ -3,7 +3,7 @@ #include "cmCursesBoolWidget.h" #include "cmCursesWidget.h" -#include "cmState.h" +#include "cmStateTypes.h" #include <string> @@ -11,7 +11,7 @@ cmCursesBoolWidget::cmCursesBoolWidget(int width, int height, int left, int top) : cmCursesWidget(width, height, left, top) { - this->Type = cmState::BOOL; + this->Type = cmStateEnums::BOOL; set_field_fore(this->Field, A_NORMAL); set_field_back(this->Field, A_STANDOUT); field_opts_off(this->Field, O_STATIC); diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 93785e0..5539fbe 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -10,6 +10,7 @@ #include "cmCursesStringWidget.h" #include "cmCursesWidget.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" @@ -47,7 +48,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( const char* value = cm->GetState()->GetCacheEntryValue(key); assert(value); switch (cm->GetState()->GetCacheEntryType(key)) { - case cmState::BOOL: + case cmStateEnums::BOOL: this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); if (cmSystemTools::IsOn(value)) { static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true); @@ -55,15 +56,15 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(false); } break; - case cmState::PATH: + case cmStateEnums::PATH: this->Entry = new cmCursesPathWidget(this->EntryWidth, 1, 1, 1); static_cast<cmCursesPathWidget*>(this->Entry)->SetString(value); break; - case cmState::FILEPATH: + case cmStateEnums::FILEPATH: this->Entry = new cmCursesFilePathWidget(this->EntryWidth, 1, 1, 1); static_cast<cmCursesFilePathWidget*>(this->Entry)->SetString(value); break; - case cmState::STRING: { + case cmStateEnums::STRING: { const char* stringsProp = cm->GetState()->GetCacheEntryProperty(key, "STRINGS"); if (stringsProp) { @@ -83,7 +84,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } break; } - case cmState::UNINITIALIZED: + case cmStateEnums::UNINITIALIZED: cmSystemTools::Error("Found an undefined variable: ", key.c_str()); break; default: diff --git a/Source/CursesDialog/cmCursesDummyWidget.cxx b/Source/CursesDialog/cmCursesDummyWidget.cxx index 61d07e2..da0478a 100644 --- a/Source/CursesDialog/cmCursesDummyWidget.cxx +++ b/Source/CursesDialog/cmCursesDummyWidget.cxx @@ -3,13 +3,13 @@ #include "cmCursesDummyWidget.h" #include "cmCursesWidget.h" -#include "cmState.h" +#include "cmStateTypes.h" cmCursesDummyWidget::cmCursesDummyWidget(int width, int height, int left, int top) : cmCursesWidget(width, height, left, top) { - this->Type = cmState::INTERNAL; + this->Type = cmStateEnums::INTERNAL; } bool cmCursesDummyWidget::HandleInput(int& /*key*/, cmCursesMainForm* /*fm*/, diff --git a/Source/CursesDialog/cmCursesFilePathWidget.cxx b/Source/CursesDialog/cmCursesFilePathWidget.cxx index 670c50f..518da4f 100644 --- a/Source/CursesDialog/cmCursesFilePathWidget.cxx +++ b/Source/CursesDialog/cmCursesFilePathWidget.cxx @@ -3,11 +3,11 @@ #include "cmCursesFilePathWidget.h" #include "cmCursesPathWidget.h" -#include "cmState.h" +#include "cmStateTypes.h" cmCursesFilePathWidget::cmCursesFilePathWidget(int width, int height, int left, int top) : cmCursesPathWidget(width, height, left, top) { - this->Type = cmState::FILEPATH; + this->Type = cmStateEnums::FILEPATH; } diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 0c3d29d..ebd35f3 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -12,6 +12,7 @@ #include "cmCursesStringWidget.h" #include "cmCursesWidget.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmVersion.h" #include "cmake.h" @@ -106,10 +107,10 @@ void cmCursesMainForm::InitializeUI() for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); it != cacheKeys.end(); ++it) { - cmState::CacheEntryType t = + cmStateEnums::CacheEntryType t = this->CMakeInstance->GetState()->GetCacheEntryType(*it); - if (t != cmState::INTERNAL && t != cmState::STATIC && - t != cmState::UNINITIALIZED) { + if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC && + t != cmStateEnums::UNINITIALIZED) { ++count; } } @@ -130,10 +131,10 @@ void cmCursesMainForm::InitializeUI() for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); it != cacheKeys.end(); ++it) { std::string key = *it; - cmState::CacheEntryType t = + cmStateEnums::CacheEntryType t = this->CMakeInstance->GetState()->GetCacheEntryType(*it); - if (t == cmState::INTERNAL || t == cmState::STATIC || - t == cmState::UNINITIALIZED) { + if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC || + t == cmStateEnums::UNINITIALIZED) { continue; } @@ -148,10 +149,10 @@ void cmCursesMainForm::InitializeUI() for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); it != cacheKeys.end(); ++it) { std::string key = *it; - cmState::CacheEntryType t = + cmStateEnums::CacheEntryType t = this->CMakeInstance->GetState()->GetCacheEntryType(*it); - if (t == cmState::INTERNAL || t == cmState::STATIC || - t == cmState::UNINITIALIZED) { + if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC || + t == cmStateEnums::UNINITIALIZED) { continue; } @@ -249,8 +250,9 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) cmCursesWidget* cw = reinterpret_cast<cmCursesWidget*>(field_userptr(currentField)); // If in edit mode, get out of it - if (cw->GetType() == cmState::STRING || cw->GetType() == cmState::PATH || - cw->GetType() == cmState::FILEPATH) { + if (cw->GetType() == cmStateEnums::STRING || + cw->GetType() == cmStateEnums::PATH || + cw->GetType() == cmStateEnums::FILEPATH) { cmCursesStringWidget* sw = static_cast<cmCursesStringWidget*>(cw); sw->SetInEdit(false); } @@ -704,7 +706,7 @@ void cmCursesMainForm::FillCacheManagerFromUI() std::string newValue = (*this->Entries)[i]->Entry->GetValue(); std::string fixedOldValue; std::string fixedNewValue; - cmState::CacheEntryType t = + cmStateEnums::CacheEntryType t = this->CMakeInstance->GetState()->GetCacheEntryType(cacheKey); this->FixValue(t, oldValue, fixedOldValue); this->FixValue(t, newValue, fixedNewValue); @@ -720,14 +722,14 @@ void cmCursesMainForm::FillCacheManagerFromUI() } } -void cmCursesMainForm::FixValue(cmState::CacheEntryType type, +void cmCursesMainForm::FixValue(cmStateEnums::CacheEntryType type, const std::string& in, std::string& out) const { out = in.substr(0, in.find_last_not_of(' ') + 1); - if (type == cmState::PATH || type == cmState::FILEPATH) { + if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) { cmSystemTools::ConvertToUnixSlashes(out); } - if (type == cmState::BOOL) { + if (type == cmStateEnums::BOOL) { if (cmSystemTools::IsOff(out.c_str())) { out = "OFF"; } else { diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 4bf452d..d891ea0 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -7,7 +7,7 @@ #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" -#include "cmState.h" +#include "cmStateTypes.h" #include <stddef.h> #include <string> @@ -110,7 +110,7 @@ protected: // cache. void FillCacheManagerFromUI(); // Fix formatting of values to a consistent form. - void FixValue(cmState::CacheEntryType type, const std::string& in, + void FixValue(cmStateEnums::CacheEntryType type, const std::string& in, std::string& out) const; // Re-post the existing fields. Used to toggle between // normal and advanced modes. Render() should be called diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx index e23a82d..d26a98f 100644 --- a/Source/CursesDialog/cmCursesOptionsWidget.cxx +++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx @@ -3,7 +3,7 @@ #include "cmCursesOptionsWidget.h" #include "cmCursesWidget.h" -#include "cmState.h" +#include "cmStateTypes.h" #define ctrl(z) ((z)&037) @@ -11,7 +11,7 @@ cmCursesOptionsWidget::cmCursesOptionsWidget(int width, int height, int left, int top) : cmCursesWidget(width, height, left, top) { - this->Type = cmState::BOOL; // this is a bit of a hack + this->Type = cmStateEnums::BOOL; // this is a bit of a hack // there is no option type, and string type causes ccmake to cast // the widget into a string widget at some point. BOOL is safe for // now. diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx index d208598..05c3279 100644 --- a/Source/CursesDialog/cmCursesPathWidget.cxx +++ b/Source/CursesDialog/cmCursesPathWidget.cxx @@ -4,7 +4,7 @@ #include "cmCursesMainForm.h" #include "cmCursesStringWidget.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include <vector> @@ -13,7 +13,7 @@ cmCursesPathWidget::cmCursesPathWidget(int width, int height, int left, int top) : cmCursesStringWidget(width, height, left, top) { - this->Type = cmState::PATH; + this->Type = cmStateEnums::PATH; this->Cycle = false; this->CurrentIndex = 0; } @@ -50,7 +50,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w) std::vector<std::string> dirs; cmSystemTools::SimpleGlob(glob, dirs, - (this->Type == cmState::PATH ? -1 : 0)); + (this->Type == cmStateEnums::PATH ? -1 : 0)); if (this->CurrentIndex < dirs.size()) { cstr = dirs[this->CurrentIndex]; } diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index f068f67..eabc642 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -6,7 +6,7 @@ #include "cmCursesMainForm.h" #include "cmCursesStandardIncludes.h" #include "cmCursesWidget.h" -#include "cmState.h" +#include "cmStateTypes.h" #include <stdio.h> #include <string.h> @@ -21,7 +21,7 @@ cmCursesStringWidget::cmCursesStringWidget(int width, int height, int left, : cmCursesWidget(width, height, left, top) { this->InEdit = false; - this->Type = cmState::STRING; + this->Type = cmStateEnums::STRING; set_field_fore(this->Field, A_NORMAL); set_field_back(this->Field, A_STANDOUT); field_opts_off(this->Field, O_STATIC); diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h index bb26cf6..d226dd7 100644 --- a/Source/CursesDialog/cmCursesWidget.h +++ b/Source/CursesDialog/cmCursesWidget.h @@ -6,7 +6,7 @@ #include <cmConfigure.h> // IWYU pragma: keep #include "cmCursesStandardIncludes.h" -#include "cmState.h" +#include "cmStateTypes.h" #include <string> @@ -41,7 +41,7 @@ public: /** * Get the type of the widget (STRING, PATH etc...) */ - cmState::CacheEntryType GetType() { return this->Type; } + cmStateEnums::CacheEntryType GetType() { return this->Type; } /** * If there are any, print the widget specific commands @@ -62,7 +62,7 @@ protected: cmCursesWidget(const cmCursesWidget& from); void operator=(const cmCursesWidget&); - cmState::CacheEntryType Type; + cmStateEnums::CacheEntryType Type; std::string Value; FIELD* Field; // The page in the main form this widget is in diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index cfb10f3..abeff97 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -196,8 +196,8 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) std::vector<std::string> cacheKeys = state->GetCacheEntryKeys(); for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); it != cacheKeys.end(); ++it) { - cmState::CacheEntryType t = state->GetCacheEntryType(*it); - if (t == cmState::INTERNAL || t == cmState::STATIC) { + cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*it); + if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC) { continue; } @@ -232,19 +232,19 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) if (s.Type == QCMakeProperty::BOOL) { this->CMakeInstance->AddCacheEntry( s.Key.toLocal8Bit().data(), s.Value.toBool() ? "ON" : "OFF", - s.Help.toLocal8Bit().data(), cmState::BOOL); + s.Help.toLocal8Bit().data(), cmStateEnums::BOOL); } else if (s.Type == QCMakeProperty::STRING) { this->CMakeInstance->AddCacheEntry( s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), - s.Help.toLocal8Bit().data(), cmState::STRING); + s.Help.toLocal8Bit().data(), cmStateEnums::STRING); } else if (s.Type == QCMakeProperty::PATH) { this->CMakeInstance->AddCacheEntry( s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), - s.Help.toLocal8Bit().data(), cmState::PATH); + s.Help.toLocal8Bit().data(), cmStateEnums::PATH); } else if (s.Type == QCMakeProperty::FILEPATH) { this->CMakeInstance->AddCacheEntry( s.Key.toLocal8Bit().data(), s.Value.toString().toLocal8Bit().data(), - s.Help.toLocal8Bit().data(), cmState::FILEPATH); + s.Help.toLocal8Bit().data(), cmStateEnums::FILEPATH); } } @@ -259,9 +259,9 @@ QCMakePropertyList QCMake::properties() const std::vector<std::string> cacheKeys = state->GetCacheEntryKeys(); for (std::vector<std::string>::const_iterator i = cacheKeys.begin(); i != cacheKeys.end(); ++i) { - cmState::CacheEntryType t = state->GetCacheEntryType(*i); - if (t == cmState::INTERNAL || t == cmState::STATIC || - t == cmState::UNINITIALIZED) { + cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*i); + if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC || + t == cmStateEnums::UNINITIALIZED) { continue; } @@ -273,14 +273,14 @@ QCMakePropertyList QCMake::properties() const QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING")); prop.Value = QString::fromLocal8Bit(cachedValue); prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED"); - if (t == cmState::BOOL) { + if (t == cmStateEnums::BOOL) { prop.Type = QCMakeProperty::BOOL; prop.Value = cmSystemTools::IsOn(cachedValue); - } else if (t == cmState::PATH) { + } else if (t == cmStateEnums::PATH) { prop.Type = QCMakeProperty::PATH; - } else if (t == cmState::FILEPATH) { + } else if (t == cmStateEnums::FILEPATH) { prop.Type = QCMakeProperty::FILEPATH; - } else if (t == cmState::STRING) { + } else if (t == cmStateEnums::STRING) { prop.Type = QCMakeProperty::STRING; const char* stringsProperty = state->GetCacheEntryProperty(*i, "STRINGS"); diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 96ad82a..a03d77d 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -133,8 +133,8 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args, this->SetError(e.str()); return false; } - cmState::TargetType type = aliasedTarget->GetType(); - if (type != cmState::EXECUTABLE) { + cmStateEnums::TargetType type = aliasedTarget->GetType(); + if (type != cmStateEnums::EXECUTABLE) { std::ostringstream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is not an " @@ -165,7 +165,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector<std::string> const& args, } // Create the imported target. - this->Makefile->AddImportedTarget(exename, cmState::EXECUTABLE, + this->Makefile->AddImportedTarget(exename, cmStateEnums::EXECUTABLE, importGlobal); return true; } diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 26e38b8..0777ef0 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -3,6 +3,7 @@ #include "cmAddLibraryCommand.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmake.h" // cmLibraryCommand @@ -15,10 +16,10 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, } // Library type defaults to value of BUILD_SHARED_LIBS, if it exists, // otherwise it defaults to static library. - cmState::TargetType type = cmState::SHARED_LIBRARY; + cmStateEnums::TargetType type = cmStateEnums::SHARED_LIBRARY; if (cmSystemTools::IsOff( this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { - type = cmState::STATIC_LIBRARY; + type = cmStateEnums::STATIC_LIBRARY; } bool excludeFromAll = false; bool importTarget = false; @@ -38,57 +39,57 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, while (s != args.end()) { std::string libType = *s; if (libType == "STATIC") { - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting STATIC type."; this->SetError(e.str()); return false; } ++s; - type = cmState::STATIC_LIBRARY; + type = cmStateEnums::STATIC_LIBRARY; haveSpecifiedType = true; } else if (libType == "SHARED") { - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting SHARED type."; this->SetError(e.str()); return false; } ++s; - type = cmState::SHARED_LIBRARY; + type = cmStateEnums::SHARED_LIBRARY; haveSpecifiedType = true; } else if (libType == "MODULE") { - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting MODULE type."; this->SetError(e.str()); return false; } ++s; - type = cmState::MODULE_LIBRARY; + type = cmStateEnums::MODULE_LIBRARY; haveSpecifiedType = true; } else if (libType == "OBJECT") { - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting OBJECT type."; this->SetError(e.str()); return false; } ++s; - type = cmState::OBJECT_LIBRARY; + type = cmStateEnums::OBJECT_LIBRARY; haveSpecifiedType = true; } else if (libType == "UNKNOWN") { - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting UNKNOWN type."; this->SetError(e.str()); return false; } ++s; - type = cmState::UNKNOWN_LIBRARY; + type = cmStateEnums::UNKNOWN_LIBRARY; haveSpecifiedType = true; } else if (libType == "ALIAS") { - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting ALIAS type."; this->SetError(e.str()); @@ -116,10 +117,10 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, return false; } ++s; - type = cmState::INTERFACE_LIBRARY; + type = cmStateEnums::INTERFACE_LIBRARY; haveSpecifiedType = true; } else if (*s == "EXCLUDE_FROM_ALL") { - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; this->SetError(e.str()); @@ -133,7 +134,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, } else if (importTarget && *s == "GLOBAL") { ++s; importGlobal = true; - } else if (type == cmState::INTERFACE_LIBRARY && *s == "GLOBAL") { + } else if (type == cmStateEnums::INTERFACE_LIBRARY && *s == "GLOBAL") { std::ostringstream e; e << "GLOBAL option may only be used with IMPORTED libraries."; this->SetError(e.str()); @@ -143,7 +144,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, } } - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { if (s != args.end()) { std::ostringstream e; e << "INTERFACE library requires no source arguments."; @@ -170,7 +171,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, bool issueMessage = false; switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0037)) { case cmPolicies::WARN: - if (type != cmState::INTERFACE_LIBRARY) { + if (type != cmStateEnums::INTERFACE_LIBRARY) { e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0037) << "\n"; issueMessage = true; } @@ -233,12 +234,12 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, this->SetError(e.str()); return false; } - cmState::TargetType aliasedType = aliasedTarget->GetType(); - if (aliasedType != cmState::SHARED_LIBRARY && - aliasedType != cmState::STATIC_LIBRARY && - aliasedType != cmState::MODULE_LIBRARY && - aliasedType != cmState::OBJECT_LIBRARY && - aliasedType != cmState::INTERFACE_LIBRARY) { + cmStateEnums::TargetType aliasedType = aliasedTarget->GetType(); + if (aliasedType != cmStateEnums::SHARED_LIBRARY && + aliasedType != cmStateEnums::STATIC_LIBRARY && + aliasedType != cmStateEnums::MODULE_LIBRARY && + aliasedType != cmStateEnums::OBJECT_LIBRARY && + aliasedType != cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is not a library."; @@ -265,16 +266,17 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to STATIC. But at this point we know only the name of the target, but not yet its linker language. */ - if ((type == cmState::SHARED_LIBRARY || type == cmState::MODULE_LIBRARY) && + if ((type == cmStateEnums::SHARED_LIBRARY || + type == cmStateEnums::MODULE_LIBRARY) && (this->Makefile->GetState()->GetGlobalPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { std::ostringstream w; w << "ADD_LIBRARY called with " - << (type == cmState::SHARED_LIBRARY ? "SHARED" : "MODULE") + << (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE") << " option but the target platform does not support dynamic linking. " "Building a STATIC library instead. This may lead to problems."; this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); - type = cmState::STATIC_LIBRARY; + type = cmStateEnums::STATIC_LIBRARY; } // Handle imported target creation. @@ -284,13 +286,13 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, this->SetError("called with IMPORTED argument but no library type."); return false; } - if (type == cmState::OBJECT_LIBRARY) { + if (type == cmStateEnums::OBJECT_LIBRARY) { this->Makefile->IssueMessage( cmake::FATAL_ERROR, "The OBJECT library type may not be used for IMPORTED libraries."); return true; } - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName)) { std::ostringstream e; e << "Invalid name for IMPORTED INTERFACE library target: " << libName; @@ -314,7 +316,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, } // A non-imported target may not have UNKNOWN type. - if (type == cmState::UNKNOWN_LIBRARY) { + if (type == cmStateEnums::UNKNOWN_LIBRARY) { this->Makefile->IssueMessage( cmake::FATAL_ERROR, "The UNKNOWN library type may be used only for IMPORTED libraries."); @@ -332,7 +334,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, std::vector<std::string> srclists; - if (type == cmState::INTERFACE_LIBRARY) { + if (type == cmStateEnums::INTERFACE_LIBRARY) { if (!cmGeneratorExpression::IsValidTargetName(libName) || libName.find("::") != std::string::npos) { std::ostringstream e; diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx index 365a426..8aa4102 100644 --- a/Source/cmBuildCommand.cxx +++ b/Source/cmBuildCommand.cxx @@ -116,6 +116,6 @@ bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args) this->Makefile->AddCacheDefinition(define, makecommand.c_str(), "Command used to build entire project " "from the command line.", - cmState::STRING); + cmStateEnums::STRING); return true; } diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx index 9134b9a..816147b 100644 --- a/Source/cmBuildNameCommand.cxx +++ b/Source/cmBuildNameCommand.cxx @@ -27,7 +27,7 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args, std::replace(cv.begin(), cv.end(), '(', '_'); std::replace(cv.begin(), cv.end(), ')', '_'); this->Makefile->AddCacheDefinition(args[0], cv.c_str(), "Name of build.", - cmState::STRING); + cmStateEnums::STRING); } return true; } @@ -53,6 +53,6 @@ bool cmBuildNameCommand::InitialPass(std::vector<std::string> const& args, std::replace(buildname.begin(), buildname.end(), ')', '_'); this->Makefile->AddCacheDefinition(args[0], buildname.c_str(), - "Name of build.", cmState::STRING); + "Name of build.", cmStateEnums::STRING); return true; } diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index eea76f2..67581b6 100644 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCMakePolicyCommand.h" +#include "cmState.h" #include "cmVersion.h" // cmCMakePolicyCommand @@ -79,7 +80,7 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args) "For backwards compatibility, what version of CMake " "commands and " "syntax should this version of CMake try to support.", - cmState::STRING); + cmStateEnums::STRING); } } return true; diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 56a469d..155456a 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -75,22 +75,22 @@ void CCONV cmAddCacheDefinition(void* arg, const char* name, const char* value, switch (type) { case CM_CACHE_BOOL: - mf->AddCacheDefinition(name, value, doc, cmState::BOOL); + mf->AddCacheDefinition(name, value, doc, cmStateEnums::BOOL); break; case CM_CACHE_PATH: - mf->AddCacheDefinition(name, value, doc, cmState::PATH); + mf->AddCacheDefinition(name, value, doc, cmStateEnums::PATH); break; case CM_CACHE_FILEPATH: - mf->AddCacheDefinition(name, value, doc, cmState::FILEPATH); + mf->AddCacheDefinition(name, value, doc, cmStateEnums::FILEPATH); break; case CM_CACHE_STRING: - mf->AddCacheDefinition(name, value, doc, cmState::STRING); + mf->AddCacheDefinition(name, value, doc, cmStateEnums::STRING); break; case CM_CACHE_INTERNAL: - mf->AddCacheDefinition(name, value, doc, cmState::INTERNAL); + mf->AddCacheDefinition(name, value, doc, cmStateEnums::INTERNAL); break; case CM_CACHE_STATIC: - mf->AddCacheDefinition(name, value, doc, cmState::STATIC); + mf->AddCacheDefinition(name, value, doc, cmStateEnums::STATIC); break; } } @@ -350,9 +350,9 @@ static void addLinkLibrary(cmMakefile* mf, std::string const& target, } cmTarget* tgt = mf->GetGlobalGenerator()->FindTarget(lib); - if (tgt && (tgt->GetType() != cmState::STATIC_LIBRARY) && - (tgt->GetType() != cmState::SHARED_LIBRARY) && - (tgt->GetType() != cmState::INTERFACE_LIBRARY) && + if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) && + (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) && + (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) && !tgt->IsExecutableWithExports()) { std::ostringstream e; e << "Target \"" << lib << "\" of type " @@ -393,8 +393,8 @@ void CCONV cmAddLibrary(void* arg, const char* libname, int shared, for (i = 0; i < numSrcs; ++i) { srcs2.push_back(srcs[i]); } - mf->AddLibrary(libname, - (shared ? cmState::SHARED_LIBRARY : cmState::STATIC_LIBRARY), + mf->AddLibrary(libname, (shared ? cmStateEnums::SHARED_LIBRARY + : cmStateEnums::STATIC_LIBRARY), srcs2); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 7dc9e33..024260c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -21,6 +21,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmVersion.h" #include "cmVersionConfig.h" @@ -1969,7 +1970,7 @@ bool cmCTest::AddVariableDefinition(const std::string& arg) { std::string name; std::string value; - cmState::CacheEntryType type = cmState::UNINITIALIZED; + cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED; if (cmake::ParseCacheEntry(arg, name, value, type)) { this->Definitions[name] = value; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 4b03499..e84012c 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -94,13 +94,13 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, // If the entry is not internal to the cache being loaded // or if it is in the list of internal entries to be // imported, load it. - if (internal || (e.Type != cmState::INTERNAL) || + if (internal || (e.Type != cmStateEnums::INTERNAL) || (includes.find(entryKey) != includes.end())) { // If we are loading the cache from another project, // make all loaded entries internal so that it is // not visible in the gui if (!internal) { - e.Type = cmState::INTERNAL; + e.Type = cmStateEnums::INTERNAL; helpString = "DO NOT EDIT, "; helpString += entryKey; helpString += " loaded from external file. " @@ -142,11 +142,11 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", "0", "Minor version of cmake used to create the " "current loaded cache", - cmState::INTERNAL); + cmStateEnums::INTERNAL); this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", "0", "Major version of cmake used to create the " "current loaded cache", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } // check to make sure the cache directory has not // been moved @@ -178,7 +178,7 @@ bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey, CacheEntry& e) { // All property entries are internal. - if (e.Type != cmState::INTERNAL) { + if (e.Type != cmStateEnums::INTERNAL) { return false; } @@ -192,7 +192,7 @@ bool cmCacheManager::ReadPropertyEntry(std::string const& entryKey, if (it.IsAtEnd()) { // Create an entry and store the property. CacheEntry& ne = this->Cache[key]; - ne.Type = cmState::UNINITIALIZED; + ne.Type = cmStateEnums::UNINITIALIZED; ne.SetProperty(*p, e.Value.c_str()); } else { // Store this property on its entry. @@ -244,17 +244,17 @@ bool cmCacheManager::SaveCache(const std::string& path) this->AddCacheEntry("CMAKE_CACHE_MINOR_VERSION", temp, "Minor version of cmake used to create the " "current loaded cache", - cmState::INTERNAL); + cmStateEnums::INTERNAL); sprintf(temp, "%d", cmVersion::GetMajorVersion()); this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp, "Major version of cmake used to create the " "current loaded cache", - cmState::INTERNAL); + cmStateEnums::INTERNAL); sprintf(temp, "%d", cmVersion::GetPatchVersion()); this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION", temp, "Patch version of cmake used to create the " "current loaded cache", - cmState::INTERNAL); + cmStateEnums::INTERNAL); // Let us store the current working directory so that if somebody // Copies it, he will not be surprised @@ -268,7 +268,7 @@ bool cmCacheManager::SaveCache(const std::string& path) this->AddCacheEntry("CMAKE_CACHEFILE_DIR", currentcwd.c_str(), "This is the directory where this CMakeCache.txt" " was created", - cmState::INTERNAL); + cmStateEnums::INTERNAL); /* clang-format off */ fout << "# This is the CMakeCache file.\n" @@ -301,14 +301,14 @@ bool cmCacheManager::SaveCache(const std::string& path) this->Cache.begin(); i != this->Cache.end(); ++i) { const CacheEntry& ce = (*i).second; - cmState::CacheEntryType t = ce.Type; + cmStateEnums::CacheEntryType t = ce.Type; if (!ce.Initialized) { /* // This should be added in, but is not for now. cmSystemTools::Error("Cache entry \"", (*i).first.c_str(), "\" is uninitialized"); */ - } else if (t != cmState::INTERNAL) { + } else if (t != cmStateEnums::INTERNAL) { // Format is key:type=value if (const char* help = ce.GetProperty("HELPSTRING")) { cmCacheManager::OutputHelpString(fout, help); @@ -334,9 +334,9 @@ bool cmCacheManager::SaveCache(const std::string& path) continue; } - cmState::CacheEntryType t = i.GetType(); + cmStateEnums::CacheEntryType t = i.GetType(); this->WritePropertyEntries(fout, i); - if (t == cmState::INTERNAL) { + if (t == cmStateEnums::INTERNAL) { // Format is key:type=value if (const char* help = i.GetProperty("HELPSTRING")) { this->OutputHelpString(fout, help); @@ -465,7 +465,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const for (std::map<std::string, CacheEntry>::const_iterator i = this->Cache.begin(); i != this->Cache.end(); ++i) { - if ((*i).second.Type != cmState::INTERNAL) { + if ((*i).second.Type != cmStateEnums::INTERNAL) { out << (*i).first << " = " << (*i).second.Value << std::endl; } } @@ -477,7 +477,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const void cmCacheManager::AddCacheEntry(const std::string& key, const char* value, const char* helpString, - cmState::CacheEntryType type) + cmStateEnums::CacheEntryType type) { CacheEntry& e = this->Cache[key]; if (value) { @@ -488,7 +488,7 @@ void cmCacheManager::AddCacheEntry(const std::string& key, const char* value, } e.Type = type; // make sure we only use unix style paths - if (type == cmState::FILEPATH || type == cmState::PATH) { + if (type == cmStateEnums::FILEPATH || type == cmStateEnums::PATH) { if (e.Value.find(';') != e.Value.npos) { std::vector<std::string> paths; cmSystemTools::ExpandListArgument(e.Value, paths); diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 16a2e78..90731f5 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -34,7 +34,7 @@ private: struct CacheEntry { std::string Value; - cmState::CacheEntryType Type; + cmStateEnums::CacheEntryType Type; cmPropertyMap Properties; std::vector<std::string> GetPropertyList() const; const char* GetProperty(const std::string&) const; @@ -44,7 +44,7 @@ private: bool Initialized; CacheEntry() : Value("") - , Type(cmState::UNINITIALIZED) + , Type(cmStateEnums::UNINITIALIZED) , Initialized(false) { } @@ -70,8 +70,14 @@ public: const char* GetValue() const { return this->GetEntry().Value.c_str(); } bool GetValueAsBool() const; void SetValue(const char*); - cmState::CacheEntryType GetType() const { return this->GetEntry().Type; } - void SetType(cmState::CacheEntryType ty) { this->GetEntry().Type = ty; } + cmStateEnums::CacheEntryType GetType() const + { + return this->GetEntry().Type; + } + void SetType(cmStateEnums::CacheEntryType ty) + { + this->GetEntry().Type = ty; + } bool Initialized() { return this->GetEntry().Initialized; } cmCacheManager& Container; std::map<std::string, CacheEntry>::iterator Position; @@ -137,7 +143,7 @@ public: return this->GetCacheIterator(key.c_str()).GetProperty(propName); } - cmState::CacheEntryType GetCacheEntryType(std::string const& key) + cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) { return this->GetCacheIterator(key.c_str()).GetType(); } @@ -200,7 +206,8 @@ public: protected: ///! Add an entry into the cache void AddCacheEntry(const std::string& key, const char* value, - const char* helpString, cmState::CacheEntryType type); + const char* helpString, + cmStateEnums::CacheEntryType type); ///! Get a cache entry object for a key CacheEntry* GetCacheEntry(const std::string& key); diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index b995fa1..95b95c1 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -17,7 +17,8 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateDirectory.h" +#include "cmStateTypes.h" cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt) : GeneratorTarget(gt) @@ -171,7 +172,7 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories() // We can ignore the INTERFACE_LIBRARY items because // Target->GetLinkInformation already processed their // link interface and they don't have any output themselves. - && linkee->GetType() != cmState::INTERFACE_LIBRARY && + && linkee->GetType() != cmStateEnums::INTERFACE_LIBRARY && emitted.insert(linkee).second) { cmLocalGenerator* lg = linkee->GetLocalGenerator(); std::string di = lg->GetCurrentBinaryDirectory(); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 93f3289..3e2cf18 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -8,7 +8,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmake.h" @@ -262,7 +262,7 @@ cmComputeLinkDepends::Compute() LinkEntry const& e = this->EntryList[i]; cmGeneratorTarget const* t = e.Target; // Entries that we know the linker will re-use do not need to be repeated. - bool uniquify = t && t->GetType() == cmState::SHARED_LIBRARY; + bool uniquify = t && t->GetType() == cmStateEnums::SHARED_LIBRARY; if (!uniquify || emmitted.insert(i).second) { this->FinalLinkEntries.push_back(e); } @@ -345,7 +345,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) if (cmLinkInterface const* iface = entry.Target->GetLinkInterface(this->Config, this->Target)) { const bool isIface = - entry.Target->GetType() == cmState::INTERFACE_LIBRARY; + entry.Target->GetType() == cmStateEnums::INTERFACE_LIBRARY; // This target provides its own link interface information. this->AddLinkEntries(depender_index, iface->Libraries); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0807ef8..28aa533 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -12,6 +12,7 @@ #include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmake.h" @@ -282,7 +283,7 @@ cmComputeLinkInformation::cmComputeLinkInformation( // the program that will load it. this->LoaderFlag = CM_NULLPTR; if (!this->UseImportLibrary && - this->Target->GetType() == cmState::MODULE_LIBRARY) { + this->Target->GetType() == cmStateEnums::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; loader_flag_var += "_FLAG"; @@ -299,10 +300,10 @@ cmComputeLinkInformation::cmComputeLinkInformation( // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if (this->Target->GetType() != cmState::STATIC_LIBRARY) { - const char* tType = - ((this->Target->GetType() == cmState::EXECUTABLE) ? "EXECUTABLE" - : "SHARED_LIBRARY"); + if (this->Target->GetType() != cmStateEnums::STATIC_LIBRARY) { + const char* tType = ((this->Target->GetType() == cmStateEnums::EXECUTABLE) + ? "EXECUTABLE" + : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; rtVar += "_RUNTIME_"; @@ -446,10 +447,10 @@ cmComputeLinkInformation::GetSharedLibrariesLinked() bool cmComputeLinkInformation::Compute() { // Skip targets that do not link. - if (!(this->Target->GetType() == cmState::EXECUTABLE || - this->Target->GetType() == cmState::SHARED_LIBRARY || - this->Target->GetType() == cmState::MODULE_LIBRARY || - this->Target->GetType() == cmState::STATIC_LIBRARY)) { + if (!(this->Target->GetType() == cmStateEnums::EXECUTABLE || + this->Target->GetType() == cmStateEnums::SHARED_LIBRARY || + this->Target->GetType() == cmStateEnums::MODULE_LIBRARY || + this->Target->GetType() == cmStateEnums::STATIC_LIBRARY)) { return false; } @@ -498,7 +499,7 @@ bool cmComputeLinkInformation::Compute() i != wrongItems.end(); ++i) { cmGeneratorTarget const* tgt = *i; bool implib = (this->UseImportLibrary && - (tgt->GetType() == cmState::SHARED_LIBRARY)); + (tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); std::string lib = tgt->GetFullPath(this->Config, implib, true); this->OldLinkDirItems.push_back(lib); } @@ -600,20 +601,21 @@ void cmComputeLinkInformation::AddItem(std::string const& item, linkItem += exe; this->Items.push_back(Item(linkItem, true, tgt)); this->Depends.push_back(exe); - } else if (tgt->GetType() == cmState::INTERFACE_LIBRARY) { + } else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // Add the interface library as an item so it can be considered as part // of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore // this for the actual link line. this->Items.push_back(Item(std::string(), false, tgt)); } else { // Decide whether to use an import library. - bool implib = (this->UseImportLibrary && - (impexe || tgt->GetType() == cmState::SHARED_LIBRARY)); + bool implib = + (this->UseImportLibrary && + (impexe || tgt->GetType() == cmStateEnums::SHARED_LIBRARY)); // Pass the full path to the target file. std::string lib = tgt->GetFullPath(config, implib, true); if (!this->LinkDependsNoShared || - tgt->GetType() != cmState::SHARED_LIBRARY) { + tgt->GetType() != cmStateEnums::SHARED_LIBRARY) { this->Depends.push_back(lib); } @@ -652,7 +654,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, if (tgt) { // The target will provide a full path. Make sure it is a shared // library. - if (tgt->GetType() != cmState::SHARED_LIBRARY) { + if (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) { return; } } else { @@ -725,13 +727,13 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() const char* shared_link_type_flag = CM_NULLPTR; const char* target_type_str = CM_NULLPTR; switch (this->Target->GetType()) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: target_type_str = "EXE"; break; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: target_type_str = "SHARED_LIBRARY"; break; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: target_type_str = "SHARED_MODULE"; break; default: @@ -964,12 +966,12 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item, // shared and static libraries but static-mode can handle only // static libraries. If a previous user item changed the link type // to static we need to make sure it is back to shared. - if (target->GetType() != cmState::STATIC_LIBRARY) { + if (target->GetType() != cmStateEnums::STATIC_LIBRARY) { this->SetCurrentLinkType(LinkShared); } // Keep track of shared library targets linked. - if (target->GetType() == cmState::SHARED_LIBRARY) { + if (target->GetType() == cmStateEnums::SHARED_LIBRARY) { this->SharedLibrariesLinked.insert(target); } @@ -1590,13 +1592,13 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo( // Libraries with unknown type must be handled using just the file // on disk. - if (target->GetType() == cmState::UNKNOWN_LIBRARY) { + if (target->GetType() == cmStateEnums::UNKNOWN_LIBRARY) { this->AddLibraryRuntimeInfo(fullPath); return; } // Skip targets that are not shared libraries (modules cannot be linked). - if (target->GetType() != cmState::SHARED_LIBRARY) { + if (target->GetType() != cmStateEnums::SHARED_LIBRARY) { return; } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 735bc32..cfebda2 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -11,6 +11,7 @@ #include "cmPolicies.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" @@ -187,7 +188,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { // Get the depender. cmGeneratorTarget const* depender = this->Targets[depender_index]; - if (depender->GetType() == cmState::INTERFACE_LIBRARY) { + if (depender->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return; } @@ -212,10 +213,10 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) oi != objectFiles.end(); ++oi) { std::string objLib = (*oi)->GetObjectLibrary(); if (!objLib.empty() && emitted.insert(objLib).second) { - if (depender->GetType() != cmState::EXECUTABLE && - depender->GetType() != cmState::STATIC_LIBRARY && - depender->GetType() != cmState::SHARED_LIBRARY && - depender->GetType() != cmState::MODULE_LIBRARY) { + if (depender->GetType() != cmStateEnums::EXECUTABLE && + depender->GetType() != cmStateEnums::STATIC_LIBRARY && + depender->GetType() != cmStateEnums::SHARED_LIBRARY && + depender->GetType() != cmStateEnums::MODULE_LIBRARY) { this->GlobalGenerator->GetCMakeInstance()->IssueMessage( cmake::FATAL_ERROR, "Only executables and non-OBJECT libraries may " @@ -287,7 +288,7 @@ void cmComputeTargetDepends::AddInterfaceDepends( // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable // within the project. - if (dependee && dependee->GetType() == cmState::EXECUTABLE && + if (dependee && dependee->GetType() == cmStateEnums::EXECUTABLE && !dependee->IsExecutableWithExports()) { dependee = CM_NULLPTR; } @@ -316,7 +317,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, cmGeneratorTarget const* dependee = dependee_name.Target; if (!dependee && !linking && - (depender->GetType() != cmState::GLOBAL_TARGET)) { + (depender->GetType() != cmStateEnums::GLOBAL_TARGET)) { cmake::MessageType messageType = cmake::AUTHOR_WARNING; bool issueMessage = false; std::ostringstream e; @@ -351,7 +352,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable // within the project. - if (linking && dependee && dependee->GetType() == cmState::EXECUTABLE && + if (linking && dependee && dependee->GetType() == cmStateEnums::EXECUTABLE && !dependee->IsExecutableWithExports()) { dependee = CM_NULLPTR; } @@ -366,7 +367,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, bool linking) { if (dependee->IsImported() || - dependee->GetType() == cmState::INTERFACE_LIBRARY) { + dependee->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // Skip IMPORTED and INTERFACE targets but follow their utility // dependencies. std::set<cmLinkItem> const& utils = dependee->GetUtilityItems(); @@ -452,7 +453,7 @@ bool cmComputeTargetDepends::CheckComponents( // Make sure the component is all STATIC_LIBRARY targets. for (NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { - if (this->Targets[*ni]->GetType() != cmState::STATIC_LIBRARY) { + if (this->Targets[*ni]->GetType() != cmStateEnums::STATIC_LIBRARY) { this->ComplainAboutBadComponent(ccg, c); return false; } diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 420a777..4c0b649 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -4,6 +4,7 @@ #include "cmAlgorithms.h" #include "cmOutputConverter.h" +#include "cmState.h" #include "cmSystemTools.h" static std::string const keyAND = "AND"; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index a409d40..c7b6d58 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -6,6 +6,7 @@ #include "cmExportTryCompileFileGenerator.h" #include "cmGlobalGenerator.h" #include "cmOutputConverter.h" +#include "cmState.h" #include "cmake.h" #include <cmsys/Directory.hxx> @@ -43,24 +44,25 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, // which signature were we called with ? this->SrcFileSignature = true; - cmState::TargetType targetType = cmState::EXECUTABLE; + cmStateEnums::TargetType targetType = cmStateEnums::EXECUTABLE; const char* tt = this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_TARGET_TYPE"); if (!isTryRun && tt && *tt) { - if (strcmp(tt, cmState::GetTargetTypeName(cmState::EXECUTABLE)) == 0) { - targetType = cmState::EXECUTABLE; + if (strcmp(tt, cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE)) == + 0) { + targetType = cmStateEnums::EXECUTABLE; } else if (strcmp(tt, cmState::GetTargetTypeName( - cmState::STATIC_LIBRARY)) == 0) { - targetType = cmState::STATIC_LIBRARY; + cmStateEnums::STATIC_LIBRARY)) == 0) { + targetType = cmStateEnums::STATIC_LIBRARY; } else { this->Makefile->IssueMessage( cmake::FATAL_ERROR, std::string("Invalid value '") + tt + "' for " "CMAKE_TRY_COMPILE_TARGET_TYPE. Only " "'" + - cmState::GetTargetTypeName(cmState::EXECUTABLE) + "' and " - "'" + - cmState::GetTargetTypeName(cmState::STATIC_LIBRARY) + + cmState::GetTargetTypeName(cmStateEnums::EXECUTABLE) + "' and " + "'" + + cmState::GetTargetTypeName(cmStateEnums::STATIC_LIBRARY) + "' " "are allowed."); return -1; @@ -122,12 +124,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" "; if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) { switch (tgt->GetType()) { - case cmState::SHARED_LIBRARY: - case cmState::STATIC_LIBRARY: - case cmState::INTERFACE_LIBRARY: - case cmState::UNKNOWN_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: break; - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: if (tgt->IsExecutableWithExports()) { break; } @@ -481,13 +483,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, ? "NEW" : "OLD"); - if (targetType == cmState::EXECUTABLE) { + if (targetType == cmStateEnums::EXECUTABLE) { /* Put the executable at a known location (for COPY_FILE). */ fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", this->BinaryDirectory.c_str()); /* Create the actual executable. */ fprintf(fout, "add_executable(%s", targetName.c_str()); - } else // if (targetType == cmState::STATIC_LIBRARY) + } else // if (targetType == cmStateEnums::STATIC_LIBRARY) { /* Put the static library at a known location (for COPY_FILE). */ fprintf(fout, "set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY \"%s\")\n", @@ -530,7 +532,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, // set the result var to the return value to indicate success or failure this->Makefile->AddCacheDefinition(argv[0], (res == 0 ? "TRUE" : "FALSE"), "Result of TRY_COMPILE", - cmState::INTERNAL); + cmStateEnums::INTERNAL); if (!outputVariable.empty()) { this->Makefile->AddDefinition(outputVariable, output.c_str()); @@ -627,16 +629,16 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) } void cmCoreTryCompile::FindOutputFile(const std::string& targetName, - cmState::TargetType targetType) + cmStateEnums::TargetType targetType) { this->FindErrorMessage = ""; this->OutputFile = ""; std::string tmpOutputFile = "/"; - if (targetType == cmState::EXECUTABLE) { + if (targetType == cmStateEnums::EXECUTABLE) { tmpOutputFile += targetName; tmpOutputFile += this->Makefile->GetSafeDefinition("CMAKE_EXECUTABLE_SUFFIX"); - } else // if (targetType == cmState::STATIC_LIBRARY) + } else // if (targetType == cmStateEnums::STATIC_LIBRARY) { tmpOutputFile += this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"); diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index e173a16..43b971f 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -35,7 +35,7 @@ protected: the error message is stored in FindErrorMessage. */ void FindOutputFile(const std::string& targetName, - cmState::TargetType targetType); + cmStateEnums::TargetType targetType); cmTypeMacro(cmCoreTryCompile, cmCommand); diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 0fd4ffb..2125f1b 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -9,7 +9,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmOutputConverter.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" @@ -42,7 +42,7 @@ bool cmCustomCommandGenerator::UseCrossCompilingEmulator(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0); - if (target && target->GetType() == cmState::EXECUTABLE) { + if (target && target->GetType() == cmStateEnums::EXECUTABLE) { return target->GetProperty("CROSSCOMPILING_EMULATOR") != CM_NULLPTR; } return false; @@ -52,12 +52,12 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(argv0); - if (target && target->GetType() == cmState::EXECUTABLE && + if (target && target->GetType() == cmStateEnums::EXECUTABLE && (target->IsImported() || !this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING"))) { return target->GetLocation(this->Config); } - if (target && target->GetType() == cmState::EXECUTABLE) { + if (target && target->GetType() == cmStateEnums::EXECUTABLE) { const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); if (emulator) { return std::string(emulator); diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx index 8800363..af4eff9 100644 --- a/Source/cmDefinePropertyCommand.cxx +++ b/Source/cmDefinePropertyCommand.cxx @@ -3,6 +3,7 @@ #include "cmDefinePropertyCommand.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmake.h" bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args, diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index aaa9d3a..c8723d0 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -7,6 +7,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmOutputConverter.h" +#include "cmStateDirectory.h" #include "cmSystemTools.h" #include <assert.h> diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx index f5e6628..38f95d2 100644 --- a/Source/cmExportBuildAndroidMKGenerator.cxx +++ b/Source/cmExportBuildAndroidMKGenerator.cxx @@ -111,8 +111,8 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( target->GetLocalGenerator()->FindGeneratorTargetToUse(*i); if (gt) { - if (gt->GetType() == cmState::SHARED_LIBRARY || - gt->GetType() == cmState::MODULE_LIBRARY) { + if (gt->GetType() == cmStateEnums::SHARED_LIBRARY || + gt->GetType() == cmStateEnums::MODULE_LIBRARY) { sharedLibs += " " + *i; } else { staticLibs += " " + *i; @@ -168,7 +168,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( } // Tell the NDK build system if prebuilt static libraries use C++. - if (target->GetType() == cmState::STATIC_LIBRARY) { + if (target->GetType() == cmStateEnums::STATIC_LIBRARY) { cmLinkImplementation const* li = target->GetLinkImplementation(config); if (std::find(li->Languages.begin(), li->Languages.end(), "CXX") != li->Languages.end()) { @@ -177,19 +177,19 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( } switch (target->GetType()) { - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: os << "include $(PREBUILT_SHARED_LIBRARY)\n"; break; - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: os << "include $(PREBUILT_STATIC_LIBRARY)\n"; break; - case cmState::EXECUTABLE: - case cmState::UTILITY: - case cmState::OBJECT_LIBRARY: - case cmState::GLOBAL_TARGET: - case cmState::INTERFACE_LIBRARY: - case cmState::UNKNOWN_LIBRARY: + case cmStateEnums::EXECUTABLE: + case cmStateEnums::UTILITY: + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::INTERFACE_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: break; } os << "\n"; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 68831c7..0c25268 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -9,7 +9,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmPolicies.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetExport.h" @@ -57,7 +57,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->LG->GetMakefile()->GetBacktrace()); return false; } - if (te->GetType() == cmState::INTERFACE_LIBRARY) { + if (te->GetType() == cmStateEnums::INTERFACE_LIBRARY) { this->GenerateRequiredCMakeVersion(os, "3.0.0"); } } @@ -134,12 +134,12 @@ void cmExportBuildFileGenerator::GenerateImportTargetsConfig( cmGeneratorTarget* target = *tei; ImportPropertyMap properties; - if (target->GetType() != cmState::INTERFACE_LIBRARY) { + if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { this->SetImportLocationProperty(config, suffix, target, properties); } if (!properties.empty()) { // Get the rest of the target details. - if (target->GetType() != cmState::INTERFACE_LIBRARY) { + if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { this->SetImportDetailProperties(config, suffix, target, properties, missingTargets); this->SetImportLinkInterface(config, suffix, @@ -186,7 +186,7 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( // Add the import library for windows DLLs. if (target->IsDLLPlatform() && - (target->GetType() == cmState::SHARED_LIBRARY || + (target->GetType() == cmStateEnums::SHARED_LIBRARY || target->IsExecutableWithExports()) && mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { std::string prop = "IMPORTED_IMPLIB"; diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index d438363..4fb5998 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -141,14 +141,14 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args, } if (cmTarget* target = gg->FindTarget(*currentTarget)) { - if (target->GetType() == cmState::OBJECT_LIBRARY) { + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "given OBJECT library \"" << *currentTarget << "\" which may not be exported."; this->SetError(e.str()); return false; } - if (target->GetType() == cmState::UTILITY) { + if (target->GetType() == cmStateEnums::UTILITY) { this->SetError("given custom target \"" + *currentTarget + "\" which may not be exported."); return false; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index d3a99fa..6c21eaf 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -11,7 +11,7 @@ #include "cmMakefile.h" #include "cmOutputConverter.h" #include "cmPolicies.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetExport.h" @@ -492,7 +492,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( getPropertyContents(gtarget, "COMPATIBLE_INTERFACE_NUMBER_MAX", ifaceProperties); - if (gtarget->GetType() != cmState::INTERFACE_LIBRARY) { + if (gtarget->GetType() != cmStateEnums::INTERFACE_LIBRARY) { getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector<std::string> configNames; @@ -735,8 +735,8 @@ void cmExportFileGenerator::SetImportDetailProperties( cmMakefile* mf = target->Makefile; // Add the soname for unix shared libraries. - if (target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY) { + if (target->GetType() == cmStateEnums::SHARED_LIBRARY || + target->GetType() == cmStateEnums::MODULE_LIBRARY) { if (!target->IsDLLPlatform()) { std::string prop; std::string value; @@ -912,22 +912,22 @@ void cmExportFileGenerator::GenerateImportTargetCode( // Create the imported target. os << "# Create imported target " << targetName << "\n"; switch (target->GetType()) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: os << "add_executable(" << targetName << " IMPORTED)\n"; break; - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: os << "add_library(" << targetName << " STATIC IMPORTED)\n"; break; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: os << "add_library(" << targetName << " SHARED IMPORTED)\n"; break; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: os << "add_library(" << targetName << " MODULE IMPORTED)\n"; break; - case cmState::UNKNOWN_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: os << "add_library(" << targetName << " UNKNOWN IMPORTED)\n"; break; - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: os << "add_library(" << targetName << " INTERFACE IMPORTED)\n"; break; default: // should never happen diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx index 58b7510..f9f5f3a 100644 --- a/Source/cmExportInstallAndroidMKGenerator.cxx +++ b/Source/cmExportInstallAndroidMKGenerator.cxx @@ -38,7 +38,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode( tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) { // Collect import properties for this target. cmTargetExport const* te = *tei; - if (te->Target->GetType() == cmState::INTERFACE_LIBRARY) { + if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } std::string dest; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 0e043de..64ea3c8 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -14,7 +14,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmPolicies.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetExport.h" @@ -81,7 +81,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorTarget* gt = (*tei)->Target; requiresConfigFiles = - requiresConfigFiles || gt->GetType() != cmState::INTERFACE_LIBRARY; + requiresConfigFiles || gt->GetType() != cmStateEnums::INTERFACE_LIBRARY; this->GenerateImportTargetCode(os, gt); @@ -120,7 +120,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) require2_8_12 = true; } } - if (gt->GetType() == cmState::INTERFACE_LIBRARY) { + if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { require3_0_0 = true; } if (gt->GetProperty("INTERFACE_SOURCES")) { @@ -316,7 +316,7 @@ void cmExportInstallFileGenerator::GenerateImportTargetsConfig( tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) { // Collect import properties for this target. cmTargetExport const* te = *tei; - if (te->Target->GetType() == cmState::INTERFACE_LIBRARY) { + if (te->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx index f80980a..66b77a6 100644 --- a/Source/cmExportLibraryDependenciesCommand.cxx +++ b/Source/cmExportLibraryDependenciesCommand.cxx @@ -79,8 +79,8 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const cmTarget const& target = l->second; // Skip non-library targets. - if (target.GetType() < cmState::STATIC_LIBRARY || - target.GetType() > cmState::MODULE_LIBRARY) { + if (target.GetType() < cmStateEnums::STATIC_LIBRARY || + target.GetType() > cmStateEnums::MODULE_LIBRARY) { continue; } diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 9fc71f6..cd0a7e6 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -8,7 +8,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cm_auto_ptr.hxx" @@ -67,7 +67,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets( CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop); - cmTarget dummyHead("try_compile_dummy_exe", cmState::EXECUTABLE, + cmTarget dummyHead("try_compile_dummy_exe", cmStateEnums::EXECUTABLE, cmTarget::VisibilityNormal, tgt->Target->GetMakefile()); cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator()); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 18c732d..41fc428 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -9,7 +9,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -302,7 +302,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { - case cmState::GLOBAL_TARGET: { + case cmStateEnums::GLOBAL_TARGET: { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (strcmp((*lg)->GetCurrentBinaryDirectory(), @@ -311,7 +311,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( compiler.c_str(), makeArgs); } } break; - case cmState::UTILITY: + case cmStateEnums::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((targetName.find("Nightly") == 0) && @@ -326,11 +326,11 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( this->AppendTarget(xml, targetName, CM_NULLPTR, make.c_str(), *lg, compiler.c_str(), makeArgs); break; - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: { cmGeneratorTarget* gt = *ti; this->AppendTarget(xml, targetName, gt, make.c_str(), *lg, compiler.c_str(), makeArgs); @@ -364,12 +364,12 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); ti != targets.end(); ti++) { switch ((*ti)->GetType()) { - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: - case cmState::UTILITY: // can have sources since 2.6.3 + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::UTILITY: // can have sources since 2.6.3 { std::vector<cmSourceFile*> sources; cmGeneratorTarget* gt = *ti; @@ -379,7 +379,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( si != sources.end(); si++) { // don't add source files from UTILITY target which have the // GENERATED property set: - if (gt->GetType() == cmState::UTILITY && + if (gt->GetType() == cmStateEnums::UTILITY && (*si)->GetPropertyAsBool("GENERATED")) { continue; } @@ -519,7 +519,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget( if (target != CM_NULLPTR) { int cbTargetType = this->GetCBTargetType(target); std::string workingDir = lg->GetCurrentBinaryDirectory(); - if (target->GetType() == cmState::EXECUTABLE) { + if (target->GetType() == cmStateEnums::EXECUTABLE) { // Determine the directory where the executable target is created, and // set the working directory to this dir. const char* runtimeOutputDir = @@ -537,7 +537,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget( std::string buildType = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::string location; - if (target->GetType() == cmState::OBJECT_LIBRARY) { + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { location = this->CreateDummyTargetFile(const_cast<cmLocalGenerator*>(lg), target); } else { @@ -713,17 +713,17 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) int cmExtraCodeBlocksGenerator::GetCBTargetType(cmGeneratorTarget* target) { switch (target->GetType()) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: if ((target->GetPropertyAsBool("WIN32_EXECUTABLE")) || (target->GetPropertyAsBool("MACOSX_BUNDLE"))) { return 0; } return 1; - case cmState::STATIC_LIBRARY: - case cmState::OBJECT_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: return 2; - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: return 3; default: return 4; diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 360c852..e79f763 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -8,7 +8,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -127,7 +127,7 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget( for (std::vector<cmGeneratorTarget*>::const_iterator lt = (*lg)->GetGeneratorTargets().begin(); lt != (*lg)->GetGeneratorTargets().end(); lt++) { - cmState::TargetType type = (*lt)->GetType(); + cmStateEnums::TargetType type = (*lt)->GetType(); std::string outputDir = (*lg)->GetCurrentBinaryDirectory(); std::string filename = outputDir + "/" + (*lt)->GetName() + ".project"; retval.push_back((*lt)->GetName()); @@ -136,11 +136,11 @@ std::vector<std::string> cmExtraCodeLiteGenerator::CreateProjectsByTarget( this->WorkspacePath.c_str(), filename.c_str()); std::string visualname = (*lt)->GetName(); switch (type) { - case cmState::SHARED_LIBRARY: - case cmState::STATIC_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: visualname = "lib" + visualname; - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: xml->StartElement("Project"); xml->Attribute("Name", visualname); xml->Attribute("Path", relafilename); @@ -209,16 +209,16 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles( std::string projectType; switch (gt->GetType()) { - case cmState::EXECUTABLE: { + case cmStateEnums::EXECUTABLE: { projectType = "Executable"; } break; - case cmState::STATIC_LIBRARY: { + case cmStateEnums::STATIC_LIBRARY: { projectType = "Static Library"; } break; - case cmState::SHARED_LIBRARY: { + case cmStateEnums::SHARED_LIBRARY: { projectType = "Dynamic Library"; } break; - case cmState::MODULE_LIBRARY: { + case cmStateEnums::MODULE_LIBRARY: { projectType = "Dynamic Library"; } break; default: // intended fallthrough @@ -226,10 +226,10 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles( } switch (gt->GetType()) { - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: { std::vector<cmSourceFile*> sources; gt->GetSourceFiles(sources, makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); @@ -430,17 +430,19 @@ void cmExtraCodeLiteGenerator::CreateProjectSourceEntries( xml.StartElement("General"); std::string outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - if (!outputPath.empty()) + if (!outputPath.empty()) { xml.Attribute("OutputFile", outputPath + "/$(ProjectName)"); - else + } else { xml.Attribute("OutputFile", "$(IntermediateDirectory)/$(ProjectName)"); + } xml.Attribute("IntermediateDirectory", "./"); xml.Attribute("Command", "./$(ProjectName)"); xml.Attribute("CommandArguments", ""); - if (!outputPath.empty()) + if (!outputPath.empty()) { xml.Attribute("WorkingDirectory", outputPath); - else + } else { xml.Attribute("WorkingDirectory", "$(IntermediateDirectory)"); + } xml.Attribute("PauseExecWhenProcTerminates", "yes"); xml.EndElement(); // General @@ -511,9 +513,9 @@ void cmExtraCodeLiteGenerator::CreateNewProjectFile( xml.StartElement("CodeLite_Project"); std::string visualname = gt->GetName(); switch (gt->GetType()) { - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: visualname = "lib" + visualname; default: // intended fallthrough break; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index e342f4c..c4e86a9 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -12,6 +12,7 @@ #include "cmSourceFile.h" #include "cmSourceGroup.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -230,7 +231,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, // in the cache valueToUse = envVarValue; mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), - cacheEntryName.c_str(), cmState::STRING, true); + cacheEntryName.c_str(), cmStateEnums::STRING, true); mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); } else if (!envVarSet && cacheValue != CM_NULLPTR) { // It is already in the cache, but not in the env, so use it from the cache @@ -245,7 +246,8 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, if (valueToUse.find(envVarValue) == std::string::npos) { valueToUse = envVarValue; mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), - cacheEntryName.c_str(), cmState::STRING, true); + cacheEntryName.c_str(), cmStateEnums::STRING, + true); mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); } } @@ -482,13 +484,14 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(cmXMLWriter& xml) std::string linkName2 = linkName; linkName2 += "/"; switch ((*ti)->GetType()) { - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: { const char* prefix = - ((*ti)->GetType() == cmState::EXECUTABLE ? "[exe] " : "[lib] "); + ((*ti)->GetType() == cmStateEnums::EXECUTABLE ? "[exe] " + : "[lib] "); linkName2 += prefix; linkName2 += (*ti)->GetName(); this->AppendLinkedResource(xml, linkName2, "virtual:/virtual", @@ -912,14 +915,14 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const ti != targets.end(); ++ti) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { - case cmState::GLOBAL_TARGET: { + case cmStateEnums::GLOBAL_TARGET: { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (subdir.empty()) { this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": "); } } break; - case cmState::UTILITY: + case cmStateEnums::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((targetName.find("Nightly") == 0) && @@ -933,13 +936,14 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const this->AppendTarget(xml, targetName, make, makeArgs, subdir, ": "); break; - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: { const char* prefix = - ((*ti)->GetType() == cmState::EXECUTABLE ? "[exe] " : "[lib] "); + ((*ti)->GetType() == cmStateEnums::EXECUTABLE ? "[exe] " + : "[lib] "); this->AppendTarget(xml, targetName, make, makeArgs, subdir, prefix); std::string fastTarget = targetName; fastTarget += "/fast"; diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index b78d09a..3730433 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -8,7 +8,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include <ostream> @@ -124,7 +124,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, ti != targets.end(); ++ti) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { - case cmState::GLOBAL_TARGET: { + case cmStateEnums::GLOBAL_TARGET: { bool insertTarget = false; // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs @@ -147,7 +147,7 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, homeOutputDir); } } break; - case cmState::UTILITY: + case cmStateEnums::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((targetName.find("Nightly") == 0) && @@ -162,11 +162,11 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, this->AppendTarget(fout, targetName, make, makeArgs, currentDir, homeOutputDir); break; - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: { this->AppendTarget(fout, targetName, make, makeArgs, currentDir, homeOutputDir); std::string fastTarget = targetName; diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 41f82a2..5d35f13 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -8,7 +8,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include <cmsys/RegularExpression.hxx> @@ -156,7 +156,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( ti != targets.end(); ti++) { std::string targetName = (*ti)->GetName(); switch ((*ti)->GetType()) { - case cmState::GLOBAL_TARGET: { + case cmStateEnums::GLOBAL_TARGET: { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs if (strcmp((*lg)->GetCurrentBinaryDirectory(), @@ -166,7 +166,7 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( false); } } break; - case cmState::UTILITY: + case cmStateEnums::UTILITY: // Add all utility targets, except the Nightly/Continuous/ // Experimental-"sub"targets as e.g. NightlyStart if (((targetName.find("Nightly") == 0) && @@ -182,11 +182,11 @@ void cmExtraSublimeTextGenerator::AppendAllTargets( makefile, compiler.c_str(), sourceFileFlags, false); break; - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: { this->AppendTarget(fout, targetName, *lg, *ti, make.c_str(), makefile, compiler.c_str(), sourceFileFlags, false); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index a71ff71..8dd204b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -115,41 +115,59 @@ bool cmFileCommand::InitialPass(std::vector<std::string> const& args, } if (subCommand == "STRINGS") { return this->HandleStringsCommand(args); - } else if (subCommand == "GLOB") { + } + if (subCommand == "GLOB") { return this->HandleGlobCommand(args, false); - } else if (subCommand == "GLOB_RECURSE") { + } + if (subCommand == "GLOB_RECURSE") { return this->HandleGlobCommand(args, true); - } else if (subCommand == "MAKE_DIRECTORY") { + } + if (subCommand == "MAKE_DIRECTORY") { return this->HandleMakeDirectoryCommand(args); - } else if (subCommand == "RENAME") { + } + if (subCommand == "RENAME") { return this->HandleRename(args); - } else if (subCommand == "REMOVE") { + } + if (subCommand == "REMOVE") { return this->HandleRemove(args, false); - } else if (subCommand == "REMOVE_RECURSE") { + } + if (subCommand == "REMOVE_RECURSE") { return this->HandleRemove(args, true); - } else if (subCommand == "COPY") { + } + if (subCommand == "COPY") { return this->HandleCopyCommand(args); - } else if (subCommand == "INSTALL") { + } + if (subCommand == "INSTALL") { return this->HandleInstallCommand(args); - } else if (subCommand == "DIFFERENT") { + } + if (subCommand == "DIFFERENT") { return this->HandleDifferentCommand(args); - } else if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") { + } + if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") { return this->HandleRPathChangeCommand(args); - } else if (subCommand == "RPATH_CHECK") { + } + if (subCommand == "RPATH_CHECK") { return this->HandleRPathCheckCommand(args); - } else if (subCommand == "RPATH_REMOVE") { + } + if (subCommand == "RPATH_REMOVE") { return this->HandleRPathRemoveCommand(args); - } else if (subCommand == "RELATIVE_PATH") { + } + if (subCommand == "RELATIVE_PATH") { return this->HandleRelativePathCommand(args); - } else if (subCommand == "TO_CMAKE_PATH") { + } + if (subCommand == "TO_CMAKE_PATH") { return this->HandleCMakePathCommand(args, false); - } else if (subCommand == "TO_NATIVE_PATH") { + } + if (subCommand == "TO_NATIVE_PATH") { return this->HandleCMakePathCommand(args, true); - } else if (subCommand == "TIMESTAMP") { + } + if (subCommand == "TIMESTAMP") { return this->HandleTimestampCommand(args); - } else if (subCommand == "GENERATE") { + } + if (subCommand == "GENERATE") { return this->HandleGenerateCommand(args); - } else if (subCommand == "LOCK") { + } + if (subCommand == "LOCK") { return this->HandleLockCommand(args); } diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx index 41ec8b4..b55341b 100644 --- a/Source/cmFileMonitor.cxx +++ b/Source/cmFileMonitor.cxx @@ -36,7 +36,7 @@ public: class cmVirtualDirectoryWatcher : public cmIBaseWatcher { public: - ~cmVirtualDirectoryWatcher() + ~cmVirtualDirectoryWatcher() override { for (auto i : this->Children) { delete i.second; @@ -156,7 +156,7 @@ public: p->AddChildWatcher(ps, this); } - ~cmRealDirectoryWatcher() + ~cmRealDirectoryWatcher() override { // Handle is freed via uv_handle_close callback! } diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 982d740..ff822b8 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -4,6 +4,7 @@ #include "cmAlgorithms.h" #include "cmState.h" +#include "cmStateTypes.h" cmFindBase::cmFindBase() { @@ -308,7 +309,7 @@ bool cmFindBase::CheckForVariableInCache() // this. if (cached && state->GetCacheEntryType(this->VariableName) == - cmState::UNINITIALIZED) { + cmStateEnums::UNINITIALIZED) { this->AlreadyInCacheWithoutMetaInfo = true; } return true; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 082350f..5d8aaa2 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFindLibraryCommand.h" +#include "cmState.h" #include <cmsys/Directory.hxx> cmFindLibraryCommand::cmFindLibraryCommand() @@ -26,7 +27,7 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn, if (this->AlreadyInCacheWithoutMetaInfo) { this->Makefile->AddCacheDefinition(this->VariableName, "", this->VariableDocumentation.c_str(), - cmState::FILEPATH); + cmStateEnums::FILEPATH); } return true; } @@ -52,13 +53,13 @@ bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn, // Save the value in the cache this->Makefile->AddCacheDefinition(this->VariableName, library.c_str(), this->VariableDocumentation.c_str(), - cmState::FILEPATH); + cmStateEnums::FILEPATH); return true; } std::string notfound = this->VariableName + "-NOTFOUND"; this->Makefile->AddCacheDefinition(this->VariableName, notfound.c_str(), this->VariableDocumentation.c_str(), - cmState::FILEPATH); + cmStateEnums::FILEPATH); return true; } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 554618e..029d422 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -3,6 +3,7 @@ #include "cmFindPackageCommand.h" #include "cmAlgorithms.h" +#include "cmState.h" #include <cmSystemTools.h> #include <cmsys/Directory.hxx> #include <cmsys/Encoding.hxx> @@ -890,7 +891,7 @@ bool cmFindPackageCommand::FindConfig() help += "."; // We force the value since we do not get here if it was already set. this->Makefile->AddCacheDefinition(this->Variable, init.c_str(), - help.c_str(), cmState::PATH, true); + help.c_str(), cmStateEnums::PATH, true); return found; } diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 35929fe..7d37185 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -26,7 +26,8 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn, if (this->AlreadyInCacheWithoutMetaInfo) { this->Makefile->AddCacheDefinition( this->VariableName, "", this->VariableDocumentation.c_str(), - (this->IncludeFileInPath ? cmState::FILEPATH : cmState::PATH)); + (this->IncludeFileInPath ? cmStateEnums::FILEPATH + : cmStateEnums::PATH)); } return true; } @@ -35,13 +36,13 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn, if (!result.empty()) { this->Makefile->AddCacheDefinition( this->VariableName, result.c_str(), this->VariableDocumentation.c_str(), - (this->IncludeFileInPath) ? cmState::FILEPATH : cmState::PATH); + (this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH); return true; } this->Makefile->AddCacheDefinition( this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), this->VariableDocumentation.c_str(), - (this->IncludeFileInPath) ? cmState::FILEPATH : cmState::PATH); + (this->IncludeFileInPath) ? cmStateEnums::FILEPATH : cmStateEnums::PATH); return true; } diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index a6f2518..9886860 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -90,7 +90,7 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn, if (this->AlreadyInCacheWithoutMetaInfo) { this->Makefile->AddCacheDefinition(this->VariableName, "", this->VariableDocumentation.c_str(), - cmState::FILEPATH); + cmStateEnums::FILEPATH); } return true; } @@ -100,13 +100,13 @@ bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn, // Save the value in the cache this->Makefile->AddCacheDefinition(this->VariableName, result.c_str(), this->VariableDocumentation.c_str(), - cmState::FILEPATH); + cmStateEnums::FILEPATH); return true; } this->Makefile->AddCacheDefinition( this->VariableName, (this->VariableName + "-NOTFOUND").c_str(), - this->VariableDocumentation.c_str(), cmState::FILEPATH); + this->VariableDocumentation.c_str(), cmStateEnums::FILEPATH); return true; } diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index aff1ecd..c026631 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -53,8 +53,9 @@ void cmGeneratorExpressionDAGChecker::Initialize() #define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() || - if (CheckResult == DAG && (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD( - TEST_TRANSITIVE_PROPERTY_METHOD) false)) + if (CheckResult == DAG && + (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD( + TEST_TRANSITIVE_PROPERTY_METHOD) false)) // NOLINT(clang-tidy) #undef TEST_TRANSITIVE_PROPERTY_METHOD { std::map<std::string, std::set<std::string> >::const_iterator it = diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f866605..3a41712 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -15,7 +15,7 @@ #include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cm_auto_ptr.hxx" @@ -1035,7 +1035,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode #define TRANSITIVE_PROPERTY_COMPARE(PROPERTY) \ (#PROPERTY == propertyName || "INTERFACE_" #PROPERTY == propertyName) || if (CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME( - TRANSITIVE_PROPERTY_COMPARE) false) { + TRANSITIVE_PROPERTY_COMPARE) false) { // NOLINT(clang-tidy) reportError( context, content->GetOriginalExpression(), "$<TARGET_PROPERTY:...> expression in link libraries " @@ -1052,7 +1052,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode #define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) dagCheckerParent->METHOD() || assert(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD( - ASSERT_TRANSITIVE_PROPERTY_METHOD) false); + ASSERT_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(clang-tidy) #undef ASSERT_TRANSITIVE_PROPERTY_METHOD } } @@ -1104,7 +1104,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!prop) { if (target->IsImported() || - target->GetType() == cmState::INTERFACE_LIBRARY) { + target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return linkedTargetsContent; } if (target->IsLinkInterfaceDependentBoolProperty(propertyName, @@ -1224,7 +1224,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), e.str()); return std::string(); } - if (gt->GetType() != cmState::OBJECT_LIBRARY) { + if (gt->GetType() != cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Objects of target \"" << tgtName << "\" referenced but is not an OBJECT library."; @@ -1506,7 +1506,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag> "for DLL target platforms."); return std::string(); } - if (target->GetType() != cmState::SHARED_LIBRARY) { + if (target->GetType() != cmStateEnums::SHARED_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), "TARGET_SONAME_FILE is allowed only for " "SHARED libraries."); @@ -1542,11 +1542,11 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> return std::string(); } - cmState::TargetType targetType = target->GetType(); + cmStateEnums::TargetType targetType = target->GetType(); - if (targetType != cmState::SHARED_LIBRARY && - targetType != cmState::MODULE_LIBRARY && - targetType != cmState::EXECUTABLE) { + if (targetType != cmStateEnums::SHARED_LIBRARY && + targetType != cmStateEnums::MODULE_LIBRARY && + targetType != cmStateEnums::EXECUTABLE) { ::reportError(context, content->GetOriginalExpression(), "TARGET_PDB_FILE is allowed only for " "targets with linker created artifacts."); @@ -1646,8 +1646,8 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "No target \"" + name + "\""); return std::string(); } - if (target->GetType() >= cmState::OBJECT_LIBRARY && - target->GetType() != cmState::UNKNOWN_LIBRARY) { + if (target->GetType() >= cmStateEnums::OBJECT_LIBRARY && + target->GetType() != cmStateEnums::UNKNOWN_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), "Target \"" + name + "\" is not an executable or library."); return std::string(); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index b16cfc6..8ac302a 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -15,6 +15,7 @@ #include "cmPropertyMap.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" +#include "cmState.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" @@ -215,7 +216,7 @@ struct TagVisitor , Target(target) , GlobalGenerator(target->GetLocalGenerator()->GetGlobalGenerator()) , Header(CM_HEADER_REGEX) - , IsObjLib(target->GetType() == cmState::OBJECT_LIBRARY) + , IsObjLib(target->GetType() == cmStateEnums::OBJECT_LIBRARY) { } @@ -230,7 +231,7 @@ struct TagVisitor std::string ext = cmSystemTools::LowerCase(sf->GetExtension()); if (sf->GetCustomCommand()) { DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf); - } else if (this->Target->GetType() == cmState::UTILITY) { + } else if (this->Target->GetType() == cmStateEnums::UTILITY) { DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf); } else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) { DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf); @@ -368,7 +369,7 @@ cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const return this->LocalGenerator; } -cmState::TargetType cmGeneratorTarget::GetType() const +cmStateEnums::TargetType cmGeneratorTarget::GetType() const { return this->Target->GetType(); } @@ -400,7 +401,7 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const if (!cmTargetPropertyComputer::PassesWhitelist( this->GetType(), prop, this->Makefile->GetMessenger(), this->GetBacktrace())) { - return 0; + return CM_NULLPTR; } if (const char* result = cmTargetPropertyComputer::GetProperty( this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) { @@ -415,7 +416,7 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const { switch (this->GetType()) { - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: if (this->IsDLLPlatform()) { if (implib) { // A DLL import library is treated as an archive target. @@ -428,10 +429,10 @@ const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const // library targets. return "LIBRARY"; } - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: // Static libraries are always treated as archive targets. return "ARCHIVE"; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: if (implib) { // Module libraries are always treated as library targets. return "ARCHIVE"; @@ -439,7 +440,7 @@ const char* cmGeneratorTarget::GetOutputTargetType(bool implib) const // Module import libraries are treated as archive targets. return "LIBRARY"; } - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: if (implib) { // Executable import libraries are treated as archive targets. return "ARCHIVE"; @@ -845,7 +846,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const bool cmGeneratorTarget::IsSystemIncludeDirectory( const std::string& dir, const std::string& config) const { - assert(this->GetType() != cmState::INTERFACE_LIBRARY); + assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); std::string config_upper; if (!config.empty()) { config_upper = cmSystemTools::UpperCase(config); @@ -1006,7 +1007,7 @@ static bool processSources( void cmGeneratorTarget::GetSourceFiles(std::vector<std::string>& files, const std::string& config) const { - assert(this->GetType() != cmState::INTERFACE_LIBRARY); + assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) { // At configure-time, this method can be called as part of getting the @@ -1151,7 +1152,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, // and then only when the platform supports an soname flag. - return ((this->GetType() == cmState::SHARED_LIBRARY) && + return ((this->GetType() == cmStateEnums::SHARED_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } @@ -1161,9 +1162,9 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall( { // Only executables and shared libraries can have an rpath and may // need relinking. - if (this->GetType() != cmState::EXECUTABLE && - this->GetType() != cmState::SHARED_LIBRARY && - this->GetType() != cmState::MODULE_LIBRARY) { + if (this->GetType() != cmStateEnums::EXECUTABLE && + this->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GetType() != cmStateEnums::MODULE_LIBRARY) { return false; } @@ -1235,9 +1236,9 @@ bool cmGeneratorTarget::NeedRelinkBeforeInstall( bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const { // Only certain target types have an rpath. - if (!(this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY || - this->GetType() == cmState::EXECUTABLE)) { + if (!(this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::MODULE_LIBRARY || + this->GetType() == cmStateEnums::EXECUTABLE)) { return false; } @@ -1292,7 +1293,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const bool cmGeneratorTarget::IsImportedSharedLibWithoutSOName( const std::string& config) const { - if (this->IsImported() && this->GetType() == cmState::SHARED_LIBRARY) { + if (this->IsImported() && this->GetType() == cmStateEnums::SHARED_LIBRARY) { if (cmGeneratorTarget::ImportInfo const* info = this->GetImportInfo(config)) { return info->NoSOName; @@ -1308,7 +1309,7 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir( bool macosx_rpath = false; if (!this->IsImported()) { - if (this->GetType() != cmState::SHARED_LIBRARY) { + if (this->GetType() != cmStateEnums::SHARED_LIBRARY) { return false; } const char* install_name = this->GetProperty("INSTALL_NAME_DIR"); @@ -1562,17 +1563,17 @@ const cmListFileBacktrace* cmGeneratorTarget::GetUtilityBacktrace( bool cmGeneratorTarget::HaveWellDefinedOutputFiles() const { - return this->GetType() == cmState::STATIC_LIBRARY || - this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY || - this->GetType() == cmState::EXECUTABLE; + return this->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::MODULE_LIBRARY || + this->GetType() == cmStateEnums::EXECUTABLE; } const char* cmGeneratorTarget::GetExportMacro() const { // Define the symbol for targets that export symbols. - if (this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY || + if (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::MODULE_LIBRARY || this->IsExecutableWithExports()) { if (const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) { this->ExportMacro = custom_export_name; @@ -1846,7 +1847,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( return CM_NULLPTR; } - if (this->GetType() > cmState::OBJECT_LIBRARY) { + if (this->GetType() > cmStateEnums::OBJECT_LIBRARY) { std::string msg = "cmTarget::GetCompileInfo called for "; msg += this->GetName(); msg += " which has type "; @@ -2023,7 +2024,7 @@ cmTargetTraceDependencies::cmTargetTraceDependencies(cmGeneratorTarget* target) this->CurrentEntry = CM_NULLPTR; // Queue all the source files already specified for the target. - if (target->GetType() != cmState::INTERFACE_LIBRARY) { + if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { std::vector<std::string> configs; this->Makefile->GetConfigurations(configs); if (configs.empty()) { @@ -2158,8 +2159,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) // then make sure it was not a full path to something else, and // the fact that the name matched a target was just a coincidence. if (cmSystemTools::FileIsFullPath(dep.c_str())) { - if (t->GetType() >= cmState::EXECUTABLE && - t->GetType() <= cmState::MODULE_LIBRARY) { + if (t->GetType() >= cmStateEnums::EXECUTABLE && + t->GetType() <= cmStateEnums::MODULE_LIBRARY) { // This is really only for compatibility so we do not need to // worry about configuration names and output names. std::string tLocation = t->GetLocationForBuild(); @@ -2199,7 +2200,7 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) // Check for a target with this name. if (cmGeneratorTarget* t = this->LocalGenerator->FindGeneratorTargetToUse(command)) { - if (t->GetType() == cmState::EXECUTABLE) { + if (t->GetType() == cmStateEnums::EXECUTABLE) { // The command refers to an executable target built in // this project. Add the target-level dependency to make // sure the executable is up to date before this custom @@ -2273,7 +2274,7 @@ void cmGeneratorTarget::TraceDependencies() // would find nothing anyway, but when building CMake itself the "install" // target command ends up referencing the "cmake" target but we do not // really want the dependency because "install" depend on "all" anyway. - if (this->GetType() == cmState::GLOBAL_TARGET) { + if (this->GetType() == cmStateEnums::GLOBAL_TARGET) { return; } @@ -2312,7 +2313,7 @@ std::string cmGeneratorTarget::GetCreateRuleVariable( std::string const& lang, std::string const& config) const { switch (this->GetType()) { - case cmState::STATIC_LIBRARY: { + case cmStateEnums::STATIC_LIBRARY: { std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY"; if (this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION", config)) { std::string varIPO = var + "_IPO"; @@ -2322,11 +2323,11 @@ std::string cmGeneratorTarget::GetCreateRuleVariable( } return var; } - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY"; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: return "CMAKE_" + lang + "_CREATE_SHARED_MODULE"; - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return "CMAKE_" + lang + "_LINK_EXECUTABLE"; default: break; @@ -2753,11 +2754,11 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - if (this->GetType() == cmState::EXECUTABLE) { + if (this->GetType() == cmStateEnums::EXECUTABLE) { this->GetExecutableNames(name, realName, impName, pdbName, config); - } else if (this->GetType() == cmState::STATIC_LIBRARY || - this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY) { + } else if (this->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::MODULE_LIBRARY) { this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else { return; @@ -2843,7 +2844,7 @@ std::string cmGeneratorTarget::NormalGetRealName( this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); } - if (this->GetType() == cmState::EXECUTABLE) { + if (this->GetType() == cmStateEnums::EXECUTABLE) { // Compute the real name that will be built. std::string name; std::string realName; @@ -2926,8 +2927,8 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, } // The import library name. - if (this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY) { + if (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::MODULE_LIBRARY) { impName = this->GetFullNameInternal(config, true); } else { impName = ""; @@ -2959,7 +2960,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #else // Check for executable version properties. const char* version = this->GetProperty("VERSION"); - if (this->GetType() != cmState::EXECUTABLE || + if (this->GetType() != cmStateEnums::EXECUTABLE || this->Makefile->IsOn("XCODE")) { version = CM_NULLPTR; } @@ -3028,10 +3029,10 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string& outSuffix) const { // Use just the target name for non-main target types. - if (this->GetType() != cmState::STATIC_LIBRARY && - this->GetType() != cmState::SHARED_LIBRARY && - this->GetType() != cmState::MODULE_LIBRARY && - this->GetType() != cmState::EXECUTABLE) { + if (this->GetType() != cmStateEnums::STATIC_LIBRARY && + this->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GetType() != cmStateEnums::MODULE_LIBRARY && + this->GetType() != cmStateEnums::EXECUTABLE) { outPrefix = ""; outBase = this->GetName(); outSuffix = ""; @@ -3050,9 +3051,9 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, // The implib option is only allowed for shared libraries, module // libraries, and executables. - if (this->GetType() != cmState::SHARED_LIBRARY && - this->GetType() != cmState::MODULE_LIBRARY && - this->GetType() != cmState::EXECUTABLE) { + if (this->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GetType() != cmStateEnums::MODULE_LIBRARY && + this->GetType() != cmStateEnums::EXECUTABLE) { implib = false; } @@ -3130,7 +3131,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, // Name shared libraries with their version number on some platforms. if (const char* soversion = this->GetProperty("SOVERSION")) { - if (this->GetType() == cmState::SHARED_LIBRARY && !implib && + if (this->GetType() == cmStateEnums::SHARED_LIBRARY && !implib && this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) { outBase += "-"; outBase += soversion; @@ -3296,8 +3297,8 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( const std::string& p, const std::string& config) const { - if (this->GetType() == cmState::OBJECT_LIBRARY || - this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::OBJECT_LIBRARY || + this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return false; } return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; @@ -3306,8 +3307,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( const std::string& p, const std::string& config) const { - if (this->GetType() == cmState::OBJECT_LIBRARY || - this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::OBJECT_LIBRARY || + this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return false; } return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; @@ -3316,8 +3317,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( const std::string& p, const std::string& config) const { - if (this->GetType() == cmState::OBJECT_LIBRARY || - this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::OBJECT_LIBRARY || + this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return false; } return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; @@ -3326,8 +3327,8 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( const std::string& p, const std::string& config) const { - if (this->GetType() == cmState::OBJECT_LIBRARY || - this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::OBJECT_LIBRARY || + this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return false; } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; @@ -3921,7 +3922,7 @@ void cmGeneratorTarget::GetTargetVersion(bool soversion, int& major, minor = 0; patch = 0; - assert(this->GetType() != cmState::INTERFACE_LIBRARY); + assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); // Look for a VERSION or SOVERSION property. const char* prop = soversion ? "SOVERSION" : "VERSION"; @@ -3993,7 +3994,7 @@ std::string cmGeneratorTarget::CreateFortranModuleDirectory( std::string cmGeneratorTarget::GetFrameworkVersion() const { - assert(this->GetType() != cmState::INTERFACE_LIBRARY); + assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY); if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) { return fversion; @@ -4109,7 +4110,7 @@ cmLinkInterface const* cmGeneratorTarget::GetLinkInterface( // Link interfaces are not supported for executables that do not // export symbols. - if (this->GetType() == cmState::EXECUTABLE && + if (this->GetType() == cmStateEnums::EXECUTABLE && !this->IsExecutableWithExports()) { return CM_NULLPTR; } @@ -4143,9 +4144,9 @@ void cmGeneratorTarget::ComputeLinkInterface( cmGeneratorTarget const* headTarget) const { if (iface.ExplicitLibraries) { - if (this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::STATIC_LIBRARY || - this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // Shared libraries may have runtime implementation dependencies // on other shared libraries that are not in the interface. UNORDERED_SET<std::string> emitted; @@ -4154,7 +4155,7 @@ void cmGeneratorTarget::ComputeLinkInterface( li != iface.Libraries.end(); ++li) { emitted.insert(*li); } - if (this->GetType() != cmState::INTERFACE_LIBRARY) { + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) { cmLinkImplementation const* impl = this->GetLinkImplementation(config); for (std::vector<cmLinkImplItem>::const_iterator li = impl->Libraries.begin(); @@ -4162,7 +4163,7 @@ void cmGeneratorTarget::ComputeLinkInterface( if (emitted.insert(*li).second) { if (li->Target) { // This is a runtime dependency on another shared library. - if (li->Target->GetType() == cmState::SHARED_LIBRARY) { + if (li->Target->GetType() == cmStateEnums::SHARED_LIBRARY) { iface.SharedDeps.push_back(*li); } } else { @@ -4192,7 +4193,7 @@ void cmGeneratorTarget::ComputeLinkInterface( } } - if (this->GetType() == cmState::STATIC_LIBRARY) { + if (this->GetType() == cmStateEnums::STATIC_LIBRARY) { // Construct the property name suffix for this configuration. std::string suffix = "_"; if (!config.empty()) { @@ -4225,7 +4226,7 @@ const cmLinkInterfaceLibraries* cmGeneratorTarget::GetLinkInterfaceLibraries( // Link interfaces are not supported for executables that do not // export symbols. - if (this->GetType() == cmState::EXECUTABLE && + if (this->GetType() == cmStateEnums::EXECUTABLE && !this->IsExecutableWithExports()) { return CM_NULLPTR; } @@ -4372,12 +4373,12 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config, if (out != outdir) { conf = ""; } - } else if (this->GetType() == cmState::EXECUTABLE) { + } else if (this->GetType() == cmStateEnums::EXECUTABLE) { // Lookup the output path for executables. out = this->Makefile->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); - } else if (this->GetType() == cmState::STATIC_LIBRARY || - this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY) { + } else if (this->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::MODULE_LIBRARY) { // Lookup the output path for libraries. out = this->Makefile->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); } @@ -4486,7 +4487,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; explicitLibraries = this->GetProperty(linkIfaceProp); - } else if (this->GetType() == cmState::SHARED_LIBRARY || + } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->IsExecutableWithExports()) { // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a // shared lib or executable. @@ -4531,8 +4532,9 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( // There is no implicit link interface for executables or modules // so if none was explicitly set then there is no link interface. - if (!explicitLibraries && (this->GetType() == cmState::EXECUTABLE || - (this->GetType() == cmState::MODULE_LIBRARY))) { + if (!explicitLibraries && + (this->GetType() == cmStateEnums::EXECUTABLE || + (this->GetType() == cmStateEnums::MODULE_LIBRARY))) { return; } iface.Exists = true; @@ -4661,7 +4663,7 @@ cmGeneratorTarget::ImportInfo const* cmGeneratorTarget::GetImportInfo( i = this->ImportInfoMap.insert(entry).first; } - if (this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return &i->second; } // If the location is empty then the target is not available for @@ -4696,7 +4698,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, std::string linkProp = "INTERFACE_LINK_LIBRARIES"; const char* propertyLibs = this->GetProperty(linkProp); - if (this->GetType() != cmState::INTERFACE_LIBRARY) { + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) { if (!propertyLibs) { linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; linkProp += suffix; @@ -4713,7 +4715,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, info.Libraries = propertyLibs; } } - if (this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return; } @@ -4734,7 +4736,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, } // Get the soname. - if (this->GetType() == cmState::SHARED_LIBRARY) { + if (this->GetType() == cmStateEnums::SHARED_LIBRARY) { std::string soProp = "IMPORTED_SONAME"; soProp += suffix; if (const char* config_soname = this->GetProperty(soProp)) { @@ -4745,7 +4747,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, } // Get the "no-soname" mark. - if (this->GetType() == cmState::SHARED_LIBRARY) { + if (this->GetType() == cmStateEnums::SHARED_LIBRARY) { std::string soProp = "IMPORTED_NO_SONAME"; soProp += suffix; if (const char* config_no_soname = this->GetProperty(soProp)) { @@ -4759,7 +4761,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, // Get the import library. if (imp) { info.ImportLibrary = imp; - } else if (this->GetType() == cmState::SHARED_LIBRARY || + } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->IsExecutableWithExports()) { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; @@ -4795,7 +4797,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, } // Get the cyclic repetition count. - if (this->GetType() == cmState::STATIC_LIBRARY) { + if (this->GetType() == cmStateEnums::STATIC_LIBRARY) { std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY"; linkProp += suffix; if (const char* config_reps = this->GetProperty(linkProp)) { @@ -5191,12 +5193,12 @@ cmGeneratorTarget* cmGeneratorTarget::FindTargetToLink( // Skip targets that will not really be linked. This is probably a // name conflict between an external library and an executable // within the project. - if (tgt && tgt->GetType() == cmState::EXECUTABLE && + if (tgt && tgt->GetType() == cmStateEnums::EXECUTABLE && !tgt->IsExecutableWithExports()) { tgt = CM_NULLPTR; } - if (tgt && tgt->GetType() == cmState::OBJECT_LIBRARY) { + if (tgt && tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Target \"" << this->GetName() << "\" links to " "OBJECT library \"" @@ -5242,14 +5244,14 @@ bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName, bool cmGeneratorTarget::IsExecutableWithExports() const { - return (this->GetType() == cmState::EXECUTABLE && + return (this->GetType() == cmStateEnums::EXECUTABLE && this->GetPropertyAsBool("ENABLE_EXPORTS")); } bool cmGeneratorTarget::HasImportLibrary() const { return (this->IsDLLPlatform() && - (this->GetType() == cmState::SHARED_LIBRARY || + (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->IsExecutableWithExports())); } @@ -5269,24 +5271,24 @@ std::string cmGeneratorTarget::GetSupportDirectory() const bool cmGeneratorTarget::IsLinkable() const { - return (this->GetType() == cmState::STATIC_LIBRARY || - this->GetType() == cmState::SHARED_LIBRARY || - this->GetType() == cmState::MODULE_LIBRARY || - this->GetType() == cmState::UNKNOWN_LIBRARY || - this->GetType() == cmState::INTERFACE_LIBRARY || + return (this->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GetType() == cmStateEnums::MODULE_LIBRARY || + this->GetType() == cmStateEnums::UNKNOWN_LIBRARY || + this->GetType() == cmStateEnums::INTERFACE_LIBRARY || this->IsExecutableWithExports()); } bool cmGeneratorTarget::IsFrameworkOnApple() const { - return (this->GetType() == cmState::SHARED_LIBRARY && + return (this->GetType() == cmStateEnums::SHARED_LIBRARY && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("FRAMEWORK")); } bool cmGeneratorTarget::IsAppBundleOnApple() const { - return (this->GetType() == cmState::EXECUTABLE && + return (this->GetType() == cmStateEnums::EXECUTABLE && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("MACOSX_BUNDLE")); } @@ -5298,6 +5300,6 @@ bool cmGeneratorTarget::IsXCTestOnApple() const bool cmGeneratorTarget::IsCFBundleOnApple() const { - return (this->GetType() == cmState::MODULE_LIBRARY && + return (this->GetType() == cmStateEnums::MODULE_LIBRARY && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("BUNDLE")); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5a02d..3805bfc 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -8,7 +8,7 @@ #include "cmLinkItem.h" #include "cmListFileCache.h" #include "cmPolicies.h" -#include "cmState.h" +#include "cmStateTypes.h" #include <map> #include <set> @@ -60,7 +60,7 @@ public: cmComputeLinkInformation* GetLinkInformation( const std::string& config) const; - cmState::TargetType GetType() const; + cmStateEnums::TargetType GetType() const; const std::string& GetName() const; std::string GetExportName() const; @@ -198,7 +198,7 @@ public: bool LinkLanguagePropagatesToDependents() const { - return this->GetType() == cmState::STATIC_LIBRARY; + return this->GetType() == cmStateEnums::STATIC_LIBRARY; } /** Get the macro to define when building sources in this target. diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 11373b7..e5949f0 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -4,7 +4,7 @@ #include "cmAlgorithms.h" #include "cmGlobalGenerator.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmake.h" // cmGetCMakePropertyCommand diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index 05dbfb4..c183947 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -88,13 +88,13 @@ bool cmGetFilenameComponentCommand::InitialPass( if (args.size() >= 4 && args[args.size() - 1] == "CACHE") { if (!programArgs.empty() && !storeArgs.empty()) { - this->Makefile->AddCacheDefinition(storeArgs, programArgs.c_str(), "", - args[2] == "PATH" ? cmState::FILEPATH - : cmState::STRING); + this->Makefile->AddCacheDefinition( + storeArgs, programArgs.c_str(), "", + args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING); } - this->Makefile->AddCacheDefinition(args[0], result.c_str(), "", - args[2] == "PATH" ? cmState::FILEPATH - : cmState::STRING); + this->Makefile->AddCacheDefinition( + args[0], result.c_str(), "", + args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING); } else { if (!programArgs.empty() && !storeArgs.empty()) { this->Makefile->AddDefinition(storeArgs, programArgs.c_str()); diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 39445dd..1852eab 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -6,6 +6,7 @@ #include "cmPropertyDefinition.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmTargetPropertyComputer.h" #include "cmTest.h" #include "cmake.h" @@ -247,7 +248,7 @@ bool cmGetPropertyCommand::HandleTargetMode() } return this->StoreResult(CM_NULLPTR); } - const char* prop_cstr = 0; + const char* prop_cstr = CM_NULLPTR; cmListFileBacktrace bt = this->Makefile->GetBacktrace(); cmMessenger* messenger = this->Makefile->GetMessenger(); if (cmTargetPropertyComputer::PassesWhitelist( diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 6a816d8..e78f780 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -24,7 +24,7 @@ bool cmGetTargetPropertyCommand::InitialPass( prop_exists = true; } } else if (!args[2].empty()) { - const char* prop_cstr = 0; + const char* prop_cstr = CM_NULLPTR; cmListFileBacktrace bt = this->Makefile->GetBacktrace(); cmMessenger* messenger = this->Makefile->GetMessenger(); if (cmTargetPropertyComputer::PassesWhitelist(tgt->GetType(), args[2], diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 3154f8d..ba623d5 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmGhsMultiTargetGenerator::Generate() this->WriteCompilerFlags(config, language); this->WriteCompilerDefinitions(config, language); this->WriteIncludes(config, language); - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { this->WriteTargetLinkLibraries(config, language); } this->WriteCustomCommands(); @@ -174,7 +174,7 @@ GhsMultiGpj::Types cmGhsMultiTargetGenerator::GetGpjTag( GhsMultiGpj::Types output; if (cmGhsMultiTargetGenerator::DetermineIfTargetGroup(target)) { output = GhsMultiGpj::INTERGRITY_APPLICATION; - } else if (target->GetType() == cmState::STATIC_LIBRARY) { + } else if (target->GetType() == cmStateEnums::STATIC_LIBRARY) { output = GhsMultiGpj::LIBRARY; } else { output = GhsMultiGpj::PROGRAM; @@ -195,13 +195,13 @@ void cmGhsMultiTargetGenerator::WriteTypeSpecifics(const std::string& config, std::string outputDir(this->GetOutputDirectory(config)); std::string outputFilename(this->GetOutputFilename(config)); - if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { std::string const static_library_suffix = this->Makefile->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"); *this->GetFolderBuildStreams() << " -o \"" << outputDir << outputFilename << static_library_suffix << "\"" << std::endl; - } else if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + } else if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { if (notKernel && !this->IsTargetGroup()) { *this->GetFolderBuildStreams() << " -relprog" << std::endl; } diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 5a2150d..a0a33ea 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -4,6 +4,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmake.h" cmGlobalBorlandMakefileGenerator::cmGlobalBorlandMakefileGenerator(cmake* cm) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 7d0c2da..b4ede1d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -29,6 +29,7 @@ #include "cmQtAutoGeneratorInitializer.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmVersion.h" #include "cmake.h" @@ -308,7 +309,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) makeProgram += "/"; makeProgram += saveFile; mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", makeProgram.c_str(), - "make program", cmState::FILEPATH); + "make program", cmStateEnums::FILEPATH); } } @@ -1062,7 +1063,7 @@ void cmGlobalGenerator::Configure() this->FirstTimeProgress = 0.0f; this->ClearGeneratorMembers(); - cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); + cmStateSnapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); snapshot.GetDirectory().SetCurrentSource( this->CMakeInstance->GetHomeDirectory()); @@ -1103,7 +1104,7 @@ void cmGlobalGenerator::Configure() sprintf(num, "%d", static_cast<int>(this->Makefiles.size())); this->GetCMakeInstance()->AddCacheEntry("CMAKE_NUMBER_OF_MAKEFILES", num, "number of local generators", - cmState::INTERNAL); + cmStateEnums::INTERNAL); // check for link libraries and include directories containing "NOTFOUND" // and for infinite loops @@ -1371,14 +1372,14 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets() filteredTargets.reserve(targets.size()); for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); ti != targets.end(); ++ti) { - if ((*ti)->GetType() == cmState::GLOBAL_TARGET) { + if ((*ti)->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } - if ((*ti)->GetType() != cmState::EXECUTABLE && - (*ti)->GetType() != cmState::STATIC_LIBRARY && - (*ti)->GetType() != cmState::SHARED_LIBRARY && - (*ti)->GetType() != cmState::MODULE_LIBRARY && - (*ti)->GetType() != cmState::OBJECT_LIBRARY) { + if ((*ti)->GetType() != cmStateEnums::EXECUTABLE && + (*ti)->GetType() != cmStateEnums::STATIC_LIBRARY && + (*ti)->GetType() != cmStateEnums::SHARED_LIBRARY && + (*ti)->GetType() != cmStateEnums::MODULE_LIBRARY && + (*ti)->GetType() != cmStateEnums::OBJECT_LIBRARY) { continue; } if ((!(*ti)->GetPropertyAsBool("AUTOMOC") && @@ -1415,13 +1416,13 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets() } cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir) const + cmOutputConverter* outputConverter, cmStateDirectory stateDir) const { return new cmLinkLineComputer(outputConverter, stateDir); } cmLinkLineComputer* cmGlobalGenerator::CreateMSVC60LinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir) const + cmOutputConverter* outputConverter, cmStateDirectory stateDir) const { return new cmMSVC60LinkLineComputer(outputConverter, stateDir); } @@ -1443,13 +1444,13 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() cmTargets& targets = mf->GetTargets(); for (cmTargets::iterator ti = targets.begin(); ti != targets.end(); ++ti) { cmTarget* t = &ti->second; - if (t->GetType() == cmState::GLOBAL_TARGET) { + if (t->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } t->AppendBuildInterfaceIncludes(); - if (t->GetType() == cmState::INTERFACE_LIBRARY) { + if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -1575,7 +1576,7 @@ void cmGlobalGenerator::CheckTargetProperties() this->Makefiles[i]->ConfigureFinalPass(); cmTargets& targets = this->Makefiles[i]->GetTargets(); for (cmTargets::iterator l = targets.begin(); l != targets.end(); l++) { - if (l->second.GetType() == cmState::INTERFACE_LIBRARY) { + if (l->second.GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } const cmTarget::LinkLibraryVectorType& libs = @@ -1886,8 +1887,8 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator* gen, this->TryCompileOuterMakefile = mf; const char* make = gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); - this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make, - "make program", cmState::FILEPATH); + this->GetCMakeInstance()->AddCacheEntry( + "CMAKE_MAKE_PROGRAM", make, "make program", cmStateEnums::FILEPATH); // copy the enabled languages this->GetCMakeInstance()->GetState()->SetEnabledLanguages( gen->GetCMakeInstance()->GetState()->GetEnabledLanguages()); @@ -1909,10 +1910,10 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } } -bool cmGlobalGenerator::IsExcluded(cmState::Snapshot const& rootSnp, - cmState::Snapshot const& snp_) const +bool cmGlobalGenerator::IsExcluded(cmStateSnapshot const& rootSnp, + cmStateSnapshot const& snp_) const { - cmState::Snapshot snp = snp_; + cmStateSnapshot snp = snp_; while (snp.IsValid()) { if (snp == rootSnp) { // No directory excludes itself. @@ -1933,8 +1934,8 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { assert(gen); - cmState::Snapshot rootSnp = root->GetStateSnapshot(); - cmState::Snapshot snp = gen->GetStateSnapshot(); + cmStateSnapshot rootSnp = root->GetStateSnapshot(); + cmStateSnapshot snp = gen->GetStateSnapshot(); return this->IsExcluded(rootSnp, snp); } @@ -1942,7 +1943,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const { - if (target->GetType() == cmState::INTERFACE_LIBRARY || + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY || target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -1974,7 +1975,7 @@ void cmGlobalGenerator::FillProjectMap() unsigned int i; for (i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); + cmStateSnapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); std::string name; do { std::string snpProjName = snp.GetProjectName(); @@ -2398,8 +2399,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf) { // Package - cmTarget target(gti.Name, cmState::GLOBAL_TARGET, cmTarget::VisibilityNormal, - mf); + cmTarget target(gti.Name, cmStateEnums::GLOBAL_TARGET, + cmTarget::VisibilityNormal, mf); target.SetProperty("EXCLUDE_FROM_ALL", "TRUE"); std::vector<std::string> no_outputs; @@ -2544,7 +2545,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets, bool cmGlobalGenerator::IsRootOnlyTarget(cmGeneratorTarget* target) const { - return (target->GetType() == cmState::GLOBAL_TARGET || + return (target->GetType() == cmStateEnums::GLOBAL_TARGET || target->GetName() == this->GetAllTargetName()); } @@ -2729,7 +2730,7 @@ void cmGlobalGenerator::WriteSummary() this->LocalGenerators[i]->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator it = tgts.begin(); it != tgts.end(); ++it) { - if ((*it)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*it)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } this->WriteSummary(*it); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index c3498e0..9cc6724 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -6,7 +6,8 @@ #include <cmConfigure.h> #include "cmExportSetMap.h" -#include "cmState.h" +#include "cmStateDirectory.h" +#include "cmStateSnapshot.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" @@ -108,10 +109,10 @@ public: virtual void Generate(); virtual cmLinkLineComputer* CreateLinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir) const; + cmOutputConverter* outputConverter, cmStateDirectory stateDir) const; cmLinkLineComputer* CreateMSVC60LinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir) const; + cmOutputConverter* outputConverter, cmStateDirectory stateDir) const; /** * Set/Get and Clear the enabled languages. @@ -410,8 +411,8 @@ protected: // has been populated. void FillProjectMap(); void CheckTargetProperties(); - bool IsExcluded(cmState::Snapshot const& root, - cmState::Snapshot const& snp) const; + bool IsExcluded(cmStateSnapshot const& root, + cmStateSnapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} diff --git a/Source/cmGlobalJOMMakefileGenerator.cxx b/Source/cmGlobalJOMMakefileGenerator.cxx index a846773..78bf5bd 100644 --- a/Source/cmGlobalJOMMakefileGenerator.cxx +++ b/Source/cmGlobalJOMMakefileGenerator.cxx @@ -4,6 +4,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmState.h" cmGlobalJOMMakefileGenerator::cmGlobalJOMMakefileGenerator(cmake* cm) : cmGlobalUnixMakefileGenerator3(cm) diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 57d9aca..75209c3 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -8,7 +8,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmXMLWriter.h" @@ -74,7 +74,7 @@ void cmGlobalKdevelopGenerator::Generate() for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin(); ti != targets.end(); ti++) { - if ((*ti)->GetType() == cmState::EXECUTABLE) { + if ((*ti)->GetType() == cmStateEnums::EXECUTABLE) { executable = (*ti)->GetLocation(""); break; } diff --git a/Source/cmGlobalMSYSMakefileGenerator.cxx b/Source/cmGlobalMSYSMakefileGenerator.cxx index 6d314d6..f17b915 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.cxx +++ b/Source/cmGlobalMSYSMakefileGenerator.cxx @@ -4,6 +4,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmake.h" #include <cmsys/FStream.hxx> diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index d5decfb..255c0f5 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -4,6 +4,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmState.h" cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator(cmake* cm) : cmGlobalUnixMakefileGenerator3(cm) diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx index 48798fb..06aba73 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.cxx +++ b/Source/cmGlobalNMakeMakefileGenerator.cxx @@ -4,6 +4,7 @@ #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" +#include "cmState.h" cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator(cmake* cm) : cmGlobalUnixMakefileGenerator3(cm) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 67df038..b90428d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -13,7 +13,7 @@ #include "cmMakefile.h" #include "cmNinjaLinkLineComputer.h" #include "cmOutputConverter.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" @@ -66,7 +66,7 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, } cmLinkLineComputer* cmGlobalNinjaGenerator::CreateLinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory /* stateDir */) const + cmOutputConverter* outputConverter, cmStateDirectory /* stateDir */) const { return new cmNinjaLinkLineComputer( outputConverter, @@ -956,17 +956,17 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( bool realname = target->IsFrameworkOnApple(); switch (target->GetType()) { - case cmState::EXECUTABLE: - case cmState::SHARED_LIBRARY: - case cmState::STATIC_LIBRARY: - case cmState::MODULE_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: { outputs.push_back(this->ConvertToNinjaPath( target->GetFullPath(configName, false, realname))); break; } - case cmState::OBJECT_LIBRARY: - case cmState::GLOBAL_TARGET: - case cmState::UTILITY: { + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::UTILITY: { std::string path = target->GetLocalGenerator()->GetCurrentBinaryDirectory() + std::string("/") + target->GetName(); @@ -982,7 +982,7 @@ void cmGlobalNinjaGenerator::AppendTargetOutputs( void cmGlobalNinjaGenerator::AppendTargetDepends( cmGeneratorTarget const* target, cmNinjaDeps& outputs) { - if (target->GetType() == cmState::GLOBAL_TARGET) { + if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { // These depend only on other CMake-provided targets, e.g. "all". std::set<std::string> const& utils = target->GetUtilities(); for (std::set<std::string>::const_iterator i = utils.begin(); @@ -997,7 +997,7 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target); for (cmTargetDependSet::const_iterator i = targetDeps.begin(); i != targetDeps.end(); ++i) { - if ((*i)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } this->AppendTargetOutputs(*i, outs); @@ -1034,7 +1034,7 @@ void cmGlobalNinjaGenerator::ComputeTargetDependsClosure( cmTargetDependSet const& targetDeps = this->GetTargetDirectDepends(target); for (cmTargetDependSet::const_iterator i = targetDeps.begin(); i != targetDeps.end(); ++i) { - if ((*i)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } if (depends.insert(*i).second) { @@ -1102,11 +1102,13 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) lg->GetGeneratorTargets().begin(); ti != lg->GetGeneratorTargets().end(); ++ti) { cmGeneratorTarget const* gt = *ti; - cmState::TargetType const type = gt->GetType(); - if ((type == cmState::EXECUTABLE || type == cmState::STATIC_LIBRARY || - type == cmState::SHARED_LIBRARY || - type == cmState::MODULE_LIBRARY || - type == cmState::OBJECT_LIBRARY || type == cmState::UTILITY) && + cmStateEnums::TargetType const type = gt->GetType(); + if ((type == cmStateEnums::EXECUTABLE || + type == cmStateEnums::STATIC_LIBRARY || + type == cmStateEnums::SHARED_LIBRARY || + type == cmStateEnums::MODULE_LIBRARY || + type == cmStateEnums::OBJECT_LIBRARY || + type == cmStateEnums::UTILITY) && !gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { targetsPerFolder[currentSourceFolder].push_back(gt->GetName()); } @@ -1114,9 +1116,9 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) // The directory-level rule should depend on the directory-level // rules of the subdirectories. - std::vector<cmState::Snapshot> const& children = + std::vector<cmStateSnapshot> const& children = lg->GetStateSnapshot().GetChildren(); - for (std::vector<cmState::Snapshot>::const_iterator stateIt = + for (std::vector<cmStateSnapshot>::const_iterator stateIt = children.begin(); stateIt != children.end(); ++stateIt) { targetsPerFolder[currentSourceFolder].push_back( @@ -1665,8 +1667,7 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( { // Setup path conversions. { - cmState::Snapshot snapshot = - this->GetCMakeInstance()->GetCurrentSnapshot(); + cmStateSnapshot snapshot = this->GetCMakeInstance()->GetCurrentSnapshot(); snapshot.GetDirectory().SetCurrentSource(dir_cur_src); snapshot.GetDirectory().SetCurrentBinary(dir_cur_bld); snapshot.GetDirectory().SetRelativePathTopSource(dir_top_src.c_str()); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 6b77a2b..d4a14e2 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -72,7 +72,7 @@ public: cmLinkLineComputer* CreateLinkLineComputer( cmOutputConverter* outputConverter, - cmState::Directory stateDir) const CM_OVERRIDE; + cmStateDirectory stateDir) const CM_OVERRIDE; /** * Write the given @a comment to the output stream @a os. It diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index daacef0..17d49e8 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -12,6 +12,8 @@ #include "cmMakefile.h" #include "cmMakefileTargetGenerator.h" #include "cmOutputConverter.h" +#include "cmState.h" +#include "cmStateDirectory.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" @@ -93,7 +95,7 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const if (!editCacheCommand.empty()) { cm->AddCacheEntry("CMAKE_EDIT_COMMAND", editCacheCommand.c_str(), "Path to cache edit program executable.", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } } const char* edit_cmd = cm->GetCacheDefinition("CMAKE_EDIT_COMMAND"); @@ -382,12 +384,12 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefileLanguageRules( std::vector<cmGeneratorTarget*> tgts = lg->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); l++) { - if (((*l)->GetType() == cmState::EXECUTABLE) || - ((*l)->GetType() == cmState::STATIC_LIBRARY) || - ((*l)->GetType() == cmState::SHARED_LIBRARY) || - ((*l)->GetType() == cmState::MODULE_LIBRARY) || - ((*l)->GetType() == cmState::OBJECT_LIBRARY) || - ((*l)->GetType() == cmState::UTILITY)) { + if (((*l)->GetType() == cmStateEnums::EXECUTABLE) || + ((*l)->GetType() == cmStateEnums::STATIC_LIBRARY) || + ((*l)->GetType() == cmStateEnums::SHARED_LIBRARY) || + ((*l)->GetType() == cmStateEnums::MODULE_LIBRARY) || + ((*l)->GetType() == cmStateEnums::OBJECT_LIBRARY) || + ((*l)->GetType() == cmStateEnums::UTILITY)) { cmGeneratorTarget* gt = *l; std::string tname = lg->GetRelativeTargetDirectory(gt); tname += "/DependInfo.cmake"; @@ -416,10 +418,12 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( l != targets.end(); ++l) { cmGeneratorTarget* gtarget = *l; int type = gtarget->GetType(); - if ((type == cmState::EXECUTABLE) || (type == cmState::STATIC_LIBRARY) || - (type == cmState::SHARED_LIBRARY) || - (type == cmState::MODULE_LIBRARY) || - (type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY)) { + if ((type == cmStateEnums::EXECUTABLE) || + (type == cmStateEnums::STATIC_LIBRARY) || + (type == cmStateEnums::SHARED_LIBRARY) || + (type == cmStateEnums::MODULE_LIBRARY) || + (type == cmStateEnums::OBJECT_LIBRARY) || + (type == cmStateEnums::UTILITY)) { // Add this to the list of depends rules in this directory. if ((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || @@ -434,9 +438,8 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRule2( // The directory-level rule should depend on the directory-level // rules of the subdirectories. - std::vector<cmState::Snapshot> children = - lg->GetStateSnapshot().GetChildren(); - for (std::vector<cmState::Snapshot>::const_iterator ci = children.begin(); + std::vector<cmStateSnapshot> children = lg->GetStateSnapshot().GetChildren(); + for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin(); ci != children.end(); ++ci) { std::string subdir = ci->GetDirectory().GetCurrentBinary(); subdir += "/"; @@ -505,7 +508,7 @@ void cmGlobalUnixMakefileGenerator3::GenerateBuildCommand( if (!this->Makefiles.empty()) { mf = this->Makefiles[0]; } else { - cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); + cmStateSnapshot snapshot = this->CMakeInstance->GetCurrentSnapshot(); snapshot.GetDirectory().SetCurrentSource( this->CMakeInstance->GetHomeDirectory()); snapshot.GetDirectory().SetCurrentBinary( @@ -554,11 +557,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules( if (!name.empty() && emitted.insert(name).second && // Handle user targets here. Global targets are handled in // the local generator on a per-directory basis. - ((type == cmState::EXECUTABLE) || - (type == cmState::STATIC_LIBRARY) || - (type == cmState::SHARED_LIBRARY) || - (type == cmState::MODULE_LIBRARY) || - (type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY))) { + ((type == cmStateEnums::EXECUTABLE) || + (type == cmStateEnums::STATIC_LIBRARY) || + (type == cmStateEnums::SHARED_LIBRARY) || + (type == cmStateEnums::MODULE_LIBRARY) || + (type == cmStateEnums::OBJECT_LIBRARY) || + (type == cmStateEnums::UTILITY))) { // Add a rule to build the target by name. lg->WriteDivider(ruleFileStream); ruleFileStream << "# Target rules for targets named " << name @@ -630,11 +634,12 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( cmGeneratorTarget* gtarget = *t; int type = gtarget->GetType(); std::string name = gtarget->GetName(); - if (!name.empty() && - ((type == cmState::EXECUTABLE) || (type == cmState::STATIC_LIBRARY) || - (type == cmState::SHARED_LIBRARY) || - (type == cmState::MODULE_LIBRARY) || - (type == cmState::OBJECT_LIBRARY) || (type == cmState::UTILITY))) { + if (!name.empty() && ((type == cmStateEnums::EXECUTABLE) || + (type == cmStateEnums::STATIC_LIBRARY) || + (type == cmStateEnums::SHARED_LIBRARY) || + (type == cmStateEnums::MODULE_LIBRARY) || + (type == cmStateEnums::OBJECT_LIBRARY) || + (type == cmStateEnums::UTILITY))) { std::string makefileName; // Add a rule to build the target by name. localName = lg->GetRelativeTargetDirectory(gtarget); @@ -808,13 +813,13 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() cmLocalGenerator* tlg = gt->GetLocalGenerator(); - if (gt->GetType() == cmState::INTERFACE_LIBRARY || + if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY || gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { continue; } - cmState::Snapshot csnp = lg->GetStateSnapshot(); - cmState::Snapshot tsnp = tlg->GetStateSnapshot(); + cmStateSnapshot csnp = lg->GetStateSnapshot(); + cmStateSnapshot tsnp = tlg->GetStateSnapshot(); // Consider the directory containing the target and all its // parents until something excludes the target. @@ -847,7 +852,7 @@ size_t cmGlobalUnixMakefileGenerator3::CountProgressMarksInTarget( TargetDependSet const& depends = this->GetTargetDirectDepends(target); for (TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { - if ((*di)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*di)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } count += this->CountProgressMarksInTarget(*di, emitted); @@ -908,7 +913,7 @@ void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends( i != depends_set.end(); ++i) { // Create the target-level dependency. cmGeneratorTarget const* dep = *i; - if (dep->GetType() == cmState::INTERFACE_LIBRARY) { + if (dep->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } cmLocalUnixMakefileGenerator3* lg3 = @@ -950,13 +955,14 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule( for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; - cmState::TargetType type = target->GetType(); - if ((type == cmState::EXECUTABLE) || - (type == cmState::STATIC_LIBRARY) || - (type == cmState::SHARED_LIBRARY) || - (type == cmState::MODULE_LIBRARY) || - (type == cmState::OBJECT_LIBRARY) || - (type == cmState::GLOBAL_TARGET) || (type == cmState::UTILITY)) { + cmStateEnums::TargetType type = target->GetType(); + if ((type == cmStateEnums::EXECUTABLE) || + (type == cmStateEnums::STATIC_LIBRARY) || + (type == cmStateEnums::SHARED_LIBRARY) || + (type == cmStateEnums::MODULE_LIBRARY) || + (type == cmStateEnums::OBJECT_LIBRARY) || + (type == cmStateEnums::GLOBAL_TARGET) || + (type == cmStateEnums::UTILITY)) { std::string name = target->GetName(); if (emittedTargets.insert(name).second) { path = "... "; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 1019d86..843e5dc 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -8,7 +8,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalCommonGenerator.h" #include "cmGlobalGeneratorFactory.h" -#include "cmState.h" +#include "cmStateTypes.h" #include <iosfwd> #include <map> @@ -248,8 +248,8 @@ private: const char* GetBuildIgnoreErrorsFlag() const CM_OVERRIDE { return "-i"; } std::string GetEditCacheCommand() const CM_OVERRIDE; - std::map<cmState::Snapshot, std::set<cmGeneratorTarget const*>, - cmState::Snapshot::StrictWeakOrder> + std::map<cmStateSnapshot, std::set<cmGeneratorTarget const*>, + cmStateSnapshot::StrictWeakOrder> DirectoryTargetsMap; void InitializeProgressMarks() CM_OVERRIDE; }; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 5d9a02b..f120762 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -230,9 +230,10 @@ cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs() } bool cmGlobalVisualStudio11Generator::NeedsDeploy( - cmState::TargetType type) const + cmStateEnums::TargetType type) const { - if ((type == cmState::EXECUTABLE || type == cmState::SHARED_LIBRARY) && + if ((type == cmStateEnums::EXECUTABLE || + type == cmStateEnums::SHARED_LIBRARY) && (this->SystemIsWindowsPhone || this->SystemIsWindowsStore)) { return true; } diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h index 0c03b0a..be78544 100644 --- a/Source/cmGlobalVisualStudio11Generator.h +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -37,7 +37,7 @@ protected: static std::set<std::string> GetInstalledWindowsCESDKs(); /** Return true if the configuration needs to be deployed */ - virtual bool NeedsDeploy(cmState::TargetType type) const; + virtual bool NeedsDeploy(cmStateEnums::TargetType type) const; private: class Factory; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index ffd87e2..6941e15 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -246,7 +246,7 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject( // Write a dsp file into the SLN file, Note, that dependencies from // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmState::TargetType, + std::ostream& fout, const std::string& name, cmStateEnums::TargetType, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index eb65bcb..9953047 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -56,7 +56,7 @@ protected: const char* path, cmGeneratorTarget const* t); virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmState::TargetType type, + std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0287def..51cb315 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -8,6 +8,7 @@ #include "cmGeneratorTarget.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" +#include "cmState.h" #include "cmUuid.h" #include "cmake.h" #include <cmsys/Encoding.hxx> @@ -101,7 +102,7 @@ void cmGlobalVisualStudio7Generator::EnableLanguage( "Semicolon separated list of supported configuration types, " "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " "anything else will be ignored.", - cmState::STRING); + cmStateEnums::STRING); } // Create list of configurations requested by user's cache, if any. @@ -118,7 +119,7 @@ void cmGlobalVisualStudio7Generator::EnableLanguage( if (cmSystemTools::GetEnv("CMAKE_MSVCIDE_RUN_PATH", extraPath)) { mf->AddCacheDefinition("CMAKE_MSVCIDE_RUN_PATH", extraPath.c_str(), "Saved environment variable CMAKE_MSVCIDE_RUN_PATH", - cmState::STATIC); + cmStateEnums::STATIC); } } @@ -345,7 +346,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmGeneratorTarget const* target = *tt; - if (target->GetType() == cmState::INTERFACE_LIBRARY) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } const char* expath = target->GetProperty("EXTERNAL_MSPROJECT"); @@ -377,7 +378,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmGeneratorTarget const* target = *tt; - if (target->GetType() == cmState::INTERFACE_LIBRARY) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } bool written = false; @@ -446,7 +447,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( for (OrderedTargetDependSet::const_iterator tt = projectTargets.begin(); tt != projectTargets.end(); ++tt) { cmGeneratorTarget const* target = *tt; - if (target->GetType() == cmState::INTERFACE_LIBRARY) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME"); @@ -676,7 +677,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( // if it is a utilitiy target then only make it part of the // default build if another target depends on it int type = target->GetType(); - if (type == cmState::GLOBAL_TARGET) { + if (type == cmStateEnums::GLOBAL_TARGET) { // check if INSTALL target is part of default build if (target->GetName() == "INSTALL") { // inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties @@ -696,7 +697,7 @@ std::set<std::string> cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( } return activeConfigs; } - if (type == cmState::UTILITY && + if (type == cmStateEnums::UTILITY && !this->IsDependedOn(projectTargets, target)) { return activeConfigs; } diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 3c6ce11..4d588e6 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -120,7 +120,7 @@ protected: const char* path, cmGeneratorTarget const* t) = 0; virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmState::TargetType type, + std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = "") = 0; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 2ce0098..64808c9 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -347,7 +347,7 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations( } void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmState::TargetType type, + std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, std::string const& platformMapping) @@ -380,10 +380,10 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( } bool cmGlobalVisualStudio8Generator::NeedsDeploy( - cmState::TargetType type) const + cmStateEnums::TargetType type) const { bool needsDeploy = - (type == cmState::EXECUTABLE || type == cmState::SHARED_LIBRARY); + (type == cmStateEnums::EXECUTABLE || type == cmStateEnums::SHARED_LIBRARY); return this->TargetsWindowsCE() && needsDeploy; } @@ -402,7 +402,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends( OrderedTargetDependSet depends(unordered, std::string()); for (OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { - if ((*i)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*i)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } std::string guid = this->GetGUID((*i)->GetName().c_str()); @@ -419,7 +419,7 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies( ui != target->GetUtilities().end(); ++ui) { if (cmGeneratorTarget* depTarget = target->GetLocalGenerator()->FindGeneratorTargetToUse(ui->c_str())) { - if (depTarget->GetType() != cmState::INTERFACE_LIBRARY && + if (depTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY && depTarget->GetProperty("EXTERNAL_MSPROJECT")) { // This utility dependency names an external .vcproj target. // We use LinkLibraryDependencies="true" to link to it without diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 2543ec1..b149c9d 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -72,14 +72,14 @@ protected: bool AddCheckTarget(); /** Return true if the configuration needs to be deployed */ - virtual bool NeedsDeploy(cmState::TargetType type) const; + virtual bool NeedsDeploy(cmStateEnums::TargetType type) const; static cmIDEFlagTable const* GetExtraFlagTableVS8(); virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSolutionConfigurations( std::ostream& fout, std::vector<std::string> const& configs); virtual void WriteProjectConfigurations( - std::ostream& fout, const std::string& name, cmState::TargetType type, + std::ostream& fout, const std::string& name, cmStateEnums::TargetType type, std::vector<std::string> const& configs, const std::set<std::string>& configsPartOfDefaultBuild, const std::string& platformMapping = ""); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 6296dd2..0782182 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -10,6 +10,7 @@ #include "cmLocalVisualStudioGenerator.h" #include "cmMakefile.h" #include "cmSourceFile.h" +#include "cmState.h" #include "cmTarget.h" #include <cmsys/Encoding.hxx> @@ -81,7 +82,8 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* tgt = *t; - if (tgt->GetType() == cmState::GLOBAL_TARGET || tgt->IsImported()) { + if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET || + tgt->IsImported()) { continue; } if (!this->IsExcluded(gen[0], tgt)) { @@ -265,11 +267,11 @@ cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target) void cmGlobalVisualStudioGenerator::FollowLinkDepends( const cmGeneratorTarget* target, std::set<const cmGeneratorTarget*>& linked) { - if (target->GetType() == cmState::INTERFACE_LIBRARY) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return; } if (linked.insert(target).second && - target->GetType() == cmState::STATIC_LIBRARY) { + target->GetType() == cmStateEnums::STATIC_LIBRARY) { // Static library targets do not list their link dependencies so // we must follow them transitively now. TargetDependSet const& depends = this->GetTargetDirectDepends(target); @@ -304,7 +306,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() static bool VSLinkable(cmGeneratorTarget const* t) { - return t->IsLinkable() || t->GetType() == cmState::OBJECT_LIBRARY; + return t->IsLinkable() || t->GetType() == cmStateEnums::OBJECT_LIBRARY; } void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends( @@ -333,10 +335,10 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends( // leaving them out for the static library itself but following them // transitively for other targets. - bool allowLinkable = (target->GetType() != cmState::STATIC_LIBRARY && - target->GetType() != cmState::SHARED_LIBRARY && - target->GetType() != cmState::MODULE_LIBRARY && - target->GetType() != cmState::EXECUTABLE); + bool allowLinkable = (target->GetType() != cmStateEnums::STATIC_LIBRARY && + target->GetType() != cmStateEnums::SHARED_LIBRARY && + target->GetType() != cmStateEnums::MODULE_LIBRARY && + target->GetType() != cmStateEnums::EXECUTABLE); TargetDependSet const& depends = this->GetTargetDirectDepends(target); @@ -344,7 +346,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends( // Static libraries cannot depend on their link implementation // due to behavior (2), but they do not really need to. std::set<cmGeneratorTarget const*> linkDepends; - if (target->GetType() != cmState::STATIC_LIBRARY) { + if (target->GetType() != cmStateEnums::STATIC_LIBRARY) { for (TargetDependSet::const_iterator di = depends.begin(); di != depends.end(); ++di) { cmTargetDepend dep = *di; @@ -367,7 +369,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends( // Collect all targets linked by this target so we can avoid // intermediate targets below. TargetSet linked; - if (target->GetType() != cmState::STATIC_LIBRARY) { + if (target->GetType() != cmStateEnums::STATIC_LIBRARY) { linked = this->GetTargetLinkClosure(target); } diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx index 94cdb38..0900797 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.cxx +++ b/Source/cmGlobalWatcomWMakeGenerator.cxx @@ -5,6 +5,7 @@ #include "cmDocumentationEntry.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmake.h" cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator(cmake* cm) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b1afa5..6de4caa 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -257,7 +257,7 @@ void cmGlobalXCodeGenerator::EnableLanguage( "Semicolon separated list of supported configuration types, " "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " "anything else will be ignored.", - cmState::STRING); + cmStateEnums::STRING); } } mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); @@ -444,7 +444,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( l != tgts.end(); l++) { cmGeneratorTarget* target = *l; - if (target->GetType() == cmState::GLOBAL_TARGET) { + if (target->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } @@ -459,12 +459,12 @@ void cmGlobalXCodeGenerator::AddExtraTargets( // this will make sure that when the next target is built // things are up-to-date if (!makeHelper.empty() && - (target->GetType() == cmState::EXECUTABLE || + (target->GetType() == cmStateEnums::EXECUTABLE || // Nope - no post-build for OBJECT_LIRBRARY - // target->GetType() == cmState::OBJECT_LIBRARY || - target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::SHARED_LIBRARY || - target->GetType() == cmState::MODULE_LIBRARY)) { + // target->GetType() == cmStateEnums::OBJECT_LIBRARY || + target->GetType() == cmStateEnums::STATIC_LIBRARY || + target->GetType() == cmStateEnums::SHARED_LIBRARY || + target->GetType() == cmStateEnums::MODULE_LIBRARY)) { makeHelper[makeHelper.size() - 1] = // fill placeholder this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)"); cmCustomCommandLines commandLines; @@ -475,7 +475,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets( cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str()); } - if (target->GetType() != cmState::INTERFACE_LIBRARY && + if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY && !target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { allbuild->AddUtility(target->GetName()); } @@ -955,12 +955,12 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets( continue; } - if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } - if (gtgt->GetType() == cmState::UTILITY || - gtgt->GetType() == cmState::GLOBAL_TARGET) { + if (gtgt->GetType() == cmStateEnums::UTILITY || + gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) { cmXCodeObject* t = this->CreateUtilityTarget(gtgt); if (!t) { return false; @@ -1188,9 +1188,9 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguages() void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) { // This matters only for targets that link. - if (gtgt->GetType() != cmState::EXECUTABLE && - gtgt->GetType() != cmState::SHARED_LIBRARY && - gtgt->GetType() != cmState::MODULE_LIBRARY) { + if (gtgt->GetType() != cmStateEnums::EXECUTABLE && + gtgt->GetType() != cmStateEnums::SHARED_LIBRARY && + gtgt->GetType() != cmStateEnums::MODULE_LIBRARY) { return; } @@ -1268,7 +1268,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands( std::vector<cmCustomCommand> const& prelink = gtgt->GetPreLinkCommands(); std::vector<cmCustomCommand> postbuild = gtgt->GetPostBuildCommands(); - if (gtgt->GetType() == cmState::SHARED_LIBRARY && + if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY && !gtgt->IsFrameworkOnApple()) { cmCustomCommandLines cmd; cmd.resize(1); @@ -1590,16 +1590,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, cmXCodeObject* buildSettings, const std::string& configName) { - if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return; } std::string defFlags; - bool shared = ((gtgt->GetType() == cmState::SHARED_LIBRARY) || - (gtgt->GetType() == cmState::MODULE_LIBRARY)); - bool binary = ((gtgt->GetType() == cmState::OBJECT_LIBRARY) || - (gtgt->GetType() == cmState::STATIC_LIBRARY) || - (gtgt->GetType() == cmState::EXECUTABLE) || shared); + bool shared = ((gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) || + (gtgt->GetType() == cmStateEnums::MODULE_LIBRARY)); + bool binary = ((gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) || + (gtgt->GetType() == cmStateEnums::STATIC_LIBRARY) || + (gtgt->GetType() == cmStateEnums::EXECUTABLE) || shared); // Compute the compilation flags for each language. std::set<std::string> languages; @@ -1653,11 +1653,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string extraLinkOptionsVar; std::string extraLinkOptions; - if (gtgt->GetType() == cmState::EXECUTABLE) { + if (gtgt->GetType() == cmStateEnums::EXECUTABLE) { extraLinkOptionsVar = "CMAKE_EXE_LINKER_FLAGS"; - } else if (gtgt->GetType() == cmState::SHARED_LIBRARY) { + } else if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) { extraLinkOptionsVar = "CMAKE_SHARED_LINKER_FLAGS"; - } else if (gtgt->GetType() == cmState::MODULE_LIBRARY) { + } else if (gtgt->GetType() == cmStateEnums::MODULE_LIBRARY) { extraLinkOptionsVar = "CMAKE_MODULE_LINKER_FLAGS"; } if (!extraLinkOptionsVar.empty()) { @@ -1665,8 +1665,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, extraLinkOptions, extraLinkOptionsVar, configName); } - if (gtgt->GetType() == cmState::OBJECT_LIBRARY || - gtgt->GetType() == cmState::STATIC_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY || + gtgt->GetType() == cmStateEnums::STATIC_LIBRARY) { this->CurrentLocalGenerator->GetStaticLibraryFlags( extraLinkOptions, cmSystemTools::UpperCase(configName), gtgt); } else { @@ -1736,10 +1736,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Set attributes to specify the proper name for the target. std::string pndir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); - if (gtgt->GetType() == cmState::STATIC_LIBRARY || - gtgt->GetType() == cmState::SHARED_LIBRARY || - gtgt->GetType() == cmState::MODULE_LIBRARY || - gtgt->GetType() == cmState::EXECUTABLE) { + if (gtgt->GetType() == cmStateEnums::STATIC_LIBRARY || + gtgt->GetType() == cmStateEnums::SHARED_LIBRARY || + gtgt->GetType() == cmStateEnums::MODULE_LIBRARY || + gtgt->GetType() == cmStateEnums::EXECUTABLE) { if (this->XcodeVersion >= 21) { if (!gtgt->UsesDefaultOutputDir(configName, false)) { std::string pncdir = gtgt->GetDirectory(configName); @@ -1759,7 +1759,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CreateString(pnprefix)); buildSettings->AddAttribute("EXECUTABLE_SUFFIX", this->CreateString(pnsuffix)); - } else if (gtgt->GetType() == cmState::OBJECT_LIBRARY) { + } else if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) { pnprefix = "lib"; pnbase = gtgt->GetName(); pnsuffix = ".a"; @@ -1782,14 +1782,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Handle settings for each target type. switch (gtgt->GetType()) { - case cmState::OBJECT_LIBRARY: - case cmState::STATIC_LIBRARY: { + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("STATIC")); break; } - case cmState::MODULE_LIBRARY: { + case cmStateEnums::MODULE_LIBRARY: { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); if (gtgt->IsCFBundleOnApple()) { @@ -1839,7 +1839,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } break; } - case cmState::SHARED_LIBRARY: { + case cmStateEnums::SHARED_LIBRARY: { if (gtgt->GetPropertyAsBool("FRAMEWORK")) { std::string fw_version = gtgt->GetFrameworkVersion(); buildSettings->AddAttribute("FRAMEWORK_VERSION", @@ -1872,7 +1872,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CreateString("DYNAMIC")); break; } - case cmState::EXECUTABLE: { + case cmStateEnums::EXECUTABLE: { // Add the flags to create an executable. std::string createFlags = this->LookupFlags("CMAKE_", llang, "_LINK_FLAGS", ""); @@ -2051,7 +2051,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Create the INSTALL_PATH attribute. std::string install_name_dir; - if (gtgt->GetType() == cmState::SHARED_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) { // Get the install_name directory for the build tree. install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. @@ -2124,7 +2124,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } // Runtime version information. - if (gtgt->GetType() == cmState::SHARED_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY) { int major; int minor; int patch; @@ -2219,7 +2219,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget( this->XCodeObjectMap[gtgt] = target; // Add source files without build rules for editing convenience. - if (gtgt->GetType() == cmState::UTILITY) { + if (gtgt->GetType() == cmStateEnums::UTILITY) { std::vector<cmSourceFile*> sources; if (!gtgt->GetConfigCommonSourceFiles(sources)) { return 0; @@ -2285,8 +2285,8 @@ const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar( cmGeneratorTarget const* target) const { if (this->XcodeVersion >= 60 && - (target->GetType() == cmState::STATIC_LIBRARY || - target->GetType() == cmState::OBJECT_LIBRARY)) { + (target->GetType() == cmStateEnums::STATIC_LIBRARY || + target->GetType() == cmStateEnums::OBJECT_LIBRARY)) { return "OTHER_LIBTOOLFLAGS"; } else { return "OTHER_LDFLAGS"; @@ -2297,10 +2297,10 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType( cmGeneratorTarget* target) { switch (target->GetType()) { - case cmState::OBJECT_LIBRARY: - case cmState::STATIC_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return "archive.ar"; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: if (target->IsXCTestOnApple()) return "wrapper.cfbundle"; else if (target->IsCFBundleOnApple()) @@ -2308,11 +2308,11 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType( else return ((this->XcodeVersion >= 22) ? "compiled.mach-o.executable" : "compiled.mach-o.dylib"); - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return (target->GetPropertyAsBool("FRAMEWORK") ? "wrapper.framework" : "compiled.mach-o.dylib"); - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return "compiled.mach-o.executable"; default: break; @@ -2324,10 +2324,10 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType( cmGeneratorTarget* target) { switch (target->GetType()) { - case cmState::OBJECT_LIBRARY: - case cmState::STATIC_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return "com.apple.product-type.library.static"; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: if (target->IsXCTestOnApple()) return "com.apple.product-type.bundle.unit-test"; else if (target->IsCFBundleOnApple()) @@ -2336,11 +2336,11 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType( return ((this->XcodeVersion >= 22) ? "com.apple.product-type.tool" : "com.apple.product-type.library.dynamic"); - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return (target->GetPropertyAsBool("FRAMEWORK") ? "com.apple.product-type.framework" : "com.apple.product-type.library.dynamic"); - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return (target->GetPropertyAsBool("MACOSX_BUNDLE") ? "com.apple.product-type.application" : "com.apple.product-type.tool"); @@ -2353,7 +2353,7 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType( cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget( cmGeneratorTarget* gtgt, cmXCodeObject* buildPhases) { - if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return 0; } cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget); @@ -2380,7 +2380,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget( fileRef->AddAttribute("explicitFileType", this->CreateString(fileType)); } std::string fullName; - if (gtgt->GetType() == cmState::OBJECT_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::OBJECT_LIBRARY) { fullName = "lib"; fullName += gtgt->GetName(); fullName += ".a"; @@ -2432,8 +2432,9 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name, return storedGUID; } - this->CMakeInstance->AddCacheEntry( - guidStoreName, id.c_str(), "Stored Xcode object GUID", cmState::INTERNAL); + this->CMakeInstance->AddCacheEntry(guidStoreName, id.c_str(), + "Stored Xcode object GUID", + cmStateEnums::INTERNAL); return id; } @@ -2527,7 +2528,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) cmSystemTools::Error("Error no target on xobject\n"); return; } - if (gt->GetType() == cmState::INTERFACE_LIBRARY) { + if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return; } @@ -2564,8 +2565,8 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) } // Skip link information for object libraries. - if (gt->GetType() == cmState::OBJECT_LIBRARY || - gt->GetType() == cmState::STATIC_LIBRARY) { + if (gt->GetType() == cmStateEnums::OBJECT_LIBRARY || + gt->GetType() == cmStateEnums::STATIC_LIBRARY) { continue; } @@ -2620,7 +2621,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) if (li->IsPath) { linkLibs += this->XCodeEscapePath(li->Value); } else if (!li->Target || - li->Target->GetType() != cmState::INTERFACE_LIBRARY) { + li->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { linkLibs += li->Value; } if (li->Target && !li->Target->IsImported()) { @@ -2649,10 +2650,10 @@ bool cmGlobalXCodeGenerator::CreateGroups( // end up with (empty anyhow) ALL_BUILD and XCODE_DEPEND_HELPER source // groups: // - if (gtgt->GetType() == cmState::GLOBAL_TARGET) { + if (gtgt->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } - if (gtgt->GetType() == cmState::INTERFACE_LIBRARY) { + if (gtgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -3149,20 +3150,20 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( cmXCodeObject* target = *i; cmGeneratorTarget* gt = target->GetTarget(); - if (gt->GetType() == cmState::EXECUTABLE || + if (gt->GetType() == cmStateEnums::EXECUTABLE || // Nope - no post-build for OBJECT_LIRBRARY - // gt->GetType() == cmState::OBJECT_LIBRARY || - gt->GetType() == cmState::STATIC_LIBRARY || - gt->GetType() == cmState::SHARED_LIBRARY || - gt->GetType() == cmState::MODULE_LIBRARY) { + // gt->GetType() == cmStateEnums::OBJECT_LIBRARY || + gt->GetType() == cmStateEnums::STATIC_LIBRARY || + gt->GetType() == cmStateEnums::SHARED_LIBRARY || + gt->GetType() == cmStateEnums::MODULE_LIBRARY) { // Declare an entry point for the target post-build phase. makefileStream << this->PostBuildMakeTarget(gt->GetName(), *ct) << ":\n"; } - if (gt->GetType() == cmState::EXECUTABLE || - gt->GetType() == cmState::SHARED_LIBRARY || - gt->GetType() == cmState::MODULE_LIBRARY) { + if (gt->GetType() == cmStateEnums::EXECUTABLE || + gt->GetType() == cmStateEnums::SHARED_LIBRARY || + gt->GetType() == cmStateEnums::MODULE_LIBRARY) { std::string tfull = gt->GetFullPath(configName); std::string trel = this->ConvertToRelativeForMake(tfull.c_str()); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index db11bd3..6b32f73 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -24,13 +24,13 @@ static const char* getShapeForTarget(const cmGeneratorTarget* target) } switch (target->GetType()) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return "house"; - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return "diamond"; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return "polygon"; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: return "octagon"; default: break; @@ -495,16 +495,16 @@ bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name) } bool cmGraphVizWriter::GenerateForTargetType( - cmState::TargetType targetType) const + cmStateEnums::TargetType targetType) const { switch (targetType) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return this->GenerateForExecutables; - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return this->GenerateForStaticLibs; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return this->GenerateForSharedLibs; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: return this->GenerateForModuleLibs; default: break; diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 0efe2b7..1ff07ab 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -5,7 +5,7 @@ #include <cmConfigure.h> // IWYU pragma: keep -#include "cmState.h" +#include "cmStateTypes.h" #include <cmsys/RegularExpression.hxx> #include <map> @@ -60,7 +60,7 @@ protected: bool IgnoreThisTarget(const std::string& name); - bool GenerateForTargetType(cmState::TargetType targetType) const; + bool GenerateForTargetType(cmStateEnums::TargetType targetType) const; std::string GraphType; std::string GraphName; diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx index 166bc7c..d598722 100644 --- a/Source/cmIncludeExternalMSProjectCommand.cxx +++ b/Source/cmIncludeExternalMSProjectCommand.cxx @@ -66,12 +66,12 @@ bool cmIncludeExternalMSProjectCommand::InitialPass( std::string guidVariable = utility_name + "_GUID_CMAKE"; this->Makefile->GetCMakeInstance()->AddCacheEntry( guidVariable.c_str(), customGuid.c_str(), "Stored GUID", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } // Create a target instance for this utility. - cmTarget* target = - this->Makefile->AddNewTarget(cmState::UTILITY, utility_name.c_str()); + cmTarget* target = this->Makefile->AddNewTarget(cmStateEnums::UTILITY, + utility_name.c_str()); target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str()); target->SetProperty("EXTERNAL_MSPROJECT", path.c_str()); diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index f040a4e..d85748e 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -327,19 +327,19 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) if (cmTarget* target = this->Makefile->FindLocalNonAliasTarget(*targetIt)) { // Found the target. Check its type. - if (target->GetType() != cmState::EXECUTABLE && - target->GetType() != cmState::STATIC_LIBRARY && - target->GetType() != cmState::SHARED_LIBRARY && - target->GetType() != cmState::MODULE_LIBRARY && - target->GetType() != cmState::OBJECT_LIBRARY && - target->GetType() != cmState::INTERFACE_LIBRARY) { + if (target->GetType() != cmStateEnums::EXECUTABLE && + target->GetType() != cmStateEnums::STATIC_LIBRARY && + target->GetType() != cmStateEnums::SHARED_LIBRARY && + target->GetType() != cmStateEnums::MODULE_LIBRARY && + target->GetType() != cmStateEnums::OBJECT_LIBRARY && + target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "TARGETS given target \"" << (*targetIt) << "\" which is not an executable, library, or module."; this->SetError(e.str()); return false; } - if (target->GetType() == cmState::OBJECT_LIBRARY) { + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "TARGETS given OBJECT library \"" << (*targetIt) << "\" which may not be installed."; @@ -387,7 +387,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) bool namelinkOnly = false; switch (target.GetType()) { - case cmState::SHARED_LIBRARY: { + case cmStateEnums::SHARED_LIBRARY: { // Shared libraries are handled differently on DLL and non-DLL // platforms. All windows platforms are DLL platforms including // cygwin. Currently no other platform is a DLL platform. @@ -454,7 +454,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) } } } break; - case cmState::STATIC_LIBRARY: { + case cmStateEnums::STATIC_LIBRARY: { // Static libraries use ARCHIVE properties. if (!archiveArgs.GetDestination().empty()) { archiveGenerator = @@ -468,7 +468,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } } break; - case cmState::MODULE_LIBRARY: { + case cmStateEnums::MODULE_LIBRARY: { // Modules use LIBRARY properties. if (!libraryArgs.GetDestination().empty()) { libraryGenerator = @@ -484,7 +484,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } } break; - case cmState::EXECUTABLE: { + case cmStateEnums::EXECUTABLE: { if (target.IsAppBundleOnApple()) { // Application bundles use the BUNDLE properties. if (!bundleArgs.GetDestination().empty()) { @@ -534,7 +534,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) CreateInstallTargetGenerator(target, archiveArgs, true, true); } } break; - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: // Nothing to do. An INTERFACE_LIBRARY can be installed, but the // only effect of that is to make it exportable. It installs no // other files itself. @@ -553,7 +553,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) bool createInstallGeneratorsForTargetFileSets = true; if (target.IsFrameworkOnApple() || - target.GetType() == cmState::INTERFACE_LIBRARY) { + target.GetType() == cmStateEnums::INTERFACE_LIBRARY) { createInstallGeneratorsForTargetFileSets = false; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 70ae204..f1df073 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -9,7 +9,7 @@ #include "cmInstallType.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cm_auto_ptr.hxx" @@ -80,36 +80,36 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( std::vector<std::string> filesFrom; std::vector<std::string> filesTo; std::string literal_args; - cmState::TargetType targetType = this->Target->GetType(); + cmStateEnums::TargetType targetType = this->Target->GetType(); cmInstallType type = cmInstallType(); switch (targetType) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: type = cmInstallType_EXECUTABLE; break; - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: type = cmInstallType_STATIC_LIBRARY; break; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: type = cmInstallType_SHARED_LIBRARY; break; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: type = cmInstallType_MODULE_LIBRARY; break; - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: // Not reachable. We never create a cmInstallTargetGenerator for // an INTERFACE_LIBRARY. assert(0 && "INTERFACE_LIBRARY targets have no installable outputs."); break; - case cmState::OBJECT_LIBRARY: - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: - case cmState::UNKNOWN_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::UNKNOWN_LIBRARY: this->Target->GetLocalGenerator()->IssueMessage( cmake::INTERNAL_ERROR, "cmInstallTargetGenerator created with non-installable target."); return; } - if (targetType == cmState::EXECUTABLE) { + if (targetType == cmStateEnums::EXECUTABLE) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); @@ -337,7 +337,7 @@ std::string cmInstallTargetGenerator::GetInstallFilename( { std::string fname; // Compute the name of the library. - if (target->GetType() == cmState::EXECUTABLE) { + if (target->GetType() == cmStateEnums::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; @@ -471,9 +471,9 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule( std::string const& toDestDirPath) { if (this->ImportLibrary || - !(this->Target->GetType() == cmState::SHARED_LIBRARY || - this->Target->GetType() == cmState::MODULE_LIBRARY || - this->Target->GetType() == cmState::EXECUTABLE)) { + !(this->Target->GetType() == cmStateEnums::SHARED_LIBRARY || + this->Target->GetType() == cmStateEnums::MODULE_LIBRARY || + this->Target->GetType() == cmStateEnums::EXECUTABLE)) { return; } @@ -527,7 +527,7 @@ void cmInstallTargetGenerator::AddInstallNamePatchRule( // Edit the install_name of the target itself if necessary. std::string new_id; - if (this->Target->GetType() == cmState::SHARED_LIBRARY) { + if (this->Target->GetType() == cmStateEnums::SHARED_LIBRARY) { std::string for_build = this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = this->Target->GetInstallNameDirForInstallTree(); @@ -704,7 +704,7 @@ void cmInstallTargetGenerator::AddStripRule(std::ostream& os, // don't strip static and import libraries, because it removes the only // symbol table they have so you can't link to them anymore - if (this->Target->GetType() == cmState::STATIC_LIBRARY || + if (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY || this->ImportLibrary) { return; } @@ -731,7 +731,7 @@ void cmInstallTargetGenerator::AddRanlibRule(std::ostream& os, const std::string& toDestDirPath) { // Static libraries need ranlib on this platform. - if (this->Target->GetType() != cmState::STATIC_LIBRARY) { + if (this->Target->GetType() != cmStateEnums::STATIC_LIBRARY) { return; } @@ -767,10 +767,10 @@ void cmInstallTargetGenerator::AddUniversalInstallRule( } switch (this->Target->GetType()) { - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: break; default: diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 24f3578..c271246 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -5,9 +5,10 @@ #include "cmComputeLinkInformation.h" #include "cmGeneratorTarget.h" #include "cmOutputConverter.h" +#include "cmStateDirectory.h" cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter, - cmState::Directory stateDir) + cmStateDirectory stateDir) : StateDir(stateDir) , OutputConverter(outputConverter) , ForResponse(false) @@ -55,7 +56,8 @@ std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) ItemVector const& items = cli.GetItems(); for (ItemVector::const_iterator li = items.begin(); li != items.end(); ++li) { - if (li->Target && li->Target->GetType() == cmState::INTERFACE_LIBRARY) { + if (li->Target && + li->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } if (li->IsPath) { diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index 1fb9b24..6bbb69e 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -4,7 +4,7 @@ #ifndef cmLinkLineComputer_h #define cmLinkLineComputer_h -#include "cmState.h" +#include "cmStateDirectory.h" class cmComputeLinkInformation; class cmOutputConverter; @@ -13,7 +13,7 @@ class cmLinkLineComputer { public: cmLinkLineComputer(cmOutputConverter* outputConverter, - cmState::Directory stateDir); + cmStateDirectory stateDir); virtual ~cmLinkLineComputer(); void SetUseWatcomQuote(bool useWatcomQuote); @@ -39,7 +39,7 @@ private: std::string ConvertToOutputFormat(std::string const& input); std::string ConvertToOutputForExisting(std::string const& input); - cmState::Directory StateDir; + cmStateDirectory StateDir; cmOutputConverter* OutputConverter; bool ForResponse; diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 5e6273c..b1cd889 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -5,6 +5,7 @@ #include "cmListFileLexer.h" #include "cmMessenger.h" #include "cmOutputConverter.h" +#include "cmState.h" #include "cmSystemTools.h" #include "cmake.h" @@ -298,7 +299,7 @@ struct cmListFileBacktrace::Entry : public cmListFileContext unsigned int RefCount; }; -cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot bottom, Entry* up, +cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot bottom, Entry* up, cmListFileContext const& lfc) : Bottom(bottom) , Cur(new Entry(lfc, up)) @@ -307,7 +308,7 @@ cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot bottom, Entry* up, this->Cur->Ref(); } -cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur) +cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot bottom, Entry* cur) : Bottom(bottom) , Cur(cur) { @@ -323,7 +324,7 @@ cmListFileBacktrace::cmListFileBacktrace() { } -cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot snapshot) +cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot snapshot) : Bottom(snapshot.GetCallStackBottom()) , Cur(CM_NULLPTR) { diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index fd779c7..1a30f29 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -9,7 +9,7 @@ #include <string> #include <vector> -#include "cmState.h" +#include "cmStateSnapshot.h" /** \class cmListFileCache * \brief A class to cache list file contents. @@ -113,14 +113,14 @@ public: // Construct an empty backtrace whose bottom sits in the directory // indicated by the given valid snapshot. - cmListFileBacktrace(cmState::Snapshot snapshot); + cmListFileBacktrace(cmStateSnapshot snapshot); // Backtraces may be copied and assigned as values. cmListFileBacktrace(cmListFileBacktrace const& r); cmListFileBacktrace& operator=(cmListFileBacktrace const& r); ~cmListFileBacktrace(); - cmState::Snapshot GetBottom() const { return this->Bottom; } + cmStateSnapshot GetBottom() const { return this->Bottom; } // Get a backtrace with the given file scope added to the top. // May not be called until after construction with a valid snapshot. @@ -147,11 +147,11 @@ public: private: struct Entry; - cmState::Snapshot Bottom; + cmStateSnapshot Bottom; Entry* Cur; - cmListFileBacktrace(cmState::Snapshot bottom, Entry* up, + cmListFileBacktrace(cmStateSnapshot bottom, Entry* up, cmListFileContext const& lfc); - cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur); + cmListFileBacktrace(cmStateSnapshot bottom, Entry* cur); }; struct cmListFile diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index 3428a6c..49db5b0 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -140,7 +140,7 @@ void cmLoadCacheCommand::CheckLine(const char* line) // Check one line of the cache file. std::string var; std::string value; - cmState::CacheEntryType type = cmState::UNINITIALIZED; + cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED; if (cmake::ParseCacheEntry(line, var, value, type)) { // Found a real entry. See if this one was requested. if (this->VariablesToRead.find(var) != this->VariablesToRead.end()) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1c3a97d..4aecb1d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -16,6 +16,8 @@ #include "cmMakefile.h" #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" +#include "cmState.h" +#include "cmStateDirectory.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTestGenerator.h" @@ -199,7 +201,7 @@ void cmLocalGenerator::TraceDependencies() std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); t != targets.end(); ++t) { - if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } (*t)->TraceDependencies(); @@ -249,7 +251,7 @@ void cmLocalGenerator::GenerateTestFiles() (*gi)->Compute(this); (*gi)->Generate(fout, config, configurationTypes); } - typedef std::vector<cmState::Snapshot> vec_t; + typedef std::vector<cmStateSnapshot> vec_t; vec_t const& children = this->Makefile->GetStateSnapshot().GetChildren(); std::string parentBinDir = this->GetCurrentBinaryDirectory(); for (vec_t::const_iterator i = children.begin(); i != children.end(); ++i) { @@ -446,12 +448,12 @@ void cmLocalGenerator::GenerateInstallRules() this->GenerateTargetInstallRules(fout, config, configurationTypes); // Include install scripts from subdirectories. - std::vector<cmState::Snapshot> children = + std::vector<cmStateSnapshot> children = this->Makefile->GetStateSnapshot().GetChildren(); if (!children.empty()) { fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"; fout << " # Include the install script for each subdirectory.\n"; - for (std::vector<cmState::Snapshot>::const_iterator ci = children.begin(); + for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin(); ci != children.end(); ++ci) { if (!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) { std::string odir = ci->GetDirectory().GetCurrentBinary(); @@ -542,7 +544,7 @@ void cmLocalGenerator::ComputeTargetManifest() for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); t != targets.end(); ++t) { cmGeneratorTarget* target = *t; - if (target->GetType() == cmState::INTERFACE_LIBRARY) { + if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } for (std::vector<std::string>::iterator ci = configNames.begin(); @@ -563,7 +565,7 @@ cmState* cmLocalGenerator::GetState() const return this->GlobalGenerator->GetCMakeInstance()->GetState(); } -cmState::Snapshot cmLocalGenerator::GetStateSnapshot() const +cmStateSnapshot cmLocalGenerator::GetStateSnapshot() const { return this->Makefile->GetStateSnapshot(); } @@ -911,12 +913,12 @@ void cmLocalGenerator::GetTargetFlags( "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library switch (target->GetType()) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: this->GetStaticLibraryFlags(linkFlags, buildType, target); break; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; - case cmState::SHARED_LIBRARY: { + case cmStateEnums::SHARED_LIBRARY: { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; if (!buildType.empty()) { @@ -962,7 +964,7 @@ void cmLocalGenerator::GetTargetFlags( frameworkPath, linkPath); } } break; - case cmState::EXECUTABLE: { + case cmStateEnums::EXECUTABLE: { linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; if (!buildType.empty()) { @@ -1189,7 +1191,7 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065( std::string linkFlags; // Flags to link an executable to shared libraries. - if (tgt.GetType() == cmState::EXECUTABLE && + if (tgt.GetType() == cmStateEnums::EXECUTABLE && this->StateSnapshot.GetState()->GetGlobalPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS")) { bool add_shlib_flags = false; @@ -1334,8 +1336,8 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, // found is part of the inName if (cmSystemTools::FileIsFullPath(inName.c_str())) { std::string tLocation; - if (target->GetType() >= cmState::EXECUTABLE && - target->GetType() <= cmState::MODULE_LIBRARY) { + if (target->GetType() >= cmStateEnums::EXECUTABLE && + target->GetType() <= cmStateEnums::MODULE_LIBRARY) { tLocation = target->GetLocation(config); tLocation = cmSystemTools::GetFilenamePath(tLocation); tLocation = cmSystemTools::CollapseFullPath(tLocation); @@ -1352,23 +1354,23 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName, } } switch (target->GetType()) { - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::UNKNOWN_LIBRARY: + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: dep = target->GetLocation(config); return true; - case cmState::OBJECT_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: // An object library has no single file on which to depend. // This was listed to get the target-level dependency. return false; - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: // An interface library has no file on which to depend. // This was listed to get the target-level dependency. return false; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: // A utility target has no file on which to depend. This was listed // only to get the target-level dependency. return false; @@ -1584,8 +1586,8 @@ void cmLocalGenerator::AddVisibilityPresetFlags( std::string warnCMP0063; std::string* pWarnCMP0063 = CM_NULLPTR; - if (target->GetType() != cmState::SHARED_LIBRARY && - target->GetType() != cmState::MODULE_LIBRARY && + if (target->GetType() != cmStateEnums::SHARED_LIBRARY && + target->GetType() != cmStateEnums::MODULE_LIBRARY && !target->IsExecutableWithExports()) { switch (target->GetPolicyStatusCMP0063()) { case cmPolicies::OLD: @@ -1627,13 +1629,13 @@ void cmLocalGenerator::AddCMP0018Flags(std::string& flags, { int targetType = target->GetType(); - bool shared = ((targetType == cmState::SHARED_LIBRARY) || - (targetType == cmState::MODULE_LIBRARY)); + bool shared = ((targetType == cmStateEnums::SHARED_LIBRARY) || + (targetType == cmStateEnums::MODULE_LIBRARY)); if (this->GetShouldUseOldFlags(shared, lang)) { this->AddSharedFlags(flags, lang, shared); } else { - if (target->GetType() == cmState::OBJECT_LIBRARY) { + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE")) { this->AddPositionIndependentFlags(flags, lang, targetType); } @@ -1696,7 +1698,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, { const char* picFlags = CM_NULLPTR; - if (targetType == cmState::EXECUTABLE) { + if (targetType == cmStateEnums::EXECUTABLE) { std::string flagsVar = "CMAKE_"; flagsVar += lang; flagsVar += "_COMPILE_OPTIONS_PIE"; @@ -1868,7 +1870,7 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, featureName += "_"; featureName += cmSystemTools::UpperCase(config); } - cmState::Snapshot snp = this->StateSnapshot; + cmStateSnapshot snp = this->StateSnapshot; while (snp.IsValid()) { if (const char* value = snp.GetDirectory().GetProperty(featureName)) { return value; @@ -1933,7 +1935,7 @@ void cmLocalGenerator::GenerateTargetInstallRules( std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } @@ -1956,15 +1958,15 @@ void cmLocalGenerator::GenerateTargetInstallRules( // Generate the proper install generator for this target type. switch ((*l)->GetType()) { - case cmState::EXECUTABLE: - case cmState::STATIC_LIBRARY: - case cmState::MODULE_LIBRARY: { + case cmStateEnums::EXECUTABLE: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: { // Use a target install generator. cmInstallTargetGeneratorLocal g(this, (*l)->GetName(), destination.c_str(), false); g.Generate(os, config, configurationTypes); } break; - case cmState::SHARED_LIBRARY: { + case cmStateEnums::SHARED_LIBRARY: { #if defined(_WIN32) || defined(__CYGWIN__) // Special code to handle DLL. Install the import library // to the normal destination and the DLL to the runtime diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 055e1a9..6314aff 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -9,7 +9,7 @@ #include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmRulePlaceholderExpander.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmake.h" #include <cm_kwiml.h> @@ -92,7 +92,7 @@ public: cmGeneratorTarget& tgt) const; cmState* GetState() const; - cmState::Snapshot GetStateSnapshot() const; + cmStateSnapshot GetStateSnapshot() const; void AddArchitectureFlags(std::string& flags, cmGeneratorTarget const* target, @@ -337,7 +337,7 @@ protected: virtual bool CheckDefinition(std::string const& define) const; cmMakefile* Makefile; - cmState::Snapshot StateSnapshot; + cmStateSnapshot StateSnapshot; cmListFileBacktrace DirectoryBacktrace; cmGlobalGenerator* GlobalGenerator; std::map<std::string, std::string> UniqueObjectNamesMap; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 157b32e..5f37af5 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -24,7 +24,7 @@ void cmLocalGhsMultiGenerator::Generate() for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } cmGhsMultiTargetGenerator tg(*l); diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 1863376..cd9af54 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -13,6 +13,7 @@ #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" @@ -81,7 +82,7 @@ void cmLocalNinjaGenerator::Generate() std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); t != targets.end(); ++t) { - if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(*t); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f30414c..4f81ef1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -17,6 +17,8 @@ #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateDirectory.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmVersion.h" #include "cmake.h" @@ -120,7 +122,7 @@ void cmLocalUnixMakefileGenerator3::Generate() static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator); for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); t != targets.end(); ++t) { - if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*t)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } CM_AUTO_PTR<cmMakefileTargetGenerator> tg( @@ -172,7 +174,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles( for (std::vector<cmGeneratorTarget*>::iterator ti = targets.begin(); ti != targets.end(); ++ti) { cmGeneratorTarget* gt = *ti; - if (gt->GetType() == cmState::INTERFACE_LIBRARY) { + if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } std::vector<cmSourceFile const*> objectSources; @@ -382,12 +384,12 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( std::string localName; for (std::vector<cmGeneratorTarget*>::iterator t = targets.begin(); t != targets.end(); ++t) { - if (((*t)->GetType() == cmState::EXECUTABLE) || - ((*t)->GetType() == cmState::STATIC_LIBRARY) || - ((*t)->GetType() == cmState::SHARED_LIBRARY) || - ((*t)->GetType() == cmState::MODULE_LIBRARY) || - ((*t)->GetType() == cmState::OBJECT_LIBRARY) || - ((*t)->GetType() == cmState::UTILITY)) { + if (((*t)->GetType() == cmStateEnums::EXECUTABLE) || + ((*t)->GetType() == cmStateEnums::STATIC_LIBRARY) || + ((*t)->GetType() == cmStateEnums::SHARED_LIBRARY) || + ((*t)->GetType() == cmStateEnums::MODULE_LIBRARY) || + ((*t)->GetType() == cmStateEnums::OBJECT_LIBRARY) || + ((*t)->GetType() == cmStateEnums::UTILITY)) { emitted.insert((*t)->GetName()); // for subdirs add a rule to build this specific target by name. @@ -1558,7 +1560,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( std::vector<cmGeneratorTarget*> targets = this->GetGeneratorTargets(); std::vector<cmGeneratorTarget*>::iterator glIt; for (glIt = targets.begin(); glIt != targets.end(); ++glIt) { - if ((*glIt)->GetType() == cmState::GLOBAL_TARGET) { + if ((*glIt)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::string targetString = "Special rule for the target " + (*glIt)->GetName(); std::vector<std::string> commands; diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 6f9f009..0516bdf 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -63,7 +63,7 @@ void cmLocalVisualStudio10Generator::Generate() std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } if (static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator) @@ -95,7 +95,7 @@ void cmLocalVisualStudio10Generator::ReadAndStoreExternalGUID( // save the GUID in the cache this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry( guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } const char* cmLocalVisualStudio10Generator::ReportErrorLabel() const diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index a4b28b5..7c32e6c 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -64,7 +64,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } const char* path = (*l)->GetProperty("EXTERNAL_MSPROJECT"); @@ -93,7 +93,7 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules() std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); ++l) { - if ((*l)->GetType() == cmState::GLOBAL_TARGET) { + if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } if ((*l)->GetName() != CMAKE_CHECK_BUILD_SYSTEM_TARGET) { @@ -112,7 +112,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() std::vector<cmGeneratorTarget*> tgts = this->GetGeneratorTargets(); for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); l++) { - if ((*l)->GetType() == cmState::GLOBAL_TARGET) { + if ((*l)->GetType() == cmStateEnums::GLOBAL_TARGET) { std::vector<std::string> no_depends; cmCustomCommandLine force_command; force_command.push_back("cd"); @@ -154,7 +154,7 @@ void cmLocalVisualStudio7Generator::WriteProjectFiles() // Create the project file for each target. for (std::vector<cmGeneratorTarget*>::iterator l = tgts.begin(); l != tgts.end(); l++) { - if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) { + if ((*l)->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace @@ -615,22 +615,22 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( bool targetBuilds = true; switch (target->GetType()) { - case cmState::OBJECT_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: targetBuilds = false; // no manifest tool for object library - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: projectType = "typeStaticLibrary"; configType = "4"; break; - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: projectType = "typeDynamicLibrary"; configType = "2"; break; - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: configType = "1"; break; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: configType = "10"; default: targetBuilds = false; @@ -725,8 +725,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( intermediateDir += "/"; intermediateDir += configName; - if (target->GetType() < cmState::UTILITY) { - std::string const& outDir = target->GetType() == cmState::OBJECT_LIBRARY + if (target->GetType() < cmStateEnums::UTILITY) { + std::string const& outDir = + target->GetType() == cmStateEnums::OBJECT_LIBRARY ? intermediateDir : target->GetDirectory(configName); /* clang-format off */ @@ -810,7 +811,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( targetOptions.OutputFlagMap(fout, "\t\t\t\t"); targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX"); fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; - if (target->GetType() <= cmState::OBJECT_LIBRARY) { + if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. std::string pdb = target->GetCompilePDBPath(configName); if (!pdb.empty()) { @@ -959,19 +960,19 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator); std::string temp; std::string extraLinkOptions; - if (target->GetType() == cmState::EXECUTABLE) { + if (target->GetType() == cmStateEnums::EXECUTABLE) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName); } - if (target->GetType() == cmState::SHARED_LIBRARY) { + if (target->GetType() == cmStateEnums::SHARED_LIBRARY) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") + std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName); } - if (target->GetType() == cmState::MODULE_LIBRARY) { + if (target->GetType() == cmStateEnums::MODULE_LIBRARY) { extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") + std::string(" ") + @@ -1004,7 +1005,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } - if ((target->GetType() == cmState::SHARED_LIBRARY || + if ((target->GetType() == cmStateEnums::SHARED_LIBRARY || target->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1012,9 +1013,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( } } switch (target->GetType()) { - case cmState::UNKNOWN_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: break; - case cmState::OBJECT_LIBRARY: { + case cmStateEnums::OBJECT_LIBRARY: { std::string libpath = this->GetTargetDirectory(target); libpath += "/"; libpath += configName; @@ -1029,7 +1030,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n"; break; } - case cmState::STATIC_LIBRARY: { + case cmStateEnums::STATIC_LIBRARY: { std::string targetNameFull = target->GetFullName(configName); std::string libpath = target->GetDirectory(configName); libpath += "/"; @@ -1059,8 +1060,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( << this->ConvertToXMLOutputPathSingle(libpath.c_str()) << "\"/>\n"; break; } - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: { + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: { std::string targetName; std::string targetNameSO; std::string targetNameFull; @@ -1145,7 +1146,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( } fout << "/>\n"; } break; - case cmState::EXECUTABLE: { + case cmStateEnums::EXECUTABLE: { std::string targetName; std::string targetNameFull; std::string targetNameImport; @@ -1241,9 +1242,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n"; break; } - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::INTERFACE_LIBRARY: break; } } @@ -1296,7 +1297,7 @@ void cmLocalVisualStudio7GeneratorInternals::OutputLibraries( lg->ConvertToRelativePath(currentBinDir, l->Value.c_str()); fout << lg->ConvertToXMLOutputPath(rel.c_str()) << " "; } else if (!l->Target || - l->Target->GetType() != cmState::INTERFACE_LIBRARY) { + l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { fout << l->Value << " "; } } @@ -1607,8 +1608,8 @@ bool cmLocalVisualStudio7Generator::WriteGroup( std::string source = (*sf)->GetFullPath(); FCInfo fcinfo(this, target, *(*sf), configs); - if (source != libName || target->GetType() == cmState::UTILITY || - target->GetType() == cmState::GLOBAL_TARGET) { + if (source != libName || target->GetType() == cmStateEnums::UTILITY || + target->GetType() == cmStateEnums::GLOBAL_TARGET) { fout << "\t\t\t<File\n"; std::string d = this->ConvertToXMLOutputPathSingle(source.c_str()); // Tell MS-Dev what the source is. If the compiler knows how to @@ -1812,7 +1813,7 @@ void cmLocalVisualStudio7Generator::OutputTargetRules( std::ostream& fout, const std::string& configName, cmGeneratorTarget* target, const std::string& /*libName*/) { - if (target->GetType() > cmState::GLOBAL_TARGET) { + if (target->GetType() > cmStateEnums::GLOBAL_TARGET) { return; } EventWriter event(this, configName, fout); @@ -1828,7 +1829,7 @@ void cmLocalVisualStudio7Generator::OutputTargetRules( tool = this->FortranProject ? "VFPreLinkEventTool" : "VCPreLinkEventTool"; event.Start(tool); bool addedPrelink = false; - if ((target->GetType() == cmState::SHARED_LIBRARY || + if ((target->GetType() == cmStateEnums::SHARED_LIBRARY || target->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (target->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1900,27 +1901,27 @@ void cmLocalVisualStudio7Generator::WriteProjectStartFortran( } const char* projectType = 0; switch (target->GetType()) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: projectType = "typeStaticLibrary"; if (keyword) { keyword = "Static Library"; } break; - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: projectType = "typeDynamicLibrary"; if (!keyword) { keyword = "Dll"; } break; - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: if (!keyword) { keyword = "Console Application"; } projectType = 0; break; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: default: break; } @@ -2117,7 +2118,7 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID( // save the GUID in the cache this->GlobalGenerator->GetCMakeInstance()->AddCacheEntry( guidStoreName.c_str(), parser.GUID.c_str(), "Stored GUID", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } std::string cmLocalVisualStudio7Generator::GetTargetDirectory( diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index e2b3cd2..e20fe50 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -76,8 +76,8 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target, // If an executable exports symbols then VS wants to create an // import library but forgets to create the output directory. // The Intel Fortran plugin always forgets to the directory. - if (target->GetType() != cmState::EXECUTABLE && - !(isFortran && target->GetType() == cmState::SHARED_LIBRARY)) { + if (target->GetType() != cmStateEnums::EXECUTABLE && + !(isFortran && target->GetType() == cmStateEnums::SHARED_LIBRARY)) { return pcc; } std::string outDir = target->GetDirectory(config, false); diff --git a/Source/cmMSVC60LinkLineComputer.cxx b/Source/cmMSVC60LinkLineComputer.cxx index 2b6df2a..9308d91 100644 --- a/Source/cmMSVC60LinkLineComputer.cxx +++ b/Source/cmMSVC60LinkLineComputer.cxx @@ -6,7 +6,7 @@ #include "cmSystemTools.h" cmMSVC60LinkLineComputer::cmMSVC60LinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir) + cmOutputConverter* outputConverter, cmStateDirectory stateDir) : cmLinkLineComputer(outputConverter, stateDir) { } diff --git a/Source/cmMSVC60LinkLineComputer.h b/Source/cmMSVC60LinkLineComputer.h index ca9da31..381b8a2 100644 --- a/Source/cmMSVC60LinkLineComputer.h +++ b/Source/cmMSVC60LinkLineComputer.h @@ -10,7 +10,7 @@ class cmMSVC60LinkLineComputer : public cmLinkLineComputer { public: cmMSVC60LinkLineComputer(cmOutputConverter* outputConverter, - cmState::Directory stateDir); + cmStateDirectory stateDir); std::string ConvertToLinkReference(std::string const& input) const CM_OVERRIDE; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c3111c0..00c0e82 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -18,6 +18,8 @@ #include "cmSourceFile.h" #include "cmSourceFileLocation.h" #include "cmState.h" +#include "cmStateDirectory.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTest.h" #include "cmVersion.h" @@ -45,7 +47,7 @@ class cmMessenger; // default is not to be building executables cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, - cmState::Snapshot const& snapshot) + cmStateSnapshot const& snapshot) : GlobalGenerator(globalGenerator) , StateSnapshot(snapshot) , Backtrace(snapshot) @@ -730,7 +732,7 @@ void cmMakefile::AddCustomCommandToTarget( return; } - if (ti->second.GetType() == cmState::OBJECT_LIBRARY) { + if (ti->second.GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an OBJECT library " @@ -738,7 +740,7 @@ void cmMakefile::AddCustomCommandToTarget( this->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } - if (ti->second.GetType() == cmState::INTERFACE_LIBRARY) { + if (ti->second.GetType() == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "Target \"" << target << "\" is an INTERFACE library " @@ -1032,7 +1034,7 @@ cmTarget* cmMakefile::AddUtilityCommand( const char* comment, bool uses_terminal) { // Create a target instance for this utility. - cmTarget* target = this->AddNewTarget(cmState::UTILITY, utilityName); + cmTarget* target = this->AddNewTarget(cmStateEnums::UTILITY, utilityName); if (excludeFromAll) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } @@ -1356,7 +1358,7 @@ private: cmMakefile* Makefile; cmGlobalGenerator* GG; cmMakefile* CurrentMakefile; - cmState::Snapshot Snapshot; + cmStateSnapshot Snapshot; bool ReportError; }; @@ -1538,7 +1540,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, return; } - cmState::Snapshot newSnapshot = + cmStateSnapshot newSnapshot = this->GetState()->CreateBuildsystemDirectorySnapshot(this->StateSnapshot); newSnapshot.GetDirectory().SetCurrentSource(srcPath); @@ -1643,20 +1645,21 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value) void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, const char* doc, - cmState::CacheEntryType type, bool force) + cmStateEnums::CacheEntryType type, + bool force) { const char* existingValue = this->GetState()->GetInitializedCacheValue(name); // must be outside the following if() to keep it alive long enough std::string nvalue; - if (existingValue && - (this->GetState()->GetCacheEntryType(name) == cmState::UNINITIALIZED)) { + if (existingValue && (this->GetState()->GetCacheEntryType(name) == + cmStateEnums::UNINITIALIZED)) { // if this is not a force, then use the value from the cache // if it is a force, then use the value being passed in if (!force) { value = existingValue; } - if (type == cmState::PATH || type == cmState::FILEPATH) { + if (type == cmStateEnums::PATH || type == cmStateEnums::FILEPATH) { std::vector<std::string>::size_type cc; std::vector<std::string> files; nvalue = value ? value : ""; @@ -1774,9 +1777,9 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target) { // for these targets do not add anything switch (target.GetType()) { - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: + case cmStateEnums::INTERFACE_LIBRARY: return; default:; } @@ -1828,13 +1831,15 @@ void cmMakefile::AddAlias(const std::string& lname, std::string const& tgtName) } cmTarget* cmMakefile::AddLibrary(const std::string& lname, - cmState::TargetType type, + cmStateEnums::TargetType type, const std::vector<std::string>& srcs, bool excludeFromAll) { - assert(type == cmState::STATIC_LIBRARY || type == cmState::SHARED_LIBRARY || - type == cmState::MODULE_LIBRARY || type == cmState::OBJECT_LIBRARY || - type == cmState::INTERFACE_LIBRARY); + assert(type == cmStateEnums::STATIC_LIBRARY || + type == cmStateEnums::SHARED_LIBRARY || + type == cmStateEnums::MODULE_LIBRARY || + type == cmStateEnums::OBJECT_LIBRARY || + type == cmStateEnums::INTERFACE_LIBRARY); cmTarget* target = this->AddNewTarget(type, lname); // Clear its dependencies. Otherwise, dependencies might persist @@ -1853,7 +1858,7 @@ cmTarget* cmMakefile::AddExecutable(const char* exeName, const std::vector<std::string>& srcs, bool excludeFromAll) { - cmTarget* target = this->AddNewTarget(cmState::EXECUTABLE, exeName); + cmTarget* target = this->AddNewTarget(cmStateEnums::EXECUTABLE, exeName); if (excludeFromAll) { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } @@ -1862,7 +1867,7 @@ cmTarget* cmMakefile::AddExecutable(const char* exeName, return target; } -cmTarget* cmMakefile::AddNewTarget(cmState::TargetType type, +cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type, const std::string& name) { cmTargets::iterator it = @@ -2040,8 +2045,8 @@ void cmMakefile::ExpandVariablesCMP0019() for (cmTargets::iterator l = this->Targets.begin(); l != this->Targets.end(); ++l) { cmTarget& t = l->second; - if (t.GetType() == cmState::INTERFACE_LIBRARY || - t.GetType() == cmState::GLOBAL_TARGET) { + if (t.GetType() == cmStateEnums::INTERFACE_LIBRARY || + t.GetType() == cmStateEnums::GLOBAL_TARGET) { continue; } includeDirs = t.GetProperty("INCLUDE_DIRECTORIES"); @@ -3175,7 +3180,7 @@ int cmMakefile::TryCompile(const std::string& srcdir, // Add this before the user-provided CMake arguments in case // one of the arguments is -DCMAKE_BUILD_TYPE=... cm.AddCacheEntry("CMAKE_BUILD_TYPE", config, "Build configuration", - cmState::STRING); + cmStateEnums::STRING); } } // if cmake args were provided then pass them in @@ -3211,10 +3216,10 @@ int cmMakefile::TryCompile(const std::string& srcdir, gg->EnableLanguagesFromGenerator(this->GetGlobalGenerator(), this); if (this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) { cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", "", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } else { cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } if (cm.Configure() != 0) { cmSystemTools::Error( @@ -3618,7 +3623,7 @@ void cmMakefile::AddCMakeDependFilesFromUser() std::string cmMakefile::FormatListFileStack() const { std::vector<std::string> listFiles; - cmState::Snapshot snp = this->StateSnapshot; + cmStateSnapshot snp = this->StateSnapshot; while (snp.IsValid()) { listFiles.push_back(snp.GetExecutionListFile()); snp = snp.GetCallStackParent(); @@ -3681,7 +3686,8 @@ void cmMakefile::RaiseScope(const std::string& var, const char* varDef) } cmTarget* cmMakefile::AddImportedTarget(const std::string& name, - cmState::TargetType type, bool global) + cmStateEnums::TargetType type, + bool global) { // Create the target. CM_AUTO_PTR<cmTarget> target( @@ -3767,7 +3773,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, // The conflict is with a non-imported target. // Allow this if the user has requested support. cmake* cm = this->GetCMakeInstance(); - if (isCustom && existing->GetType() == cmState::UTILITY && + if (isCustom && existing->GetType() == cmStateEnums::UTILITY && this != existing->GetMakefile() && cm->GetState()->GetGlobalPropertyAsBool( "ALLOW_DUPLICATE_CUSTOM_TARGETS")) { @@ -3781,22 +3787,22 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, << "\" because another target with the same name already exists. " << "The existing target is "; switch (existing->GetType()) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: e << "an executable "; break; - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: e << "a static library "; break; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: e << "a shared library "; break; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: e << "a module library "; break; - case cmState::UTILITY: + case cmStateEnums::UTILITY: e << "a custom target "; break; - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: e << "an interface library "; break; default: @@ -3914,7 +3920,7 @@ void cmMakefile::StoreMatches(cmsys::RegularExpression& re) this->MarkVariableAsUsed(nMatchesVariable); } -cmState::Snapshot cmMakefile::GetStateSnapshot() const +cmStateSnapshot cmMakefile::GetStateSnapshot() const { return this->StateSnapshot; } @@ -3995,7 +4001,7 @@ void cmMakefile::PopPolicy() void cmMakefile::PopSnapshot(bool reportError) { - // cmState::Snapshot manages nested policy scopes within it. + // cmStateSnapshot manages nested policy scopes within it. // Since the scope corresponding to the snapshot is closing, // reject any still-open nested policy scopes with an error. while (!this->StateSnapshot.CanPopPolicyScope()) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 0116ce1..b61e81b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -9,7 +9,7 @@ #include "cmListFileCache.h" #include "cmNewLineStyle.h" #include "cmPolicies.h" -#include "cmState.h" +#include "cmStateSnapshot.h" #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" #include "cmake.h" @@ -70,7 +70,7 @@ public: * Construct an empty makefile. */ cmMakefile(cmGlobalGenerator* globalGenerator, - const cmState::Snapshot& snapshot); + const cmStateSnapshot& snapshot); /** * Destructor. @@ -163,9 +163,10 @@ public: /** Create a new imported target with the name and type given. */ cmTarget* AddImportedTarget(const std::string& name, - cmState::TargetType type, bool global); + cmStateEnums::TargetType type, bool global); - cmTarget* AddNewTarget(cmState::TargetType type, const std::string& name); + cmTarget* AddNewTarget(cmStateEnums::TargetType type, + const std::string& name); /** * Add an executable to the build. @@ -223,7 +224,7 @@ public: void AddDefinition(const std::string& name, const char* value); ///! Add a definition to this makefile and the global cmake cache. void AddCacheDefinition(const std::string& name, const char* value, - const char* doc, cmState::CacheEntryType type, + const char* doc, cmStateEnums::CacheEntryType type, bool force = false); /** @@ -251,7 +252,8 @@ public: /** * Set the name of the library. */ - cmTarget* AddLibrary(const std::string& libname, cmState::TargetType type, + cmTarget* AddLibrary(const std::string& libname, + cmStateEnums::TargetType type, const std::vector<std::string>& srcs, bool excludeFromAll = false); void AddAlias(const std::string& libname, const std::string& tgt); @@ -751,7 +753,7 @@ public: void ClearMatches(); void StoreMatches(cmsys::RegularExpression& re); - cmState::Snapshot GetStateSnapshot() const; + cmStateSnapshot GetStateSnapshot() const; const char* GetDefineFlagsCMP0059() const; @@ -827,7 +829,7 @@ private: cmMakefile(const cmMakefile& mf); cmMakefile& operator=(const cmMakefile& mf); - cmState::Snapshot StateSnapshot; + cmStateSnapshot StateSnapshot; cmListFileBacktrace Backtrace; void ReadListFile(cmListFile const& listFile, diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 7eca0a8..cbbd2e6 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -12,6 +12,7 @@ #include "cmOSXBundleGenerator.h" #include "cmOutputConverter.h" #include "cmRulePlaceholderExpander.h" +#include "cmState.h" #include "cmSystemTools.h" #include "cmake.h" diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 00a9100..a249efd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -13,6 +13,7 @@ #include "cmOutputConverter.h" #include "cmRulePlaceholderExpander.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" @@ -24,7 +25,7 @@ cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( : cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - if (this->GeneratorTarget->GetType() != cmState::INTERFACE_LIBRARY) { + if (this->GeneratorTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY) { this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -57,24 +58,24 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() // write the link rules // Write the rule for this target type. switch (this->GeneratorTarget->GetType()) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: this->WriteStaticLibraryRules(); break; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); if (this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); } break; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); if (this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); } break; - case cmState::OBJECT_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: this->WriteObjectLibraryRules(); break; default: @@ -251,8 +252,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( this->LocalGenerator->AppendFlags(linkFlags, extraFlags); // Add OSX version flags, if any. - if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || - this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { this->AppendOSXVerFlag(linkFlags, linkLanguage, "COMPATIBILITY", true); this->AppendOSXVerFlag(linkFlags, linkLanguage, "CURRENT", false); } @@ -345,13 +346,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( std::string buildEcho = "Linking "; buildEcho += linkLanguage; switch (this->GeneratorTarget->GetType()) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: buildEcho += " static library "; break; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: buildEcho += " shared library "; break; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: if (this->GeneratorTarget->IsCFBundleOnApple()) { buildEcho += " CFBundle"; } @@ -399,7 +400,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( #ifdef _WIN32 // There may be a manifest file for this target. Add it to the // clean set just in case. - if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) { + if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), (targetFullPath + ".manifest").c_str())); @@ -409,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( std::vector<std::string> commands1; // Add a command to remove any existing files for this library. // for static libs only - if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { this->LocalGenerator->AppendCleanCommand(commands1, libCleanFiles, this->GeneratorTarget, "target"); this->LocalGenerator->CreateCDCommand( @@ -443,7 +444,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( std::vector<std::string> archiveAppendCommands; std::vector<std::string> archiveFinishCommands; std::string::size_type archiveCommandLimit = std::string::npos; - if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { haveStaticLibraryRule = this->Makefile->IsDefinitionSet(linkRuleVar); std::string arCreateVar = "CMAKE_"; arCreateVar += linkLanguage; @@ -492,7 +493,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Collect up flags to link in needed libraries. std::string linkLibs; - if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY) { + if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY) { CM_AUTO_PTR<cmLinkLineComputer> linkLineComputer( this->CreateLinkLineComputer( @@ -514,7 +515,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( useWatcomQuote); // maybe create .def file from list of objects - if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY && + if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { this->GenDefFile(real_link_commands, linkFlags); } @@ -574,7 +575,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Compute the directory portion of the install_name setting. std::string install_name_dir; - if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY) { // Get the install_name directory for the build tree. install_name_dir = this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); @@ -659,7 +660,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( std::string linkRule = this->GetLinkRule(linkRuleVar); cmSystemTools::ExpandListArgument(linkRule, real_link_commands); if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE") && - (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY)) { + (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY)) { std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL); cmakeCommand += " -E __run_iwyu --lwyu="; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index cbfe850..68c166e 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -21,6 +21,7 @@ #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -68,16 +69,16 @@ cmMakefileTargetGenerator* cmMakefileTargetGenerator::New( cmMakefileTargetGenerator* result = CM_NULLPTR; switch (tgt->GetType()) { - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: result = new cmMakefileExecutableTargetGenerator(tgt); break; - case cmState::STATIC_LIBRARY: - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: result = new cmMakefileLibraryTargetGenerator(tgt); break; - case cmState::UTILITY: + case cmStateEnums::UTILITY: result = new cmMakefileUtilityTargetGenerator(tgt); break; default: @@ -504,10 +505,10 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( std::string targetFullPathReal; std::string targetFullPathPDB; std::string targetFullPathCompilePDB; - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE || - this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || - this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || - this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE || + this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { targetFullPathReal = this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = @@ -515,7 +516,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( targetFullPathPDB += "/"; targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } - if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { + if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { targetFullPathCompilePDB = this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if (targetFullPathCompilePDB.empty()) { @@ -1232,7 +1233,7 @@ class cmMakefileTargetGeneratorObjectStrings public: cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings, cmOutputConverter* outputConverter, - cmState::Directory stateDir, + cmStateDirectory stateDir, std::string::size_type limit) : Strings(strings) , OutputConverter(outputConverter) @@ -1277,7 +1278,7 @@ private: std::vector<std::string>& Strings; cmOutputConverter* OutputConverter; - cmState::Directory StateDir; + cmStateDirectory StateDir; std::string::size_type LengthLimit; std::string CurrentString; std::string NextObject; @@ -1346,7 +1347,7 @@ void cmMakefileTargetGenerator::AppendTargetDepends( std::vector<std::string>& depends) { // Static libraries never depend on anything for linking. - if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) { return; } @@ -1553,7 +1554,7 @@ std::string cmMakefileTargetGenerator::CreateResponseFile( } cmLinkLineComputer* cmMakefileTargetGenerator::CreateLinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir) + cmOutputConverter* outputConverter, cmStateDirectory stateDir) { if (this->Makefile->IsOn("MSVC60")) { return this->GlobalGenerator->CreateMSVC60LinkLineComputer(outputConverter, diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 4c61011..e44f64a 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -141,7 +141,7 @@ protected: std::vector<std::string>& makefile_depends); cmLinkLineComputer* CreateLinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir); + cmOutputConverter* outputConverter, cmStateDirectory stateDir); /** Create a response file with the given set of options. Returns the relative path from the target build working directory to the diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 5ec1620..8f9e288 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -26,7 +26,7 @@ bool cmMarkAsAdvancedCommand::InitialPass(std::vector<std::string> const& args, cmState* state = this->Makefile->GetState(); if (!state->GetCacheEntryValue(variable)) { this->Makefile->GetCMakeInstance()->AddCacheEntry( - variable, CM_NULLPTR, CM_NULLPTR, cmState::UNINITIALIZED); + variable, CM_NULLPTR, CM_NULLPTR, cmStateEnums::UNINITIALIZED); overwrite = true; } if (!state->GetCacheEntryValue(variable)) { diff --git a/Source/cmNinjaLinkLineComputer.cxx b/Source/cmNinjaLinkLineComputer.cxx index 3dcb20b..fa9df6d 100644 --- a/Source/cmNinjaLinkLineComputer.cxx +++ b/Source/cmNinjaLinkLineComputer.cxx @@ -5,7 +5,7 @@ #include "cmGlobalNinjaGenerator.h" cmNinjaLinkLineComputer::cmNinjaLinkLineComputer( - cmOutputConverter* outputConverter, cmState::Directory stateDir, + cmOutputConverter* outputConverter, cmStateDirectory stateDir, cmGlobalNinjaGenerator const* gg) : cmLinkLineComputer(outputConverter, stateDir) , GG(gg) diff --git a/Source/cmNinjaLinkLineComputer.h b/Source/cmNinjaLinkLineComputer.h index a108568..daecea4 100644 --- a/Source/cmNinjaLinkLineComputer.h +++ b/Source/cmNinjaLinkLineComputer.h @@ -13,7 +13,7 @@ class cmNinjaLinkLineComputer : public cmLinkLineComputer { public: cmNinjaLinkLineComputer(cmOutputConverter* outputConverter, - cmState::Directory stateDir, + cmStateDirectory stateDir, cmGlobalNinjaGenerator const* gg); std::string ConvertToLinkReference(std::string const& input) const diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index b28b19a..11773f9 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" @@ -45,7 +46,7 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( , TargetLinkLanguage("") { this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); - if (target->GetType() == cmState::EXECUTABLE) { + if (target->GetType() == cmStateEnums::EXECUTABLE) { this->GetGeneratorTarget()->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); @@ -56,7 +57,7 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( GetLocalGenerator()->GetConfigName()); } - if (target->GetType() != cmState::OBJECT_LIBRARY) { + if (target->GetType() != cmStateEnums::OBJECT_LIBRARY) { // on Windows the output dir is already needed at compile time // ensure the directory exists (OutDir test) EnsureDirectoryExists(target->GetDirectory(this->GetConfigName())); @@ -87,7 +88,7 @@ void cmNinjaNormalTargetGenerator::Generate() // Write the build statements this->WriteObjectBuildStatements(); - if (this->GetGeneratorTarget()->GetType() == cmState::OBJECT_LIBRARY) { + if (this->GetGeneratorTarget()->GetType() == cmStateEnums::OBJECT_LIBRARY) { this->WriteObjectLibStatement(); } else { this->WriteLinkStatement(); @@ -106,10 +107,11 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() // Write rules for languages compiled in this target. std::set<std::string> languages; - std::vector<cmSourceFile*> sourceFiles; - this->GetGeneratorTarget()->GetSourceFiles( + std::vector<cmSourceFile const*> sourceFiles; + this->GetGeneratorTarget()->GetObjectSources( sourceFiles, this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); - for (std::vector<cmSourceFile*>::const_iterator i = sourceFiles.begin(); + for (std::vector<cmSourceFile const*>::const_iterator i = + sourceFiles.begin(); i != sourceFiles.end(); ++i) { const std::string& lang = (*i)->GetLanguage(); if (!lang.empty()) { @@ -125,17 +127,17 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() const char* cmNinjaNormalTargetGenerator::GetVisibleTypeName() const { switch (this->GetGeneratorTarget()->GetType()) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return "static library"; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return "shared library"; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: if (this->GetGeneratorTarget()->IsCFBundleOnApple()) { return "CFBundle shared module"; } else { return "shared module"; } - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return "executable"; default: return CM_NULLPTR; @@ -160,7 +162,7 @@ struct cmNinjaRemoveNoOpCommands void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) { - cmState::TargetType targetType = this->GetGeneratorTarget()->GetType(); + cmStateEnums::TargetType targetType = this->GetGeneratorTarget()->GetType(); std::string ruleName = this->LanguageLinkerRule(); // Select whether to use a response file for objects. @@ -236,7 +238,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) vars.Manifests = "$MANIFESTS"; std::string langFlags; - if (targetType != cmState::EXECUTABLE) { + if (targetType != cmStateEnums::EXECUTABLE) { langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS"; vars.LanguageCompileFlags = langFlags.c_str(); } @@ -292,7 +294,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL); - if (targetType == cmState::EXECUTABLE) { + if (targetType == cmStateEnums::EXECUTABLE) { this->GetGlobalGenerator()->AddRule( "CMAKE_SYMLINK_EXECUTABLE", cmakeCommand + " -E cmake_symlink_executable" @@ -352,7 +354,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() } } switch (this->GetGeneratorTarget()->GetType()) { - case cmState::STATIC_LIBRARY: { + case cmStateEnums::STATIC_LIBRARY: { // We have archive link commands set. First, delete the existing archive. { std::string cmakeCommand = @@ -377,9 +379,9 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd() } return linkCmds; } - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::EXECUTABLE: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::EXECUTABLE: break; default: assert(0 && "Unexpected target type"); @@ -452,7 +454,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Write comments. cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream()); - const cmState::TargetType targetType = gt.GetType(); + const cmStateEnums::TargetType targetType = gt.GetType(); this->GetBuildFileStream() << "# Link build statements for " << cmState::GetTargetTypeName(targetType) << " target " << this->GetTargetName() << "\n\n"; @@ -497,7 +499,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() linkLineComputer.get(), this->GetConfigName(), vars["LINK_LIBRARIES"], vars["FLAGS"], vars["LINK_FLAGS"], frameworkPath, linkPath, &genTarget); if (this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") && - (gt.GetType() == cmState::SHARED_LIBRARY || + (gt.GetType() == cmStateEnums::SHARED_LIBRARY || gt.IsExecutableWithExports())) { if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { std::string name_of_def_file = gt.GetSupportDirectory(); @@ -510,8 +512,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // Add OS X version flags, if any. - if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || - this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage, "COMPATIBILITY", true); this->AppendOSXVerFlag(vars["LINK_FLAGS"], this->TargetLinkLanguage, @@ -535,7 +537,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Compute architecture specific link flags. Yes, these go into a different // variable for executables, probably due to a mistake made when duplicating // code between the Makefile executable and library generators. - if (targetType == cmState::EXECUTABLE) { + if (targetType == cmStateEnums::EXECUTABLE) { std::string t = vars["FLAGS"]; localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName); t += lwyuFlags; @@ -552,7 +554,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; - if (targetType == cmState::SHARED_LIBRARY) { + if (targetType == cmStateEnums::SHARED_LIBRARY) { std::string install_dir = this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { @@ -625,7 +627,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // maybe create .def file from list of objects - if ((gt.GetType() == cmState::SHARED_LIBRARY || + if ((gt.GetType() == cmStateEnums::SHARED_LIBRARY || gt.IsExecutableWithExports()) && this->GetMakefile()->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (gt.GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -713,7 +715,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->WriteLinkRule(usedResponseFile); if (symlinkNeeded) { - if (targetType == cmState::EXECUTABLE) { + if (targetType == cmStateEnums::EXECUTABLE) { globalGen.WriteBuild( this->GetBuildFileStream(), "Create executable symlink " + targetOutput, diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 1ac6cd4..b48387c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -17,6 +17,7 @@ #include "cmRulePlaceholderExpander.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" @@ -31,15 +32,15 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target) { switch (target->GetType()) { - case cmState::EXECUTABLE: - case cmState::SHARED_LIBRARY: - case cmState::STATIC_LIBRARY: - case cmState::MODULE_LIBRARY: - case cmState::OBJECT_LIBRARY: + case cmStateEnums::EXECUTABLE: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: return new cmNinjaNormalTargetGenerator(target); - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: return new cmNinjaUtilityTargetGenerator(target); default: @@ -186,8 +187,8 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source, cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const { // Static libraries never depend on other targets for linking. - if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || - this->GeneratorTarget->GetType() == cmState::OBJECT_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::OBJECT_LIBRARY) { return cmNinjaDeps(); } @@ -274,8 +275,9 @@ std::string cmNinjaTargetGenerator::GetPreprocessedFilePath( objName.substr(0, objName.size() - objExt.size()) + "-pp." + ppExt; std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); - if (!path.empty()) + if (!path.empty()) { path += "/"; + } path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path += "/"; path += ppName; @@ -286,8 +288,9 @@ std::string cmNinjaTargetGenerator::GetDyndepFilePath( std::string const& lang) const { std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); - if (!path.empty()) + if (!path.empty()) { path += "/"; + } path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget); path += "/"; path += lang; @@ -335,15 +338,15 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) { std::string pdbPath; std::string compilePdbPath; - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE || - this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || - this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || - this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE || + this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { pdbPath = this->GeneratorTarget->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } - if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { + if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { compilePdbPath = this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if (compilePdbPath.empty()) { diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 17e35e5..500ff4a 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -12,7 +12,7 @@ #include "cmNinjaTypes.h" #include "cmOutputConverter.h" #include "cmSourceFile.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" @@ -151,7 +151,7 @@ void cmNinjaUtilityTargetGenerator::Generate() // Add an alias for the logical target name regardless of what directory // contains it. Skip this for GLOBAL_TARGET because they are meant to // be per-directory and have one at the top-level anyway. - if (this->GetGeneratorTarget()->GetType() != cmState::GLOBAL_TARGET) { + if (this->GetGeneratorTarget()->GetType() != cmStateEnums::GLOBAL_TARGET) { this->GetGlobalGenerator()->AddTargetAlias(this->GetTargetName(), this->GetGeneratorTarget()); } diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index 946a543..0186ef2 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -32,7 +32,7 @@ bool cmOptionCommand::InitialPass(std::vector<std::string> const& args, cmState* state = this->Makefile->GetState(); const char* existingValue = state->GetCacheEntryValue(args[0]); if (existingValue) { - if (state->GetCacheEntryType(args[0]) != cmState::UNINITIALIZED) { + if (state->GetCacheEntryType(args[0]) != cmStateEnums::UNINITIALIZED) { state->SetCacheEntryProperty(args[0], "HELPSTRING", args[1]); return true; } @@ -43,6 +43,6 @@ bool cmOptionCommand::InitialPass(std::vector<std::string> const& args, } bool init = cmSystemTools::IsOn(initialValue.c_str()); this->Makefile->AddCacheDefinition(args[0], init ? "ON" : "OFF", - args[1].c_str(), cmState::BOOL); + args[1].c_str(), cmStateEnums::BOOL); return true; } diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 84a433c..445ad0b 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -3,6 +3,8 @@ #include "cmOutputConverter.h" #include "cmAlgorithms.h" +#include "cmState.h" +#include "cmStateDirectory.h" #include "cmSystemTools.h" #include <algorithm> @@ -11,7 +13,7 @@ #include <set> #include <sstream> -cmOutputConverter::cmOutputConverter(cmState::Snapshot snapshot) +cmOutputConverter::cmOutputConverter(cmStateSnapshot snapshot) : StateSnapshot(snapshot) , LinkScriptShell(false) { @@ -78,7 +80,7 @@ static bool cmOutputConverterNotAbove(const char* a, const char* b) bool cmOutputConverter::ContainedInDirectory(std::string const& local_path, std::string const& remote_path, - cmState::Directory directory) + cmStateDirectory directory) { const std::string relativePathTopBinary = directory.GetRelativePathTopBinary(); diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 71cacab..dabb091 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -5,7 +5,7 @@ #include <cmConfigure.h> // IWYU pragma: keep -#include "cmState.h" +#include "cmStateSnapshot.h" #include <string> #include <vector> @@ -13,7 +13,7 @@ class cmOutputConverter { public: - cmOutputConverter(cmState::Snapshot snapshot); + cmOutputConverter(cmStateSnapshot snapshot); enum OutputFormat { @@ -92,7 +92,7 @@ public: static bool ContainedInDirectory(std::string const& local_path, std::string const& remote_path, - cmState::Directory directory); + cmStateDirectory directory); /** * Convert the given remote path to a relative path with respect to @@ -125,7 +125,7 @@ private: static std::string Shell__GetArgument(const char* in, int flags); private: - cmState::Snapshot StateSnapshot; + cmStateSnapshot StateSnapshot; bool LinkScriptShell; }; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 3402191..6339e11 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -3,6 +3,7 @@ #include "cmAlgorithms.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmVersion.h" #include "cmake.h" @@ -233,7 +234,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, const char* version) "For backwards compatibility, what version of CMake " "commands and " "syntax should this version of CMake try to support.", - cmState::STRING); + cmStateEnums::STRING); } } } diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index c34a94b..c27da8e 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -19,10 +19,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, this->Makefile->AddCacheDefinition( bindir, this->Makefile->GetCurrentBinaryDirectory(), - "Value Computed by CMake", cmState::STATIC); + "Value Computed by CMake", cmStateEnums::STATIC); this->Makefile->AddCacheDefinition( srcdir, this->Makefile->GetCurrentSourceDirectory(), - "Value Computed by CMake", cmState::STATIC); + "Value Computed by CMake", cmStateEnums::STATIC); bindir = "PROJECT_BINARY_DIR"; srcdir = "PROJECT_SOURCE_DIR"; @@ -45,7 +45,7 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str()); this->Makefile->AddCacheDefinition("CMAKE_PROJECT_NAME", args[0].c_str(), "Value Computed by CMake", - cmState::STATIC); + cmStateEnums::STATIC); } bool haveVersion = false; diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 5246a67..f0373a1 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -13,6 +13,7 @@ #include "cmSourceFile.h" #include "cmSourceFileLocation.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmake.h" diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index b66257c..f56f575 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -8,6 +8,8 @@ #include "cmMakefile.h" #include "cmOutputConverter.h" #include "cmState.h" +#include "cmStateDirectory.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cm_auto_ptr.hxx" #include "cmake.h" @@ -165,7 +167,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cm.GetCurrentSnapshot().SetDefaultDefinitions(); cmGlobalGenerator gg(&cm); - cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmStateSnapshot snapshot = cm.GetCurrentSnapshot(); snapshot.GetDirectory().SetCurrentBinary(targetDirectory); snapshot.GetDirectory().SetCurrentSource(targetDirectory); diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index e0fcb75..e50878b 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmServerProtocol.h" -#include "cmCacheManager.h" #include "cmExternalMakefileProjectGenerator.h" #include "cmFileMonitor.h" #include "cmGeneratorTarget.h" @@ -42,8 +41,9 @@ static std::vector<std::string> getConfigurations(const cmake* cm) } makefiles[0]->GetConfigurations(configurations); - if (configurations.empty()) + if (configurations.empty()) { configurations.push_back(""); + } return configurations; } @@ -96,20 +96,24 @@ static void getCMakeInputs(const cmGlobalGenerator* gg, if (!sourceDir.empty()) { const std::string& relative = cmSystemTools::RelativePath(sourceDir.c_str(), jt->c_str()); - if (toAdd.size() > relative.size()) + if (toAdd.size() > relative.size()) { toAdd = relative; + } } if (isInternal) { - if (internalFiles) + if (internalFiles) { internalFiles->push_back(toAdd); + } } else { if (isTemporary) { - if (tmpFiles) + if (tmpFiles) { tmpFiles->push_back(toAdd); + } } else { - if (explicitFiles) + if (explicitFiles) { explicitFiles->push_back(toAdd); + } } } } @@ -672,8 +676,9 @@ static Json::Value DumpSourceFilesList( Json::Value result = Json::arrayValue; for (auto it = fileGroups.begin(); it != fileGroups.end(); ++it) { Json::Value group = DumpSourceFileGroup(it->first, it->second, baseDir); - if (!group.isNull()) + if (!group.isNull()) { result.append(group); + } } return result; @@ -685,7 +690,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, cmLocalGenerator* lg = target->GetLocalGenerator(); const cmState* state = lg->GetState(); - const cmState::TargetType type = target->GetType(); + const cmStateEnums::TargetType type = target->GetType(); const std::string typeName = state->GetTargetTypeName(type); Json::Value ttl = Json::arrayValue; @@ -821,8 +826,8 @@ static Json::Value DumpProjectList(const cmake* cm, const std::string config) Json::Value pObj = Json::objectValue; pObj[kNAME_KEY] = projectIt.first; - assert(projectIt.second.size() > - 0); // All Projects must have at least one local generator + // All Projects must have at least one local generator + assert(!projectIt.second.empty()); const cmLocalGenerator* lg = projectIt.second.at(0); // Project structure information: diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 8ce0b18..65b0e9c 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -64,8 +64,9 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, bool cache = false; // optional bool force = false; // optional bool parentScope = false; - cmState::CacheEntryType type = cmState::STRING; // required if cache - const char* docstring = CM_NULLPTR; // required if cache + cmStateEnums::CacheEntryType type = + cmStateEnums::STRING; // required if cache + const char* docstring = CM_NULLPTR; // required if cache unsigned int ignoreLastArgs = 0; // look for PARENT_SCOPE argument @@ -115,12 +116,12 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args, cmState* state = this->Makefile->GetState(); const char* existingValue = state->GetCacheEntryValue(variable); if (existingValue && - (state->GetCacheEntryType(variable) != cmState::UNINITIALIZED)) { + (state->GetCacheEntryType(variable) != cmStateEnums::UNINITIALIZED)) { // if the set is trying to CACHE the value but the value // is already in the cache and the type is not internal // then leave now without setting any definitions in the cache // or the makefile - if (cache && type != cmState::INTERNAL && !force) { + if (cache && type != cmStateEnums::INTERNAL && !force) { return true; } } diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index dbd3ed9..7664eca 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -68,7 +68,8 @@ bool cmSiteNameCommand::InitialPass(std::vector<std::string> const& args, #endif this->Makefile->AddCacheDefinition( args[0], siteName.c_str(), - "Name of the computer/site where compile is being run", cmState::STRING); + "Name of the computer/site where compile is being run", + cmStateEnums::STRING); return true; } diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 5d37578..6f29b18 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -7,6 +7,7 @@ #include "cmMakefile.h" #include "cmProperty.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmake.h" diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 0e73879..0d1eb3e 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmState.h" +#include "cmStatePrivate.h" + #include "cmAlgorithms.h" #include "cmCacheManager.h" #include "cmCommand.h" @@ -9,7 +11,6 @@ #include "cmListFileCache.h" #include "cmSystemTools.h" #include "cmTypeMacro.h" -#include "cmVersion.h" #include "cmake.h" #include <algorithm> @@ -20,85 +21,6 @@ #include <string.h> #include <utility> -static std::string const kBINARY_DIR = "BINARY_DIR"; -static std::string const kBUILDSYSTEM_TARGETS = "BUILDSYSTEM_TARGETS"; -static std::string const kSOURCE_DIR = "SOURCE_DIR"; -static std::string const kSUBDIRECTORIES = "SUBDIRECTORIES"; - -struct cmState::SnapshotDataType -{ - cmState::PositionType ScopeParent; - cmState::PositionType DirectoryParent; - cmLinkedTree<cmState::PolicyStackEntry>::iterator Policies; - cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyRoot; - cmLinkedTree<cmState::PolicyStackEntry>::iterator PolicyScope; - cmState::SnapshotType SnapshotType; - bool Keep; - cmLinkedTree<std::string>::iterator ExecutionListFile; - cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator - BuildSystemDirectory; - cmLinkedTree<cmDefinitions>::iterator Vars; - cmLinkedTree<cmDefinitions>::iterator Root; - cmLinkedTree<cmDefinitions>::iterator Parent; - std::vector<std::string>::size_type IncludeDirectoryPosition; - std::vector<std::string>::size_type CompileDefinitionsPosition; - std::vector<std::string>::size_type CompileOptionsPosition; -}; - -struct cmState::PolicyStackEntry : public cmPolicies::PolicyMap -{ - typedef cmPolicies::PolicyMap derived; - PolicyStackEntry(bool w = false) - : derived() - , Weak(w) - { - } - PolicyStackEntry(derived const& d, bool w) - : derived(d) - , Weak(w) - { - } - PolicyStackEntry(PolicyStackEntry const& r) - : derived(r) - , Weak(r.Weak) - { - } - bool Weak; -}; - -struct cmState::BuildsystemDirectoryStateType -{ - cmState::PositionType DirectoryEnd; - - std::string Location; - std::string OutputLocation; - - // The top-most directories for relative path conversion. Both the - // source and destination location of a relative path conversion - // must be underneath one of these directories (both under source or - // both under binary) in order for the relative path to be evaluated - // safely by the build tools. - std::string RelativePathTopSource; - std::string RelativePathTopBinary; - - std::vector<std::string> IncludeDirectories; - std::vector<cmListFileBacktrace> IncludeDirectoryBacktraces; - - std::vector<std::string> CompileDefinitions; - std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces; - - std::vector<std::string> CompileOptions; - std::vector<cmListFileBacktrace> CompileOptionsBacktraces; - - std::vector<std::string> NormalTargetNames; - - std::string ProjectName; - - cmPropertyMap Properties; - - std::vector<cmState::Snapshot> Children; -}; - cmState::cmState() : IsInTryCompile(false) , WindowsShell(false) @@ -117,26 +39,26 @@ cmState::~cmState() cmDeleteAll(this->Commands); } -const char* cmState::GetTargetTypeName(cmState::TargetType targetType) +const char* cmState::GetTargetTypeName(cmStateEnums::TargetType targetType) { switch (targetType) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return "STATIC_LIBRARY"; - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: return "MODULE_LIBRARY"; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return "SHARED_LIBRARY"; - case cmState::OBJECT_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: return "OBJECT_LIBRARY"; - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return "EXECUTABLE"; - case cmState::UTILITY: + case cmStateEnums::UTILITY: return "UTILITY"; - case cmState::GLOBAL_TARGET: + case cmStateEnums::GLOBAL_TARGET: return "GLOBAL_TARGET"; - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: return "INTERFACE_LIBRARY"; - case cmState::UNKNOWN_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: return "UNKNOWN_LIBRARY"; } assert(0 && "Unexpected target type"); @@ -147,7 +69,7 @@ const char* cmCacheEntryTypes[] = { "BOOL", "PATH", "FILEPATH", "STRING", "INTERNAL", "STATIC", "UNINITIALIZED", CM_NULLPTR }; -const char* cmState::CacheEntryTypeToString(cmState::CacheEntryType type) +const char* cmState::CacheEntryTypeToString(cmStateEnums::CacheEntryType type) { if (type > 6) { return cmCacheEntryTypes[6]; @@ -155,16 +77,16 @@ const char* cmState::CacheEntryTypeToString(cmState::CacheEntryType type) return cmCacheEntryTypes[type]; } -cmState::CacheEntryType cmState::StringToCacheEntryType(const char* s) +cmStateEnums::CacheEntryType cmState::StringToCacheEntryType(const char* s) { int i = 0; while (cmCacheEntryTypes[i]) { if (strcmp(s, cmCacheEntryTypes[i]) == 0) { - return static_cast<cmState::CacheEntryType>(i); + return static_cast<cmStateEnums::CacheEntryType>(i); } ++i; } - return STRING; + return cmStateEnums::STRING; } bool cmState::IsCacheEntryType(std::string const& key) @@ -219,7 +141,7 @@ const char* cmState::GetInitializedCacheValue(std::string const& key) const return this->CacheManager->GetInitializedCacheValue(key); } -cmState::CacheEntryType cmState::GetCacheEntryType( +cmStateEnums::CacheEntryType cmState::GetCacheEntryType( std::string const& key) const { cmCacheManager::CacheIterator it = @@ -279,7 +201,7 @@ bool cmState::GetCacheEntryPropertyAsBool(std::string const& key, void cmState::AddCacheEntry(const std::string& key, const char* value, const char* helpString, - cmState::CacheEntryType type) + cmStateEnums::CacheEntryType type) { this->CacheManager->AddCacheEntry(key, value, helpString, type); } @@ -304,16 +226,16 @@ void cmState::RemoveCacheEntryProperty(std::string const& key, .SetProperty(propertyName, (void*)CM_NULLPTR); } -cmState::Snapshot cmState::Reset() +cmStateSnapshot cmState::Reset() { this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); - PositionType pos = this->SnapshotData.Truncate(); + cmStateDetail::PositionType pos = this->SnapshotData.Truncate(); this->ExecutionListFiles.Truncate(); { - cmLinkedTree<BuildsystemDirectoryStateType>::iterator it = + cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator it = this->BuildsystemDirectory.Truncate(); it->IncludeDirectories.clear(); it->IncludeDirectoryBacktraces.clear(); @@ -360,7 +282,7 @@ cmState::Snapshot cmState::Reset() this->DefineProperty("RULE_LAUNCH_LINK", cmProperty::TARGET, "", "", true); this->DefineProperty("RULE_LAUNCH_CUSTOM", cmProperty::TARGET, "", "", true); - return Snapshot(this, pos); + return cmStateSnapshot(this, pos); } void cmState::DefineProperty(const std::string& name, @@ -676,78 +598,13 @@ const char* cmState::GetBinaryDirectory() const return this->BinaryDirectory.c_str(); } -void cmState::Directory::ComputeRelativePathTopSource() -{ - // Relative path conversion inside the source tree is not used to - // construct relative paths passed to build tools so it is safe to use - // even when the source is a network path. - - cmState::Snapshot snapshot = this->Snapshot_; - std::vector<cmState::Snapshot> snapshots; - snapshots.push_back(snapshot); - while (true) { - snapshot = snapshot.GetBuildsystemDirectoryParent(); - if (snapshot.IsValid()) { - snapshots.push_back(snapshot); - } else { - break; - } - } - - std::string result = snapshots.front().GetDirectory().GetCurrentSource(); - - for (std::vector<cmState::Snapshot>::const_iterator it = - snapshots.begin() + 1; - it != snapshots.end(); ++it) { - std::string currentSource = it->GetDirectory().GetCurrentSource(); - if (cmSystemTools::IsSubDirectory(result, currentSource)) { - result = currentSource; - } - } - this->DirectoryState->RelativePathTopSource = result; -} - -void cmState::Directory::ComputeRelativePathTopBinary() -{ - cmState::Snapshot snapshot = this->Snapshot_; - std::vector<cmState::Snapshot> snapshots; - snapshots.push_back(snapshot); - while (true) { - snapshot = snapshot.GetBuildsystemDirectoryParent(); - if (snapshot.IsValid()) { - snapshots.push_back(snapshot); - } else { - break; - } - } - - std::string result = snapshots.front().GetDirectory().GetCurrentBinary(); - - for (std::vector<cmState::Snapshot>::const_iterator it = - snapshots.begin() + 1; - it != snapshots.end(); ++it) { - std::string currentBinary = it->GetDirectory().GetCurrentBinary(); - if (cmSystemTools::IsSubDirectory(result, currentBinary)) { - result = currentBinary; - } - } - - // The current working directory on Windows cannot be a network - // path. Therefore relative paths cannot work when the binary tree - // is a network path. - if (result.size() < 2 || result.substr(0, 2) != "//") { - this->DirectoryState->RelativePathTopBinary = result; - } else { - this->DirectoryState->RelativePathTopBinary = ""; - } -} - -cmState::Snapshot cmState::CreateBaseSnapshot() +cmStateSnapshot cmState::CreateBaseSnapshot() { - PositionType pos = this->SnapshotData.Push(this->SnapshotData.Root()); + cmStateDetail::PositionType pos = + this->SnapshotData.Push(this->SnapshotData.Root()); pos->DirectoryParent = this->SnapshotData.Root(); pos->ScopeParent = this->SnapshotData.Root(); - pos->SnapshotType = BaseType; + pos->SnapshotType = cmStateEnums::BaseType; pos->Keep = true; pos->BuildSystemDirectory = this->BuildsystemDirectory.Push(this->BuildsystemDirectory.Root()); @@ -766,17 +623,18 @@ cmState::Snapshot cmState::CreateBaseSnapshot() assert(pos->Vars.IsValid()); pos->Parent = this->VarTree.Root(); pos->Root = this->VarTree.Root(); - return cmState::Snapshot(this, pos); + return cmStateSnapshot(this, pos); } -cmState::Snapshot cmState::CreateBuildsystemDirectorySnapshot( - Snapshot originSnapshot) +cmStateSnapshot cmState::CreateBuildsystemDirectorySnapshot( + cmStateSnapshot originSnapshot) { assert(originSnapshot.IsValid()); - PositionType pos = this->SnapshotData.Push(originSnapshot.Position); + cmStateDetail::PositionType pos = + this->SnapshotData.Push(originSnapshot.Position); pos->DirectoryParent = originSnapshot.Position; pos->ScopeParent = originSnapshot.Position; - pos->SnapshotType = BuildsystemDirectoryType; + pos->SnapshotType = cmStateEnums::BuildsystemDirectoryType; pos->Keep = true; pos->BuildSystemDirectory = this->BuildsystemDirectory.Push( originSnapshot.Position->BuildSystemDirectory); @@ -794,7 +652,7 @@ cmState::Snapshot cmState::CreateBuildsystemDirectorySnapshot( pos->Root = origin; pos->Vars = this->VarTree.Push(origin); - cmState::Snapshot snapshot = cmState::Snapshot(this, pos); + cmStateSnapshot snapshot = cmStateSnapshot(this, pos); originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot); snapshot.SetDefaultDefinitions(); snapshot.InitializeFromParent(); @@ -802,13 +660,13 @@ cmState::Snapshot cmState::CreateBuildsystemDirectorySnapshot( return snapshot; } -cmState::Snapshot cmState::CreateFunctionCallSnapshot( - cmState::Snapshot originSnapshot, std::string const& fileName) +cmStateSnapshot cmState::CreateFunctionCallSnapshot( + cmStateSnapshot originSnapshot, std::string const& fileName) { - PositionType pos = + cmStateDetail::PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); pos->ScopeParent = originSnapshot.Position; - pos->SnapshotType = FunctionCallType; + pos->SnapshotType = cmStateEnums::FunctionCallType; pos->Keep = false; pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); @@ -818,46 +676,46 @@ cmState::Snapshot cmState::CreateFunctionCallSnapshot( cmLinkedTree<cmDefinitions>::iterator origin = originSnapshot.Position->Vars; pos->Parent = origin; pos->Vars = this->VarTree.Push(origin); - return cmState::Snapshot(this, pos); + return cmStateSnapshot(this, pos); } -cmState::Snapshot cmState::CreateMacroCallSnapshot( - cmState::Snapshot originSnapshot, std::string const& fileName) +cmStateSnapshot cmState::CreateMacroCallSnapshot( + cmStateSnapshot originSnapshot, std::string const& fileName) { - PositionType pos = + cmStateDetail::PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); - pos->SnapshotType = MacroCallType; + pos->SnapshotType = cmStateEnums::MacroCallType; pos->Keep = false; pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmState::Snapshot(this, pos); + return cmStateSnapshot(this, pos); } -cmState::Snapshot cmState::CreateIncludeFileSnapshot( - cmState::Snapshot originSnapshot, const std::string& fileName) +cmStateSnapshot cmState::CreateIncludeFileSnapshot( + cmStateSnapshot originSnapshot, const std::string& fileName) { - PositionType pos = + cmStateDetail::PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); - pos->SnapshotType = IncludeFileType; + pos->SnapshotType = cmStateEnums::IncludeFileType; pos->Keep = true; pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); assert(originSnapshot.Position->Vars.IsValid()); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmState::Snapshot(this, pos); + return cmStateSnapshot(this, pos); } -cmState::Snapshot cmState::CreateVariableScopeSnapshot( - cmState::Snapshot originSnapshot) +cmStateSnapshot cmState::CreateVariableScopeSnapshot( + cmStateSnapshot originSnapshot) { - PositionType pos = + cmStateDetail::PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); pos->ScopeParent = originSnapshot.Position; - pos->SnapshotType = VariableScopeType; + pos->SnapshotType = cmStateEnums::VariableScopeType; pos->Keep = false; pos->PolicyScope = originSnapshot.Position->Policies; assert(originSnapshot.Position->Vars.IsValid()); @@ -866,39 +724,39 @@ cmState::Snapshot cmState::CreateVariableScopeSnapshot( pos->Parent = origin; pos->Vars = this->VarTree.Push(origin); assert(pos->Vars.IsValid()); - return cmState::Snapshot(this, pos); + return cmStateSnapshot(this, pos); } -cmState::Snapshot cmState::CreateInlineListFileSnapshot( - cmState::Snapshot originSnapshot, const std::string& fileName) +cmStateSnapshot cmState::CreateInlineListFileSnapshot( + cmStateSnapshot originSnapshot, const std::string& fileName) { - PositionType pos = + cmStateDetail::PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); - pos->SnapshotType = InlineListFileType; + pos->SnapshotType = cmStateEnums::InlineListFileType; pos->Keep = true; pos->ExecutionListFile = this->ExecutionListFiles.Push( originSnapshot.Position->ExecutionListFile, fileName); pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmState::Snapshot(this, pos); + return cmStateSnapshot(this, pos); } -cmState::Snapshot cmState::CreatePolicyScopeSnapshot( - cmState::Snapshot originSnapshot) +cmStateSnapshot cmState::CreatePolicyScopeSnapshot( + cmStateSnapshot originSnapshot) { - PositionType pos = + cmStateDetail::PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); - pos->SnapshotType = PolicyScopeType; + pos->SnapshotType = cmStateEnums::PolicyScopeType; pos->Keep = false; pos->BuildSystemDirectory->DirectoryEnd = pos; pos->PolicyScope = originSnapshot.Position->Policies; - return cmState::Snapshot(this, pos); + return cmStateSnapshot(this, pos); } -cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) +cmStateSnapshot cmState::Pop(cmStateSnapshot originSnapshot) { - PositionType pos = originSnapshot.Position; - PositionType prevPos = pos; + cmStateDetail::PositionType pos = originSnapshot.Position; + cmStateDetail::PositionType prevPos = pos; ++prevPos; prevPos->IncludeDirectoryPosition = prevPos->BuildSystemDirectory->IncludeDirectories.size(); @@ -920,855 +778,7 @@ cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) this->SnapshotData.Pop(pos); } - return Snapshot(this, prevPos); -} - -cmState::Snapshot::Snapshot(cmState* state) - : State(state) - , Position() -{ -} - -std::vector<cmState::Snapshot> cmState::Snapshot::GetChildren() -{ - return this->Position->BuildSystemDirectory->Children; -} - -cmState::Snapshot::Snapshot(cmState* state, PositionType position) - : State(state) - , Position(position) -{ -} - -cmState::SnapshotType cmState::Snapshot::GetType() const -{ - return this->Position->SnapshotType; -} - -const char* cmState::Directory::GetCurrentSource() const -{ - return this->DirectoryState->Location.c_str(); -} - -void cmState::Directory::SetCurrentSource(std::string const& dir) -{ - std::string& loc = this->DirectoryState->Location; - loc = dir; - cmSystemTools::ConvertToUnixSlashes(loc); - loc = cmSystemTools::CollapseFullPath(loc); - - this->ComputeRelativePathTopSource(); - - this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc); -} - -const char* cmState::Directory::GetCurrentBinary() const -{ - return this->DirectoryState->OutputLocation.c_str(); -} - -void cmState::Directory::SetCurrentBinary(std::string const& dir) -{ - std::string& loc = this->DirectoryState->OutputLocation; - loc = dir; - cmSystemTools::ConvertToUnixSlashes(loc); - loc = cmSystemTools::CollapseFullPath(loc); - - this->ComputeRelativePathTopBinary(); - - this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc); -} - -void cmState::Snapshot::SetListFile(const std::string& listfile) -{ - *this->Position->ExecutionListFile = listfile; -} - -const char* cmState::Directory::GetRelativePathTopSource() const -{ - return this->DirectoryState->RelativePathTopSource.c_str(); -} - -const char* cmState::Directory::GetRelativePathTopBinary() const -{ - return this->DirectoryState->RelativePathTopBinary.c_str(); -} - -void cmState::Directory::SetRelativePathTopSource(const char* dir) -{ - this->DirectoryState->RelativePathTopSource = dir; -} - -void cmState::Directory::SetRelativePathTopBinary(const char* dir) -{ - this->DirectoryState->RelativePathTopBinary = dir; -} - -std::string cmState::Snapshot::GetExecutionListFile() const -{ - return *this->Position->ExecutionListFile; -} - -bool cmState::Snapshot::IsValid() const -{ - return this->State && this->Position.IsValid() - ? this->Position != this->State->SnapshotData.Root() - : false; -} - -cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const -{ - Snapshot snapshot; - if (!this->State || this->Position == this->State->SnapshotData.Root()) { - return snapshot; - } - PositionType parentPos = this->Position->DirectoryParent; - if (parentPos != this->State->SnapshotData.Root()) { - snapshot = - Snapshot(this->State, parentPos->BuildSystemDirectory->DirectoryEnd); - } - - return snapshot; -} - -cmState::Snapshot cmState::Snapshot::GetCallStackParent() const -{ - assert(this->State); - assert(this->Position != this->State->SnapshotData.Root()); - - Snapshot snapshot; - PositionType parentPos = this->Position; - while (parentPos->SnapshotType == cmState::PolicyScopeType || - parentPos->SnapshotType == cmState::VariableScopeType) { - ++parentPos; - } - if (parentPos->SnapshotType == cmState::BuildsystemDirectoryType || - parentPos->SnapshotType == cmState::BaseType) { - return snapshot; - } - - ++parentPos; - while (parentPos->SnapshotType == cmState::PolicyScopeType || - parentPos->SnapshotType == cmState::VariableScopeType) { - ++parentPos; - } - - if (parentPos == this->State->SnapshotData.Root()) { - return snapshot; - } - - snapshot = Snapshot(this->State, parentPos); - return snapshot; -} - -cmState::Snapshot cmState::Snapshot::GetCallStackBottom() const -{ - assert(this->State); - assert(this->Position != this->State->SnapshotData.Root()); - - PositionType pos = this->Position; - while (pos->SnapshotType != cmState::BaseType && - pos->SnapshotType != cmState::BuildsystemDirectoryType && - pos != this->State->SnapshotData.Root()) { - ++pos; - } - return Snapshot(this->State, pos); -} - -void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) -{ - PositionType pos = this->Position; - pos->Policies = this->State->PolicyStack.Push(pos->Policies, - PolicyStackEntry(entry, weak)); -} - -bool cmState::Snapshot::PopPolicy() -{ - PositionType pos = this->Position; - if (pos->Policies == pos->PolicyScope) { - return false; - } - pos->Policies = this->State->PolicyStack.Pop(pos->Policies); - return true; -} - -bool cmState::Snapshot::CanPopPolicyScope() -{ - return this->Position->Policies == this->Position->PolicyScope; -} - -void cmState::Snapshot::SetPolicy(cmPolicies::PolicyID id, - cmPolicies::PolicyStatus status) -{ - // Update the policy stack from the top to the top-most strong entry. - bool previous_was_weak = true; - for (cmLinkedTree<PolicyStackEntry>::iterator psi = this->Position->Policies; - previous_was_weak && psi != this->Position->PolicyRoot; ++psi) { - psi->Set(id, status); - previous_was_weak = psi->Weak; - } -} - -cmPolicies::PolicyStatus cmState::Snapshot::GetPolicy( - cmPolicies::PolicyID id) const -{ - cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); - - if (status == cmPolicies::REQUIRED_ALWAYS || - status == cmPolicies::REQUIRED_IF_USED) { - return status; - } - - cmLinkedTree<BuildsystemDirectoryStateType>::iterator dir = - this->Position->BuildSystemDirectory; - - while (true) { - assert(dir.IsValid()); - cmLinkedTree<PolicyStackEntry>::iterator leaf = - dir->DirectoryEnd->Policies; - cmLinkedTree<PolicyStackEntry>::iterator root = - dir->DirectoryEnd->PolicyRoot; - for (; leaf != root; ++leaf) { - if (leaf->IsDefined(id)) { - status = leaf->Get(id); - return status; - } - } - cmState::PositionType e = dir->DirectoryEnd; - cmState::PositionType p = e->DirectoryParent; - if (p == this->State->SnapshotData.Root()) { - break; - } - dir = p->BuildSystemDirectory; - } - return status; -} - -bool cmState::Snapshot::HasDefinedPolicyCMP0011() -{ - return !this->Position->Policies->IsEmpty(); -} - -const char* cmState::Snapshot::GetDefinition(std::string const& name) const -{ - assert(this->Position->Vars.IsValid()); - return cmDefinitions::Get(name, this->Position->Vars, this->Position->Root); -} - -bool cmState::Snapshot::IsInitialized(std::string const& name) const -{ - return cmDefinitions::HasKey(name, this->Position->Vars, - this->Position->Root); -} - -void cmState::Snapshot::SetDefinition(std::string const& name, - std::string const& value) -{ - this->Position->Vars->Set(name, value.c_str()); -} - -void cmState::Snapshot::RemoveDefinition(std::string const& name) -{ - this->Position->Vars->Set(name, CM_NULLPTR); -} - -std::vector<std::string> cmState::Snapshot::UnusedKeys() const -{ - return this->Position->Vars->UnusedKeys(); -} - -std::vector<std::string> cmState::Snapshot::ClosureKeys() const -{ - return cmDefinitions::ClosureKeys(this->Position->Vars, - this->Position->Root); -} - -bool cmState::Snapshot::RaiseScope(std::string const& var, const char* varDef) -{ - if (this->Position->ScopeParent == this->Position->DirectoryParent) { - Snapshot parentDir = this->GetBuildsystemDirectoryParent(); - if (!parentDir.IsValid()) { - return false; - } - // Update the definition in the parent directory top scope. This - // directory's scope was initialized by the closure of the parent - // scope, so we do not need to localize the definition first. - if (varDef) { - parentDir.SetDefinition(var, varDef); - } else { - parentDir.RemoveDefinition(var); - } - return true; - } - // First localize the definition in the current scope. - cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root); - - // Now update the definition in the parent scope. - this->Position->Parent->Set(var, varDef); - return true; -} - -static const std::string cmPropertySentinal = std::string(); - -template <typename T, typename U, typename V> -void InitializeContentFromParent(T& parentContent, T& thisContent, - U& parentBacktraces, U& thisBacktraces, - V& contentEndPosition) -{ - std::vector<std::string>::const_iterator parentBegin = parentContent.begin(); - std::vector<std::string>::const_iterator parentEnd = parentContent.end(); - - std::vector<std::string>::const_reverse_iterator parentRbegin = - cmMakeReverseIterator(parentEnd); - std::vector<std::string>::const_reverse_iterator parentRend = - parentContent.rend(); - parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal); - std::vector<std::string>::const_iterator parentIt = parentRbegin.base(); - - thisContent = std::vector<std::string>(parentIt, parentEnd); - - std::vector<cmListFileBacktrace>::const_iterator btIt = - parentBacktraces.begin() + std::distance(parentBegin, parentIt); - std::vector<cmListFileBacktrace>::const_iterator btEnd = - parentBacktraces.end(); - - thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd); - - contentEndPosition = thisContent.size(); -} - -void cmState::Snapshot::SetDefaultDefinitions() -{ -/* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. - With CMake must separate between target and host platform. In most cases - the tests for WIN32, UNIX and APPLE will be for the target system, so an - additional set of variables for the host system is required -> - CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. - WIN32, UNIX and APPLE are now set in the platform files in - Modules/Platforms/. - To keep cmake scripts (-P) and custom language and compiler modules - working, these variables are still also set here in this place, but they - will be reset in CMakeSystemSpecificInformation.cmake before the platform - files are executed. */ -#if defined(_WIN32) - this->SetDefinition("WIN32", "1"); - this->SetDefinition("CMAKE_HOST_WIN32", "1"); -#else - this->SetDefinition("UNIX", "1"); - this->SetDefinition("CMAKE_HOST_UNIX", "1"); -#endif -#if defined(__CYGWIN__) - std::string legacy; - if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) && - cmSystemTools::IsOn(legacy.c_str())) { - this->SetDefinition("WIN32", "1"); - this->SetDefinition("CMAKE_HOST_WIN32", "1"); - } -#endif -#if defined(__APPLE__) - this->SetDefinition("APPLE", "1"); - this->SetDefinition("CMAKE_HOST_APPLE", "1"); -#endif -#if defined(__sun__) - this->SetDefinition("CMAKE_HOST_SOLARIS", "1"); -#endif - - char temp[1024]; - sprintf(temp, "%d", cmVersion::GetMinorVersion()); - this->SetDefinition("CMAKE_MINOR_VERSION", temp); - sprintf(temp, "%d", cmVersion::GetMajorVersion()); - this->SetDefinition("CMAKE_MAJOR_VERSION", temp); - sprintf(temp, "%d", cmVersion::GetPatchVersion()); - this->SetDefinition("CMAKE_PATCH_VERSION", temp); - sprintf(temp, "%d", cmVersion::GetTweakVersion()); - this->SetDefinition("CMAKE_TWEAK_VERSION", temp); - this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); - - this->SetDefinition("CMAKE_FILES_DIRECTORY", - cmake::GetCMakeFilesDirectory()); - - // Setup the default include file regular expression (match everything). - this->Position->BuildSystemDirectory->Properties.SetProperty( - "INCLUDE_REGULAR_EXPRESSION", "^.*$"); -} - -void cmState::Snapshot::SetDirectoryDefinitions() -{ - this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory()); - this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", - this->State->GetSourceDirectory()); - this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory()); - this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", - this->State->GetBinaryDirectory()); -} - -void cmState::Snapshot::InitializeFromParent() -{ - PositionType parent = this->Position->DirectoryParent; - assert(this->Position->Vars.IsValid()); - assert(parent->Vars.IsValid()); - - *this->Position->Vars = - cmDefinitions::MakeClosure(parent->Vars, parent->Root); - - InitializeContentFromParent( - parent->BuildSystemDirectory->IncludeDirectories, - this->Position->BuildSystemDirectory->IncludeDirectories, - parent->BuildSystemDirectory->IncludeDirectoryBacktraces, - this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces, - this->Position->IncludeDirectoryPosition); - - InitializeContentFromParent( - parent->BuildSystemDirectory->CompileDefinitions, - this->Position->BuildSystemDirectory->CompileDefinitions, - parent->BuildSystemDirectory->CompileDefinitionsBacktraces, - this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces, - this->Position->CompileDefinitionsPosition); - - InitializeContentFromParent( - parent->BuildSystemDirectory->CompileOptions, - this->Position->BuildSystemDirectory->CompileOptions, - parent->BuildSystemDirectory->CompileOptionsBacktraces, - this->Position->BuildSystemDirectory->CompileOptionsBacktraces, - this->Position->CompileOptionsPosition); -} - -cmState* cmState::Snapshot::GetState() const -{ - return this->State; -} - -cmState::Directory cmState::Snapshot::GetDirectory() const -{ - return Directory(this->Position->BuildSystemDirectory, *this); -} - -void cmState::Snapshot::SetProjectName(const std::string& name) -{ - this->Position->BuildSystemDirectory->ProjectName = name; -} - -std::string cmState::Snapshot::GetProjectName() const -{ - return this->Position->BuildSystemDirectory->ProjectName; -} - -void cmState::Snapshot::InitializeFromParent_ForSubdirsCommand() -{ - std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR"); - std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR"); - this->InitializeFromParent(); - this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory()); - this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory()); - - this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir); - this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir); -} - -cmState::Directory::Directory( - cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter, - const cmState::Snapshot& snapshot) - : DirectoryState(iter) - , Snapshot_(snapshot) -{ -} - -template <typename T, typename U> -cmStringRange GetPropertyContent(T const& content, U contentEndPosition) -{ - std::vector<std::string>::const_iterator end = - content.begin() + contentEndPosition; - - std::vector<std::string>::const_reverse_iterator rbegin = - cmMakeReverseIterator(end); - rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); - - return cmMakeRange(rbegin.base(), end); -} - -template <typename T, typename U, typename V> -cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces, - V contentEndPosition) -{ - std::vector<std::string>::const_iterator entryEnd = - content.begin() + contentEndPosition; - - std::vector<std::string>::const_reverse_iterator rbegin = - cmMakeReverseIterator(entryEnd); - rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); - - std::vector<cmListFileBacktrace>::const_iterator it = - backtraces.begin() + std::distance(content.begin(), rbegin.base()); - - std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end(); - return cmMakeRange(it, end); -} - -template <typename T, typename U, typename V> -void AppendEntry(T& content, U& backtraces, V& endContentPosition, - const std::string& value, const cmListFileBacktrace& lfbt) -{ - if (value.empty()) { - return; - } - - assert(endContentPosition == content.size()); - - content.push_back(value); - backtraces.push_back(lfbt); - - endContentPosition = content.size(); -} - -template <typename T, typename U, typename V> -void SetContent(T& content, U& backtraces, V& endContentPosition, - const std::string& vec, const cmListFileBacktrace& lfbt) -{ - assert(endContentPosition == content.size()); - - content.resize(content.size() + 2); - backtraces.resize(backtraces.size() + 2); - - content.back() = vec; - backtraces.back() = lfbt; - - endContentPosition = content.size(); -} - -template <typename T, typename U, typename V> -void ClearContent(T& content, U& backtraces, V& endContentPosition) -{ - assert(endContentPosition == content.size()); - - content.resize(content.size() + 1); - backtraces.resize(backtraces.size() + 1); - - endContentPosition = content.size(); -} - -cmStringRange cmState::Directory::GetIncludeDirectoriesEntries() const -{ - return GetPropertyContent( - this->DirectoryState->IncludeDirectories, - this->Snapshot_.Position->IncludeDirectoryPosition); -} - -cmBacktraceRange cmState::Directory::GetIncludeDirectoriesEntryBacktraces() - const -{ - return GetPropertyBacktraces( - this->DirectoryState->IncludeDirectories, - this->DirectoryState->IncludeDirectoryBacktraces, - this->Snapshot_.Position->IncludeDirectoryPosition); -} - -void cmState::Directory::AppendIncludeDirectoriesEntry( - const std::string& vec, const cmListFileBacktrace& lfbt) -{ - AppendEntry(this->DirectoryState->IncludeDirectories, - this->DirectoryState->IncludeDirectoryBacktraces, - this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt); -} - -void cmState::Directory::PrependIncludeDirectoriesEntry( - const std::string& vec, const cmListFileBacktrace& lfbt) -{ - std::vector<std::string>::iterator entryEnd = - this->DirectoryState->IncludeDirectories.begin() + - this->Snapshot_.Position->IncludeDirectoryPosition; - - std::vector<std::string>::reverse_iterator rend = - this->DirectoryState->IncludeDirectories.rend(); - std::vector<std::string>::reverse_iterator rbegin = - cmMakeReverseIterator(entryEnd); - rbegin = std::find(rbegin, rend, cmPropertySentinal); - - std::vector<std::string>::iterator entryIt = rbegin.base(); - std::vector<std::string>::iterator entryBegin = - this->DirectoryState->IncludeDirectories.begin(); - - std::vector<cmListFileBacktrace>::iterator btIt = - this->DirectoryState->IncludeDirectoryBacktraces.begin() + - std::distance(entryBegin, entryIt); - - this->DirectoryState->IncludeDirectories.insert(entryIt, vec); - this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt); - - this->Snapshot_.Position->IncludeDirectoryPosition = - this->DirectoryState->IncludeDirectories.size(); -} - -void cmState::Directory::SetIncludeDirectories(const std::string& vec, - const cmListFileBacktrace& lfbt) -{ - SetContent(this->DirectoryState->IncludeDirectories, - this->DirectoryState->IncludeDirectoryBacktraces, - this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt); -} - -void cmState::Directory::ClearIncludeDirectories() -{ - ClearContent(this->DirectoryState->IncludeDirectories, - this->DirectoryState->IncludeDirectoryBacktraces, - this->Snapshot_.Position->IncludeDirectoryPosition); -} - -cmStringRange cmState::Directory::GetCompileDefinitionsEntries() const -{ - return GetPropertyContent( - this->DirectoryState->CompileDefinitions, - this->Snapshot_.Position->CompileDefinitionsPosition); -} - -cmBacktraceRange cmState::Directory::GetCompileDefinitionsEntryBacktraces() - const -{ - return GetPropertyBacktraces( - this->DirectoryState->CompileDefinitions, - this->DirectoryState->CompileDefinitionsBacktraces, - this->Snapshot_.Position->CompileDefinitionsPosition); -} - -void cmState::Directory::AppendCompileDefinitionsEntry( - const std::string& vec, const cmListFileBacktrace& lfbt) -{ - AppendEntry(this->DirectoryState->CompileDefinitions, - this->DirectoryState->CompileDefinitionsBacktraces, - this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt); -} - -void cmState::Directory::SetCompileDefinitions(const std::string& vec, - const cmListFileBacktrace& lfbt) -{ - SetContent(this->DirectoryState->CompileDefinitions, - this->DirectoryState->CompileDefinitionsBacktraces, - this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt); -} - -void cmState::Directory::ClearCompileDefinitions() -{ - ClearContent(this->DirectoryState->CompileDefinitions, - this->DirectoryState->CompileDefinitionsBacktraces, - this->Snapshot_.Position->CompileDefinitionsPosition); -} - -cmStringRange cmState::Directory::GetCompileOptionsEntries() const -{ - return GetPropertyContent(this->DirectoryState->CompileOptions, - this->Snapshot_.Position->CompileOptionsPosition); -} - -cmBacktraceRange cmState::Directory::GetCompileOptionsEntryBacktraces() const -{ - return GetPropertyBacktraces( - this->DirectoryState->CompileOptions, - this->DirectoryState->CompileOptionsBacktraces, - this->Snapshot_.Position->CompileOptionsPosition); -} - -void cmState::Directory::AppendCompileOptionsEntry( - const std::string& vec, const cmListFileBacktrace& lfbt) -{ - AppendEntry(this->DirectoryState->CompileOptions, - this->DirectoryState->CompileOptionsBacktraces, - this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt); -} - -void cmState::Directory::SetCompileOptions(const std::string& vec, - const cmListFileBacktrace& lfbt) -{ - SetContent(this->DirectoryState->CompileOptions, - this->DirectoryState->CompileOptionsBacktraces, - this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt); -} - -void cmState::Directory::ClearCompileOptions() -{ - ClearContent(this->DirectoryState->CompileOptions, - this->DirectoryState->CompileOptionsBacktraces, - this->Snapshot_.Position->CompileOptionsPosition); -} - -bool cmState::Snapshot::StrictWeakOrder::operator()( - const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const -{ - return lhs.Position.StrictWeakOrdered(rhs.Position); -} - -void cmState::Directory::SetProperty(const std::string& prop, - const char* value, - cmListFileBacktrace const& lfbt) -{ - if (prop == "INCLUDE_DIRECTORIES") { - if (!value) { - this->ClearIncludeDirectories(); - return; - } - this->SetIncludeDirectories(value, lfbt); - return; - } - if (prop == "COMPILE_OPTIONS") { - if (!value) { - this->ClearCompileOptions(); - return; - } - this->SetCompileOptions(value, lfbt); - return; - } - if (prop == "COMPILE_DEFINITIONS") { - if (!value) { - this->ClearCompileDefinitions(); - return; - } - this->SetCompileDefinitions(value, lfbt); - return; - } - - this->DirectoryState->Properties.SetProperty(prop, value); -} - -void cmState::Directory::AppendProperty(const std::string& prop, - const char* value, bool asString, - cmListFileBacktrace const& lfbt) -{ - if (prop == "INCLUDE_DIRECTORIES") { - this->AppendIncludeDirectoriesEntry(value, lfbt); - return; - } - if (prop == "COMPILE_OPTIONS") { - this->AppendCompileOptionsEntry(value, lfbt); - return; - } - if (prop == "COMPILE_DEFINITIONS") { - this->AppendCompileDefinitionsEntry(value, lfbt); - return; - } - - this->DirectoryState->Properties.AppendProperty(prop, value, asString); -} - -const char* cmState::Directory::GetProperty(const std::string& prop) const -{ - const bool chain = - this->Snapshot_.State->IsPropertyChained(prop, cmProperty::DIRECTORY); - return this->GetProperty(prop, chain); -} - -const char* cmState::Directory::GetProperty(const std::string& prop, - bool chain) const -{ - static std::string output; - output = ""; - if (prop == "PARENT_DIRECTORY") { - cmState::Snapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent(); - if (parent.IsValid()) { - return parent.GetDirectory().GetCurrentSource(); - } - return ""; - } - if (prop == kBINARY_DIR) { - output = this->GetCurrentBinary(); - return output.c_str(); - } - if (prop == kSOURCE_DIR) { - output = this->GetCurrentSource(); - return output.c_str(); - } - if (prop == kSUBDIRECTORIES) { - std::vector<std::string> child_dirs; - std::vector<cmState::Snapshot> const& children = - this->DirectoryState->Children; - for (std::vector<cmState::Snapshot>::const_iterator ci = children.begin(); - ci != children.end(); ++ci) { - child_dirs.push_back(ci->GetDirectory().GetCurrentSource()); - } - output = cmJoin(child_dirs, ";"); - return output.c_str(); - } - if (prop == kBUILDSYSTEM_TARGETS) { - output = cmJoin(this->DirectoryState->NormalTargetNames, ";"); - return output.c_str(); - } - - if (prop == "LISTFILE_STACK") { - std::vector<std::string> listFiles; - cmState::Snapshot snp = this->Snapshot_; - while (snp.IsValid()) { - listFiles.push_back(snp.GetExecutionListFile()); - snp = snp.GetCallStackParent(); - } - std::reverse(listFiles.begin(), listFiles.end()); - output = cmJoin(listFiles, ";"); - return output.c_str(); - } - if (prop == "CACHE_VARIABLES") { - output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";"); - return output.c_str(); - } - if (prop == "VARIABLES") { - std::vector<std::string> res = this->Snapshot_.ClosureKeys(); - std::vector<std::string> cacheKeys = - this->Snapshot_.State->GetCacheEntryKeys(); - res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); - std::sort(res.begin(), res.end()); - output = cmJoin(res, ";"); - return output.c_str(); - } - if (prop == "INCLUDE_DIRECTORIES") { - output = cmJoin(this->GetIncludeDirectoriesEntries(), ";"); - return output.c_str(); - } - if (prop == "COMPILE_OPTIONS") { - output = cmJoin(this->GetCompileOptionsEntries(), ";"); - return output.c_str(); - } - if (prop == "COMPILE_DEFINITIONS") { - output = cmJoin(this->GetCompileDefinitionsEntries(), ";"); - return output.c_str(); - } - - const char* retVal = this->DirectoryState->Properties.GetPropertyValue(prop); - if (!retVal && chain) { - Snapshot parentSnapshot = this->Snapshot_.GetBuildsystemDirectoryParent(); - if (parentSnapshot.IsValid()) { - return parentSnapshot.GetDirectory().GetProperty(prop, chain); - } - return this->Snapshot_.State->GetGlobalProperty(prop); - } - - return retVal; -} - -bool cmState::Directory::GetPropertyAsBool(const std::string& prop) const -{ - return cmSystemTools::IsOn(this->GetProperty(prop)); -} - -std::vector<std::string> cmState::Directory::GetPropertyKeys() const -{ - std::vector<std::string> keys; - keys.reserve(this->DirectoryState->Properties.size()); - for (cmPropertyMap::const_iterator it = - this->DirectoryState->Properties.begin(); - it != this->DirectoryState->Properties.end(); ++it) { - keys.push_back(it->first); - } - return keys; -} - -void cmState::Directory::AddNormalTargetName(std::string const& name) -{ - this->DirectoryState->NormalTargetNames.push_back(name); -} - -bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) -{ - return lhs.Position == rhs.Position; -} - -bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) -{ - return lhs.Position != rhs.Position; + return cmStateSnapshot(this, prevPos); } static bool ParseEntryWithoutType(const std::string& entry, std::string& var, @@ -1802,7 +812,8 @@ static bool ParseEntryWithoutType(const std::string& entry, std::string& var, } bool cmState::ParseCacheEntry(const std::string& entry, std::string& var, - std::string& value, CacheEntryType& type) + std::string& value, + cmStateEnums::CacheEntryType& type) { // input line is: key:type=value static cmsys::RegularExpression reg( diff --git a/Source/cmState.h b/Source/cmState.h index feed1c7..6d74815 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -8,10 +8,10 @@ #include "cmAlgorithms.h" #include "cmDefinitions.h" #include "cmLinkedTree.h" -#include "cmPolicies.h" #include "cmProperty.h" #include "cmPropertyDefinitionMap.h" #include "cmPropertyMap.h" +#include "cmStateTypes.h" #include <map> #include <set> @@ -23,202 +23,36 @@ class cmCommand; class cmListFileBacktrace; class cmPropertyDefinition; +class cmStateDirectory; +class cmStateSnapshot; + class cmState { - struct SnapshotDataType; - struct PolicyStackEntry; - struct BuildsystemDirectoryStateType; - typedef cmLinkedTree<SnapshotDataType>::iterator PositionType; - friend class Snapshot; + friend class cmStateSnapshot; public: cmState(); ~cmState(); - enum SnapshotType - { - BaseType, - BuildsystemDirectoryType, - FunctionCallType, - MacroCallType, - IncludeFileType, - InlineListFileType, - PolicyScopeType, - VariableScopeType - }; - - class Directory; - - class Snapshot - { - public: - Snapshot(cmState* state = CM_NULLPTR); - Snapshot(cmState* state, PositionType position); - - const char* GetDefinition(std::string const& name) const; - bool IsInitialized(std::string const& name) const; - void SetDefinition(std::string const& name, std::string const& value); - void RemoveDefinition(std::string const& name); - std::vector<std::string> UnusedKeys() const; - std::vector<std::string> ClosureKeys() const; - bool RaiseScope(std::string const& var, const char* varDef); - - void SetListFile(std::string const& listfile); - - std::string GetExecutionListFile() const; - - std::vector<Snapshot> GetChildren(); - - bool IsValid() const; - Snapshot GetBuildsystemDirectoryParent() const; - Snapshot GetCallStackParent() const; - Snapshot GetCallStackBottom() const; - SnapshotType GetType() const; - - void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); - cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; - bool HasDefinedPolicyCMP0011(); - void PushPolicy(cmPolicies::PolicyMap entry, bool weak); - bool PopPolicy(); - bool CanPopPolicyScope(); - - cmState* GetState() const; - - Directory GetDirectory() const; - - void SetProjectName(std::string const& name); - std::string GetProjectName() const; - - void InitializeFromParent_ForSubdirsCommand(); - - struct StrictWeakOrder - { - bool operator()(const cmState::Snapshot& lhs, - const cmState::Snapshot& rhs) const; - }; - - void SetDirectoryDefinitions(); - void SetDefaultDefinitions(); - - private: - friend bool operator==(const cmState::Snapshot& lhs, - const cmState::Snapshot& rhs); - friend bool operator!=(const cmState::Snapshot& lhs, - const cmState::Snapshot& rhs); - friend class cmState; - friend class Directory; - friend struct StrictWeakOrder; - - void InitializeFromParent(); - - cmState* State; - cmState::PositionType Position; - }; - - class Directory - { - Directory(cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter, - Snapshot const& snapshot); - - public: - const char* GetCurrentSource() const; - void SetCurrentSource(std::string const& dir); - const char* GetCurrentBinary() const; - void SetCurrentBinary(std::string const& dir); - - const char* GetRelativePathTopSource() const; - const char* GetRelativePathTopBinary() const; - void SetRelativePathTopSource(const char* dir); - void SetRelativePathTopBinary(const char* dir); - - cmStringRange GetIncludeDirectoriesEntries() const; - cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const; - void AppendIncludeDirectoriesEntry(std::string const& vec, - cmListFileBacktrace const& lfbt); - void PrependIncludeDirectoriesEntry(std::string const& vec, - cmListFileBacktrace const& lfbt); - void SetIncludeDirectories(std::string const& vec, - cmListFileBacktrace const& lfbt); - void ClearIncludeDirectories(); - - cmStringRange GetCompileDefinitionsEntries() const; - cmBacktraceRange GetCompileDefinitionsEntryBacktraces() const; - void AppendCompileDefinitionsEntry(std::string const& vec, - cmListFileBacktrace const& lfbt); - void SetCompileDefinitions(std::string const& vec, - cmListFileBacktrace const& lfbt); - void ClearCompileDefinitions(); - - cmStringRange GetCompileOptionsEntries() const; - cmBacktraceRange GetCompileOptionsEntryBacktraces() const; - void AppendCompileOptionsEntry(std::string const& vec, - cmListFileBacktrace const& lfbt); - void SetCompileOptions(std::string const& vec, - cmListFileBacktrace const& lfbt); - void ClearCompileOptions(); - - void SetProperty(const std::string& prop, const char* value, - cmListFileBacktrace const& lfbt); - void AppendProperty(const std::string& prop, const char* value, - bool asString, cmListFileBacktrace const& lfbt); - const char* GetProperty(const std::string& prop) const; - const char* GetProperty(const std::string& prop, bool chain) const; - bool GetPropertyAsBool(const std::string& prop) const; - std::vector<std::string> GetPropertyKeys() const; - - void AddNormalTargetName(std::string const& name); - - private: - void ComputeRelativePathTopSource(); - void ComputeRelativePathTopBinary(); - - private: - cmLinkedTree<BuildsystemDirectoryStateType>::iterator DirectoryState; - Snapshot Snapshot_; - friend class Snapshot; - }; - - enum TargetType - { - EXECUTABLE, - STATIC_LIBRARY, - SHARED_LIBRARY, - MODULE_LIBRARY, - OBJECT_LIBRARY, - UTILITY, - GLOBAL_TARGET, - INTERFACE_LIBRARY, - UNKNOWN_LIBRARY - }; - - static const char* GetTargetTypeName(cmState::TargetType targetType); - - Snapshot CreateBaseSnapshot(); - Snapshot CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot); - Snapshot CreateFunctionCallSnapshot(Snapshot originSnapshot, - std::string const& fileName); - Snapshot CreateMacroCallSnapshot(Snapshot originSnapshot, - std::string const& fileName); - Snapshot CreateIncludeFileSnapshot(Snapshot originSnapshot, - std::string const& fileName); - Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot); - Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, - std::string const& fileName); - Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot); - Snapshot Pop(Snapshot originSnapshot); - - enum CacheEntryType - { - BOOL = 0, - PATH, - FILEPATH, - STRING, - INTERNAL, - STATIC, - UNINITIALIZED - }; - static CacheEntryType StringToCacheEntryType(const char*); - static const char* CacheEntryTypeToString(CacheEntryType); + static const char* GetTargetTypeName(cmStateEnums::TargetType targetType); + + cmStateSnapshot CreateBaseSnapshot(); + cmStateSnapshot CreateBuildsystemDirectorySnapshot( + cmStateSnapshot originSnapshot); + cmStateSnapshot CreateFunctionCallSnapshot(cmStateSnapshot originSnapshot, + std::string const& fileName); + cmStateSnapshot CreateMacroCallSnapshot(cmStateSnapshot originSnapshot, + std::string const& fileName); + cmStateSnapshot CreateIncludeFileSnapshot(cmStateSnapshot originSnapshot, + std::string const& fileName); + cmStateSnapshot CreateVariableScopeSnapshot(cmStateSnapshot originSnapshot); + cmStateSnapshot CreateInlineListFileSnapshot(cmStateSnapshot originSnapshot, + std::string const& fileName); + cmStateSnapshot CreatePolicyScopeSnapshot(cmStateSnapshot originSnapshot); + cmStateSnapshot Pop(cmStateSnapshot originSnapshot); + + static cmStateEnums::CacheEntryType StringToCacheEntryType(const char*); + static const char* CacheEntryTypeToString(cmStateEnums::CacheEntryType); static bool IsCacheEntryType(std::string const& key); bool LoadCache(const std::string& path, bool internal, @@ -232,7 +66,7 @@ public: std::vector<std::string> GetCacheEntryKeys() const; const char* GetCacheEntryValue(std::string const& key) const; const char* GetInitializedCacheValue(std::string const& key) const; - CacheEntryType GetCacheEntryType(std::string const& key) const; + cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const; void SetCacheEntryValue(std::string const& key, std::string const& value); void SetCacheValue(std::string const& key, std::string const& value); @@ -257,9 +91,10 @@ public: ///! Break up a line like VAR:type="value" into var, type and value static bool ParseCacheEntry(const std::string& entry, std::string& var, - std::string& value, CacheEntryType& type); + std::string& value, + cmStateEnums::CacheEntryType& type); - Snapshot Reset(); + cmStateSnapshot Reset(); // Define a property void DefineProperty(const std::string& name, cmProperty::ScopeType scope, const char* ShortDescription, @@ -321,7 +156,8 @@ public: private: friend class cmake; void AddCacheEntry(const std::string& key, const char* value, - const char* helpString, CacheEntryType type); + const char* helpString, + cmStateEnums::CacheEntryType type); std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; std::vector<std::string> EnabledLanguages; @@ -329,12 +165,13 @@ private: cmPropertyMap GlobalProperties; cmCacheManager* CacheManager; - cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory; + cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType> + BuildsystemDirectory; cmLinkedTree<std::string> ExecutionListFiles; - cmLinkedTree<PolicyStackEntry> PolicyStack; - cmLinkedTree<SnapshotDataType> SnapshotData; + cmLinkedTree<cmStateDetail::PolicyStackEntry> PolicyStack; + cmLinkedTree<cmStateDetail::SnapshotDataType> SnapshotData; cmLinkedTree<cmDefinitions> VarTree; std::string SourceDirectory; @@ -348,7 +185,4 @@ private: bool MSYSShell; }; -bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); -bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); - #endif diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx new file mode 100644 index 0000000..01e1e7e --- /dev/null +++ b/Source/cmStateDirectory.cxx @@ -0,0 +1,518 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmStateDirectory.h" +#include "cmState.h" +#include "cmStatePrivate.h" +#include "cmSystemTools.h" + +static std::string const kBINARY_DIR = "BINARY_DIR"; +static std::string const kBUILDSYSTEM_TARGETS = "BUILDSYSTEM_TARGETS"; +static std::string const kSOURCE_DIR = "SOURCE_DIR"; +static std::string const kSUBDIRECTORIES = "SUBDIRECTORIES"; + +void cmStateDirectory::ComputeRelativePathTopSource() +{ + // Relative path conversion inside the source tree is not used to + // construct relative paths passed to build tools so it is safe to use + // even when the source is a network path. + + cmStateSnapshot snapshot = this->Snapshot_; + std::vector<cmStateSnapshot> snapshots; + snapshots.push_back(snapshot); + while (true) { + snapshot = snapshot.GetBuildsystemDirectoryParent(); + if (snapshot.IsValid()) { + snapshots.push_back(snapshot); + } else { + break; + } + } + + std::string result = snapshots.front().GetDirectory().GetCurrentSource(); + + for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1; + it != snapshots.end(); ++it) { + std::string currentSource = it->GetDirectory().GetCurrentSource(); + if (cmSystemTools::IsSubDirectory(result, currentSource)) { + result = currentSource; + } + } + this->DirectoryState->RelativePathTopSource = result; +} + +void cmStateDirectory::ComputeRelativePathTopBinary() +{ + cmStateSnapshot snapshot = this->Snapshot_; + std::vector<cmStateSnapshot> snapshots; + snapshots.push_back(snapshot); + while (true) { + snapshot = snapshot.GetBuildsystemDirectoryParent(); + if (snapshot.IsValid()) { + snapshots.push_back(snapshot); + } else { + break; + } + } + + std::string result = snapshots.front().GetDirectory().GetCurrentBinary(); + + for (std::vector<cmStateSnapshot>::const_iterator it = snapshots.begin() + 1; + it != snapshots.end(); ++it) { + std::string currentBinary = it->GetDirectory().GetCurrentBinary(); + if (cmSystemTools::IsSubDirectory(result, currentBinary)) { + result = currentBinary; + } + } + + // The current working directory on Windows cannot be a network + // path. Therefore relative paths cannot work when the binary tree + // is a network path. + if (result.size() < 2 || result.substr(0, 2) != "//") { + this->DirectoryState->RelativePathTopBinary = result; + } else { + this->DirectoryState->RelativePathTopBinary = ""; + } +} + +const char* cmStateDirectory::GetCurrentSource() const +{ + return this->DirectoryState->Location.c_str(); +} + +void cmStateDirectory::SetCurrentSource(std::string const& dir) +{ + std::string& loc = this->DirectoryState->Location; + loc = dir; + cmSystemTools::ConvertToUnixSlashes(loc); + loc = cmSystemTools::CollapseFullPath(loc); + + this->ComputeRelativePathTopSource(); + + this->Snapshot_.SetDefinition("CMAKE_CURRENT_SOURCE_DIR", loc); +} + +const char* cmStateDirectory::GetCurrentBinary() const +{ + return this->DirectoryState->OutputLocation.c_str(); +} + +void cmStateDirectory::SetCurrentBinary(std::string const& dir) +{ + std::string& loc = this->DirectoryState->OutputLocation; + loc = dir; + cmSystemTools::ConvertToUnixSlashes(loc); + loc = cmSystemTools::CollapseFullPath(loc); + + this->ComputeRelativePathTopBinary(); + + this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc); +} + +const char* cmStateDirectory::GetRelativePathTopSource() const +{ + return this->DirectoryState->RelativePathTopSource.c_str(); +} + +const char* cmStateDirectory::GetRelativePathTopBinary() const +{ + return this->DirectoryState->RelativePathTopBinary.c_str(); +} + +void cmStateDirectory::SetRelativePathTopSource(const char* dir) +{ + this->DirectoryState->RelativePathTopSource = dir; +} + +void cmStateDirectory::SetRelativePathTopBinary(const char* dir) +{ + this->DirectoryState->RelativePathTopBinary = dir; +} + +cmStateDirectory::cmStateDirectory( + cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator iter, + const cmStateSnapshot& snapshot) + : DirectoryState(iter) + , Snapshot_(snapshot) +{ +} + +template <typename T, typename U> +cmStringRange GetPropertyContent(T const& content, U contentEndPosition) +{ + std::vector<std::string>::const_iterator end = + content.begin() + contentEndPosition; + + std::vector<std::string>::const_reverse_iterator rbegin = + cmMakeReverseIterator(end); + rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); + + return cmMakeRange(rbegin.base(), end); +} + +template <typename T, typename U, typename V> +cmBacktraceRange GetPropertyBacktraces(T const& content, U const& backtraces, + V contentEndPosition) +{ + std::vector<std::string>::const_iterator entryEnd = + content.begin() + contentEndPosition; + + std::vector<std::string>::const_reverse_iterator rbegin = + cmMakeReverseIterator(entryEnd); + rbegin = std::find(rbegin, content.rend(), cmPropertySentinal); + + std::vector<cmListFileBacktrace>::const_iterator it = + backtraces.begin() + std::distance(content.begin(), rbegin.base()); + + std::vector<cmListFileBacktrace>::const_iterator end = backtraces.end(); + return cmMakeRange(it, end); +} + +template <typename T, typename U, typename V> +void AppendEntry(T& content, U& backtraces, V& endContentPosition, + const std::string& value, const cmListFileBacktrace& lfbt) +{ + if (value.empty()) { + return; + } + + assert(endContentPosition == content.size()); + + content.push_back(value); + backtraces.push_back(lfbt); + + endContentPosition = content.size(); +} + +template <typename T, typename U, typename V> +void SetContent(T& content, U& backtraces, V& endContentPosition, + const std::string& vec, const cmListFileBacktrace& lfbt) +{ + assert(endContentPosition == content.size()); + + content.resize(content.size() + 2); + backtraces.resize(backtraces.size() + 2); + + content.back() = vec; + backtraces.back() = lfbt; + + endContentPosition = content.size(); +} + +template <typename T, typename U, typename V> +void ClearContent(T& content, U& backtraces, V& endContentPosition) +{ + assert(endContentPosition == content.size()); + + content.resize(content.size() + 1); + backtraces.resize(backtraces.size() + 1); + + endContentPosition = content.size(); +} + +cmStringRange cmStateDirectory::GetIncludeDirectoriesEntries() const +{ + return GetPropertyContent( + this->DirectoryState->IncludeDirectories, + this->Snapshot_.Position->IncludeDirectoryPosition); +} + +cmBacktraceRange cmStateDirectory::GetIncludeDirectoriesEntryBacktraces() const +{ + return GetPropertyBacktraces( + this->DirectoryState->IncludeDirectories, + this->DirectoryState->IncludeDirectoryBacktraces, + this->Snapshot_.Position->IncludeDirectoryPosition); +} + +void cmStateDirectory::AppendIncludeDirectoriesEntry( + const std::string& vec, const cmListFileBacktrace& lfbt) +{ + AppendEntry(this->DirectoryState->IncludeDirectories, + this->DirectoryState->IncludeDirectoryBacktraces, + this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt); +} + +void cmStateDirectory::PrependIncludeDirectoriesEntry( + const std::string& vec, const cmListFileBacktrace& lfbt) +{ + std::vector<std::string>::iterator entryEnd = + this->DirectoryState->IncludeDirectories.begin() + + this->Snapshot_.Position->IncludeDirectoryPosition; + + std::vector<std::string>::reverse_iterator rend = + this->DirectoryState->IncludeDirectories.rend(); + std::vector<std::string>::reverse_iterator rbegin = + cmMakeReverseIterator(entryEnd); + rbegin = std::find(rbegin, rend, cmPropertySentinal); + + std::vector<std::string>::iterator entryIt = rbegin.base(); + std::vector<std::string>::iterator entryBegin = + this->DirectoryState->IncludeDirectories.begin(); + + std::vector<cmListFileBacktrace>::iterator btIt = + this->DirectoryState->IncludeDirectoryBacktraces.begin() + + std::distance(entryBegin, entryIt); + + this->DirectoryState->IncludeDirectories.insert(entryIt, vec); + this->DirectoryState->IncludeDirectoryBacktraces.insert(btIt, lfbt); + + this->Snapshot_.Position->IncludeDirectoryPosition = + this->DirectoryState->IncludeDirectories.size(); +} + +void cmStateDirectory::SetIncludeDirectories(const std::string& vec, + const cmListFileBacktrace& lfbt) +{ + SetContent(this->DirectoryState->IncludeDirectories, + this->DirectoryState->IncludeDirectoryBacktraces, + this->Snapshot_.Position->IncludeDirectoryPosition, vec, lfbt); +} + +void cmStateDirectory::ClearIncludeDirectories() +{ + ClearContent(this->DirectoryState->IncludeDirectories, + this->DirectoryState->IncludeDirectoryBacktraces, + this->Snapshot_.Position->IncludeDirectoryPosition); +} + +cmStringRange cmStateDirectory::GetCompileDefinitionsEntries() const +{ + return GetPropertyContent( + this->DirectoryState->CompileDefinitions, + this->Snapshot_.Position->CompileDefinitionsPosition); +} + +cmBacktraceRange cmStateDirectory::GetCompileDefinitionsEntryBacktraces() const +{ + return GetPropertyBacktraces( + this->DirectoryState->CompileDefinitions, + this->DirectoryState->CompileDefinitionsBacktraces, + this->Snapshot_.Position->CompileDefinitionsPosition); +} + +void cmStateDirectory::AppendCompileDefinitionsEntry( + const std::string& vec, const cmListFileBacktrace& lfbt) +{ + AppendEntry(this->DirectoryState->CompileDefinitions, + this->DirectoryState->CompileDefinitionsBacktraces, + this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt); +} + +void cmStateDirectory::SetCompileDefinitions(const std::string& vec, + const cmListFileBacktrace& lfbt) +{ + SetContent(this->DirectoryState->CompileDefinitions, + this->DirectoryState->CompileDefinitionsBacktraces, + this->Snapshot_.Position->CompileDefinitionsPosition, vec, lfbt); +} + +void cmStateDirectory::ClearCompileDefinitions() +{ + ClearContent(this->DirectoryState->CompileDefinitions, + this->DirectoryState->CompileDefinitionsBacktraces, + this->Snapshot_.Position->CompileDefinitionsPosition); +} + +cmStringRange cmStateDirectory::GetCompileOptionsEntries() const +{ + return GetPropertyContent(this->DirectoryState->CompileOptions, + this->Snapshot_.Position->CompileOptionsPosition); +} + +cmBacktraceRange cmStateDirectory::GetCompileOptionsEntryBacktraces() const +{ + return GetPropertyBacktraces( + this->DirectoryState->CompileOptions, + this->DirectoryState->CompileOptionsBacktraces, + this->Snapshot_.Position->CompileOptionsPosition); +} + +void cmStateDirectory::AppendCompileOptionsEntry( + const std::string& vec, const cmListFileBacktrace& lfbt) +{ + AppendEntry(this->DirectoryState->CompileOptions, + this->DirectoryState->CompileOptionsBacktraces, + this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt); +} + +void cmStateDirectory::SetCompileOptions(const std::string& vec, + const cmListFileBacktrace& lfbt) +{ + SetContent(this->DirectoryState->CompileOptions, + this->DirectoryState->CompileOptionsBacktraces, + this->Snapshot_.Position->CompileOptionsPosition, vec, lfbt); +} + +void cmStateDirectory::ClearCompileOptions() +{ + ClearContent(this->DirectoryState->CompileOptions, + this->DirectoryState->CompileOptionsBacktraces, + this->Snapshot_.Position->CompileOptionsPosition); +} + +void cmStateDirectory::SetProperty(const std::string& prop, const char* value, + cmListFileBacktrace const& lfbt) +{ + if (prop == "INCLUDE_DIRECTORIES") { + if (!value) { + this->ClearIncludeDirectories(); + return; + } + this->SetIncludeDirectories(value, lfbt); + return; + } + if (prop == "COMPILE_OPTIONS") { + if (!value) { + this->ClearCompileOptions(); + return; + } + this->SetCompileOptions(value, lfbt); + return; + } + if (prop == "COMPILE_DEFINITIONS") { + if (!value) { + this->ClearCompileDefinitions(); + return; + } + this->SetCompileDefinitions(value, lfbt); + return; + } + + this->DirectoryState->Properties.SetProperty(prop, value); +} + +void cmStateDirectory::AppendProperty(const std::string& prop, + const char* value, bool asString, + cmListFileBacktrace const& lfbt) +{ + if (prop == "INCLUDE_DIRECTORIES") { + this->AppendIncludeDirectoriesEntry(value, lfbt); + return; + } + if (prop == "COMPILE_OPTIONS") { + this->AppendCompileOptionsEntry(value, lfbt); + return; + } + if (prop == "COMPILE_DEFINITIONS") { + this->AppendCompileDefinitionsEntry(value, lfbt); + return; + } + + this->DirectoryState->Properties.AppendProperty(prop, value, asString); +} + +const char* cmStateDirectory::GetProperty(const std::string& prop) const +{ + const bool chain = + this->Snapshot_.State->IsPropertyChained(prop, cmProperty::DIRECTORY); + return this->GetProperty(prop, chain); +} + +const char* cmStateDirectory::GetProperty(const std::string& prop, + bool chain) const +{ + static std::string output; + output = ""; + if (prop == "PARENT_DIRECTORY") { + cmStateSnapshot parent = this->Snapshot_.GetBuildsystemDirectoryParent(); + if (parent.IsValid()) { + return parent.GetDirectory().GetCurrentSource(); + } + return ""; + } + if (prop == kBINARY_DIR) { + output = this->GetCurrentBinary(); + return output.c_str(); + } + if (prop == kSOURCE_DIR) { + output = this->GetCurrentSource(); + return output.c_str(); + } + if (prop == kSUBDIRECTORIES) { + std::vector<std::string> child_dirs; + std::vector<cmStateSnapshot> const& children = + this->DirectoryState->Children; + for (std::vector<cmStateSnapshot>::const_iterator ci = children.begin(); + ci != children.end(); ++ci) { + child_dirs.push_back(ci->GetDirectory().GetCurrentSource()); + } + output = cmJoin(child_dirs, ";"); + return output.c_str(); + } + if (prop == kBUILDSYSTEM_TARGETS) { + output = cmJoin(this->DirectoryState->NormalTargetNames, ";"); + return output.c_str(); + } + + if (prop == "LISTFILE_STACK") { + std::vector<std::string> listFiles; + cmStateSnapshot snp = this->Snapshot_; + while (snp.IsValid()) { + listFiles.push_back(snp.GetExecutionListFile()); + snp = snp.GetCallStackParent(); + } + std::reverse(listFiles.begin(), listFiles.end()); + output = cmJoin(listFiles, ";"); + return output.c_str(); + } + if (prop == "CACHE_VARIABLES") { + output = cmJoin(this->Snapshot_.State->GetCacheEntryKeys(), ";"); + return output.c_str(); + } + if (prop == "VARIABLES") { + std::vector<std::string> res = this->Snapshot_.ClosureKeys(); + std::vector<std::string> cacheKeys = + this->Snapshot_.State->GetCacheEntryKeys(); + res.insert(res.end(), cacheKeys.begin(), cacheKeys.end()); + std::sort(res.begin(), res.end()); + output = cmJoin(res, ";"); + return output.c_str(); + } + if (prop == "INCLUDE_DIRECTORIES") { + output = cmJoin(this->GetIncludeDirectoriesEntries(), ";"); + return output.c_str(); + } + if (prop == "COMPILE_OPTIONS") { + output = cmJoin(this->GetCompileOptionsEntries(), ";"); + return output.c_str(); + } + if (prop == "COMPILE_DEFINITIONS") { + output = cmJoin(this->GetCompileDefinitionsEntries(), ";"); + return output.c_str(); + } + + const char* retVal = this->DirectoryState->Properties.GetPropertyValue(prop); + if (!retVal && chain) { + cmStateSnapshot parentSnapshot = + this->Snapshot_.GetBuildsystemDirectoryParent(); + if (parentSnapshot.IsValid()) { + return parentSnapshot.GetDirectory().GetProperty(prop, chain); + } + return this->Snapshot_.State->GetGlobalProperty(prop); + } + + return retVal; +} + +bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const +{ + return cmSystemTools::IsOn(this->GetProperty(prop)); +} + +std::vector<std::string> cmStateDirectory::GetPropertyKeys() const +{ + std::vector<std::string> keys; + keys.reserve(this->DirectoryState->Properties.size()); + for (cmPropertyMap::const_iterator it = + this->DirectoryState->Properties.begin(); + it != this->DirectoryState->Properties.end(); ++it) { + keys.push_back(it->first); + } + return keys; +} + +void cmStateDirectory::AddNormalTargetName(std::string const& name) +{ + this->DirectoryState->NormalTargetNames.push_back(name); +} diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h new file mode 100644 index 0000000..17a89d8 --- /dev/null +++ b/Source/cmStateDirectory.h @@ -0,0 +1,82 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#ifndef cmStateDirectory_h +#define cmStateDirectory_h + +#include <cmConfigure.h> // IWYU pragma: keep + +#include <string> +#include <vector> + +#include "cmAlgorithms.h" +#include "cmListFileCache.h" +#include "cmStateSnapshot.h" +#include "cmStateTypes.h" + +class cmStateDirectory +{ + cmStateDirectory( + cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator iter, + cmStateSnapshot const& snapshot); + +public: + const char* GetCurrentSource() const; + void SetCurrentSource(std::string const& dir); + const char* GetCurrentBinary() const; + void SetCurrentBinary(std::string const& dir); + + const char* GetRelativePathTopSource() const; + const char* GetRelativePathTopBinary() const; + void SetRelativePathTopSource(const char* dir); + void SetRelativePathTopBinary(const char* dir); + + cmStringRange GetIncludeDirectoriesEntries() const; + cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const; + void AppendIncludeDirectoriesEntry(std::string const& vec, + cmListFileBacktrace const& lfbt); + void PrependIncludeDirectoriesEntry(std::string const& vec, + cmListFileBacktrace const& lfbt); + void SetIncludeDirectories(std::string const& vec, + cmListFileBacktrace const& lfbt); + void ClearIncludeDirectories(); + + cmStringRange GetCompileDefinitionsEntries() const; + cmBacktraceRange GetCompileDefinitionsEntryBacktraces() const; + void AppendCompileDefinitionsEntry(std::string const& vec, + cmListFileBacktrace const& lfbt); + void SetCompileDefinitions(std::string const& vec, + cmListFileBacktrace const& lfbt); + void ClearCompileDefinitions(); + + cmStringRange GetCompileOptionsEntries() const; + cmBacktraceRange GetCompileOptionsEntryBacktraces() const; + void AppendCompileOptionsEntry(std::string const& vec, + cmListFileBacktrace const& lfbt); + void SetCompileOptions(std::string const& vec, + cmListFileBacktrace const& lfbt); + void ClearCompileOptions(); + + void SetProperty(const std::string& prop, const char* value, + cmListFileBacktrace const& lfbt); + void AppendProperty(const std::string& prop, const char* value, + bool asString, cmListFileBacktrace const& lfbt); + const char* GetProperty(const std::string& prop) const; + const char* GetProperty(const std::string& prop, bool chain) const; + bool GetPropertyAsBool(const std::string& prop) const; + std::vector<std::string> GetPropertyKeys() const; + + void AddNormalTargetName(std::string const& name); + +private: + void ComputeRelativePathTopSource(); + void ComputeRelativePathTopBinary(); + +private: + cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator + DirectoryState; + cmStateSnapshot Snapshot_; + friend class cmStateSnapshot; +}; + +#endif diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h new file mode 100644 index 0000000..8daa3cf --- /dev/null +++ b/Source/cmStatePrivate.h @@ -0,0 +1,94 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#ifndef cmStatePrivate_h +#define cmStatePrivate_h + +#include <cmConfigure.h> // IWYU pragma: keep + +#include <string> +#include <vector> + +#include "cmDefinitions.h" +#include "cmLinkedTree.h" +#include "cmListFileCache.h" +#include "cmPropertyMap.h" +#include "cmStateTypes.h" + +static const std::string cmPropertySentinal = std::string(); + +struct cmStateDetail::SnapshotDataType +{ + cmStateDetail::PositionType ScopeParent; + cmStateDetail::PositionType DirectoryParent; + cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator Policies; + cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator PolicyRoot; + cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator PolicyScope; + cmStateEnums::SnapshotType SnapshotType; + bool Keep; + cmLinkedTree<std::string>::iterator ExecutionListFile; + cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator + BuildSystemDirectory; + cmLinkedTree<cmDefinitions>::iterator Vars; + cmLinkedTree<cmDefinitions>::iterator Root; + cmLinkedTree<cmDefinitions>::iterator Parent; + std::vector<std::string>::size_type IncludeDirectoryPosition; + std::vector<std::string>::size_type CompileDefinitionsPosition; + std::vector<std::string>::size_type CompileOptionsPosition; +}; + +struct cmStateDetail::PolicyStackEntry : public cmPolicies::PolicyMap +{ + typedef cmPolicies::PolicyMap derived; + PolicyStackEntry(bool w = false) + : derived() + , Weak(w) + { + } + PolicyStackEntry(derived const& d, bool w) + : derived(d) + , Weak(w) + { + } + PolicyStackEntry(PolicyStackEntry const& r) + : derived(r) + , Weak(r.Weak) + { + } + bool Weak; +}; + +struct cmStateDetail::BuildsystemDirectoryStateType +{ + cmStateDetail::PositionType DirectoryEnd; + + std::string Location; + std::string OutputLocation; + + // The top-most directories for relative path conversion. Both the + // source and destination location of a relative path conversion + // must be underneath one of these directories (both under source or + // both under binary) in order for the relative path to be evaluated + // safely by the build tools. + std::string RelativePathTopSource; + std::string RelativePathTopBinary; + + std::vector<std::string> IncludeDirectories; + std::vector<cmListFileBacktrace> IncludeDirectoryBacktraces; + + std::vector<std::string> CompileDefinitions; + std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces; + + std::vector<std::string> CompileOptions; + std::vector<cmListFileBacktrace> CompileOptionsBacktraces; + + std::vector<std::string> NormalTargetNames; + + std::string ProjectName; + + cmPropertyMap Properties; + + std::vector<cmStateSnapshot> Children; +}; + +#endif diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx new file mode 100644 index 0000000..7f86221 --- /dev/null +++ b/Source/cmStateSnapshot.cxx @@ -0,0 +1,415 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include "cmStateSnapshot.h" + +#include "cmState.h" +#include "cmStateDirectory.h" +#include "cmStatePrivate.h" +#include "cmSystemTools.h" +#include "cmVersion.h" +#include "cmake.h" + +cmStateSnapshot::cmStateSnapshot(cmState* state) + : State(state) + , Position() +{ +} + +std::vector<cmStateSnapshot> cmStateSnapshot::GetChildren() +{ + return this->Position->BuildSystemDirectory->Children; +} + +cmStateSnapshot::cmStateSnapshot(cmState* state, + cmStateDetail::PositionType position) + : State(state) + , Position(position) +{ +} + +cmStateEnums::SnapshotType cmStateSnapshot::GetType() const +{ + return this->Position->SnapshotType; +} + +void cmStateSnapshot::SetListFile(const std::string& listfile) +{ + *this->Position->ExecutionListFile = listfile; +} + +std::string cmStateSnapshot::GetExecutionListFile() const +{ + return *this->Position->ExecutionListFile; +} + +bool cmStateSnapshot::IsValid() const +{ + return this->State && this->Position.IsValid() + ? this->Position != this->State->SnapshotData.Root() + : false; +} + +cmStateSnapshot cmStateSnapshot::GetBuildsystemDirectoryParent() const +{ + cmStateSnapshot snapshot; + if (!this->State || this->Position == this->State->SnapshotData.Root()) { + return snapshot; + } + cmStateDetail::PositionType parentPos = this->Position->DirectoryParent; + if (parentPos != this->State->SnapshotData.Root()) { + snapshot = cmStateSnapshot(this->State, + parentPos->BuildSystemDirectory->DirectoryEnd); + } + + return snapshot; +} + +cmStateSnapshot cmStateSnapshot::GetCallStackParent() const +{ + assert(this->State); + assert(this->Position != this->State->SnapshotData.Root()); + + cmStateSnapshot snapshot; + cmStateDetail::PositionType parentPos = this->Position; + while (parentPos->SnapshotType == cmStateEnums::PolicyScopeType || + parentPos->SnapshotType == cmStateEnums::VariableScopeType) { + ++parentPos; + } + if (parentPos->SnapshotType == cmStateEnums::BuildsystemDirectoryType || + parentPos->SnapshotType == cmStateEnums::BaseType) { + return snapshot; + } + + ++parentPos; + while (parentPos->SnapshotType == cmStateEnums::PolicyScopeType || + parentPos->SnapshotType == cmStateEnums::VariableScopeType) { + ++parentPos; + } + + if (parentPos == this->State->SnapshotData.Root()) { + return snapshot; + } + + snapshot = cmStateSnapshot(this->State, parentPos); + return snapshot; +} + +cmStateSnapshot cmStateSnapshot::GetCallStackBottom() const +{ + assert(this->State); + assert(this->Position != this->State->SnapshotData.Root()); + + cmStateDetail::PositionType pos = this->Position; + while (pos->SnapshotType != cmStateEnums::BaseType && + pos->SnapshotType != cmStateEnums::BuildsystemDirectoryType && + pos != this->State->SnapshotData.Root()) { + ++pos; + } + return cmStateSnapshot(this->State, pos); +} + +void cmStateSnapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) +{ + cmStateDetail::PositionType pos = this->Position; + pos->Policies = this->State->PolicyStack.Push( + pos->Policies, cmStateDetail::PolicyStackEntry(entry, weak)); +} + +bool cmStateSnapshot::PopPolicy() +{ + cmStateDetail::PositionType pos = this->Position; + if (pos->Policies == pos->PolicyScope) { + return false; + } + pos->Policies = this->State->PolicyStack.Pop(pos->Policies); + return true; +} + +bool cmStateSnapshot::CanPopPolicyScope() +{ + return this->Position->Policies == this->Position->PolicyScope; +} + +void cmStateSnapshot::SetPolicy(cmPolicies::PolicyID id, + cmPolicies::PolicyStatus status) +{ + // Update the policy stack from the top to the top-most strong entry. + bool previous_was_weak = true; + for (cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator psi = + this->Position->Policies; + previous_was_weak && psi != this->Position->PolicyRoot; ++psi) { + psi->Set(id, status); + previous_was_weak = psi->Weak; + } +} + +cmPolicies::PolicyStatus cmStateSnapshot::GetPolicy( + cmPolicies::PolicyID id) const +{ + cmPolicies::PolicyStatus status = cmPolicies::GetPolicyStatus(id); + + if (status == cmPolicies::REQUIRED_ALWAYS || + status == cmPolicies::REQUIRED_IF_USED) { + return status; + } + + cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator dir = + this->Position->BuildSystemDirectory; + + while (true) { + assert(dir.IsValid()); + cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator leaf = + dir->DirectoryEnd->Policies; + cmLinkedTree<cmStateDetail::PolicyStackEntry>::iterator root = + dir->DirectoryEnd->PolicyRoot; + for (; leaf != root; ++leaf) { + if (leaf->IsDefined(id)) { + status = leaf->Get(id); + return status; + } + } + cmStateDetail::PositionType e = dir->DirectoryEnd; + cmStateDetail::PositionType p = e->DirectoryParent; + if (p == this->State->SnapshotData.Root()) { + break; + } + dir = p->BuildSystemDirectory; + } + return status; +} + +bool cmStateSnapshot::HasDefinedPolicyCMP0011() +{ + return !this->Position->Policies->IsEmpty(); +} + +const char* cmStateSnapshot::GetDefinition(std::string const& name) const +{ + assert(this->Position->Vars.IsValid()); + return cmDefinitions::Get(name, this->Position->Vars, this->Position->Root); +} + +bool cmStateSnapshot::IsInitialized(std::string const& name) const +{ + return cmDefinitions::HasKey(name, this->Position->Vars, + this->Position->Root); +} + +void cmStateSnapshot::SetDefinition(std::string const& name, + std::string const& value) +{ + this->Position->Vars->Set(name, value.c_str()); +} + +void cmStateSnapshot::RemoveDefinition(std::string const& name) +{ + this->Position->Vars->Set(name, CM_NULLPTR); +} + +std::vector<std::string> cmStateSnapshot::UnusedKeys() const +{ + return this->Position->Vars->UnusedKeys(); +} + +std::vector<std::string> cmStateSnapshot::ClosureKeys() const +{ + return cmDefinitions::ClosureKeys(this->Position->Vars, + this->Position->Root); +} + +bool cmStateSnapshot::RaiseScope(std::string const& var, const char* varDef) +{ + if (this->Position->ScopeParent == this->Position->DirectoryParent) { + cmStateSnapshot parentDir = this->GetBuildsystemDirectoryParent(); + if (!parentDir.IsValid()) { + return false; + } + // Update the definition in the parent directory top scope. This + // directory's scope was initialized by the closure of the parent + // scope, so we do not need to localize the definition first. + if (varDef) { + parentDir.SetDefinition(var, varDef); + } else { + parentDir.RemoveDefinition(var); + } + return true; + } + // First localize the definition in the current scope. + cmDefinitions::Raise(var, this->Position->Vars, this->Position->Root); + + // Now update the definition in the parent scope. + this->Position->Parent->Set(var, varDef); + return true; +} + +template <typename T, typename U, typename V> +void InitializeContentFromParent(T& parentContent, T& thisContent, + U& parentBacktraces, U& thisBacktraces, + V& contentEndPosition) +{ + std::vector<std::string>::const_iterator parentBegin = parentContent.begin(); + std::vector<std::string>::const_iterator parentEnd = parentContent.end(); + + std::vector<std::string>::const_reverse_iterator parentRbegin = + cmMakeReverseIterator(parentEnd); + std::vector<std::string>::const_reverse_iterator parentRend = + parentContent.rend(); + parentRbegin = std::find(parentRbegin, parentRend, cmPropertySentinal); + std::vector<std::string>::const_iterator parentIt = parentRbegin.base(); + + thisContent = std::vector<std::string>(parentIt, parentEnd); + + std::vector<cmListFileBacktrace>::const_iterator btIt = + parentBacktraces.begin() + std::distance(parentBegin, parentIt); + std::vector<cmListFileBacktrace>::const_iterator btEnd = + parentBacktraces.end(); + + thisBacktraces = std::vector<cmListFileBacktrace>(btIt, btEnd); + + contentEndPosition = thisContent.size(); +} + +void cmStateSnapshot::SetDefaultDefinitions() +{ +/* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. + With CMake must separate between target and host platform. In most cases + the tests for WIN32, UNIX and APPLE will be for the target system, so an + additional set of variables for the host system is required -> + CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. + WIN32, UNIX and APPLE are now set in the platform files in + Modules/Platforms/. + To keep cmake scripts (-P) and custom language and compiler modules + working, these variables are still also set here in this place, but they + will be reset in CMakeSystemSpecificInformation.cmake before the platform + files are executed. */ +#if defined(_WIN32) + this->SetDefinition("WIN32", "1"); + this->SetDefinition("CMAKE_HOST_WIN32", "1"); +#else + this->SetDefinition("UNIX", "1"); + this->SetDefinition("CMAKE_HOST_UNIX", "1"); +#endif +#if defined(__CYGWIN__) + std::string legacy; + if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) && + cmSystemTools::IsOn(legacy.c_str())) { + this->SetDefinition("WIN32", "1"); + this->SetDefinition("CMAKE_HOST_WIN32", "1"); + } +#endif +#if defined(__APPLE__) + this->SetDefinition("APPLE", "1"); + this->SetDefinition("CMAKE_HOST_APPLE", "1"); +#endif +#if defined(__sun__) + this->SetDefinition("CMAKE_HOST_SOLARIS", "1"); +#endif + + char temp[1024]; + sprintf(temp, "%d", cmVersion::GetMinorVersion()); + this->SetDefinition("CMAKE_MINOR_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetMajorVersion()); + this->SetDefinition("CMAKE_MAJOR_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetPatchVersion()); + this->SetDefinition("CMAKE_PATCH_VERSION", temp); + sprintf(temp, "%d", cmVersion::GetTweakVersion()); + this->SetDefinition("CMAKE_TWEAK_VERSION", temp); + this->SetDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion()); + + this->SetDefinition("CMAKE_FILES_DIRECTORY", + cmake::GetCMakeFilesDirectory()); + + // Setup the default include file regular expression (match everything). + this->Position->BuildSystemDirectory->Properties.SetProperty( + "INCLUDE_REGULAR_EXPRESSION", "^.*$"); +} + +void cmStateSnapshot::SetDirectoryDefinitions() +{ + this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory()); + this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->State->GetSourceDirectory()); + this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory()); + this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", + this->State->GetBinaryDirectory()); +} + +void cmStateSnapshot::InitializeFromParent() +{ + cmStateDetail::PositionType parent = this->Position->DirectoryParent; + assert(this->Position->Vars.IsValid()); + assert(parent->Vars.IsValid()); + + *this->Position->Vars = + cmDefinitions::MakeClosure(parent->Vars, parent->Root); + + InitializeContentFromParent( + parent->BuildSystemDirectory->IncludeDirectories, + this->Position->BuildSystemDirectory->IncludeDirectories, + parent->BuildSystemDirectory->IncludeDirectoryBacktraces, + this->Position->BuildSystemDirectory->IncludeDirectoryBacktraces, + this->Position->IncludeDirectoryPosition); + + InitializeContentFromParent( + parent->BuildSystemDirectory->CompileDefinitions, + this->Position->BuildSystemDirectory->CompileDefinitions, + parent->BuildSystemDirectory->CompileDefinitionsBacktraces, + this->Position->BuildSystemDirectory->CompileDefinitionsBacktraces, + this->Position->CompileDefinitionsPosition); + + InitializeContentFromParent( + parent->BuildSystemDirectory->CompileOptions, + this->Position->BuildSystemDirectory->CompileOptions, + parent->BuildSystemDirectory->CompileOptionsBacktraces, + this->Position->BuildSystemDirectory->CompileOptionsBacktraces, + this->Position->CompileOptionsPosition); +} + +cmState* cmStateSnapshot::GetState() const +{ + return this->State; +} + +cmStateDirectory cmStateSnapshot::GetDirectory() const +{ + return cmStateDirectory(this->Position->BuildSystemDirectory, *this); +} + +void cmStateSnapshot::SetProjectName(const std::string& name) +{ + this->Position->BuildSystemDirectory->ProjectName = name; +} + +std::string cmStateSnapshot::GetProjectName() const +{ + return this->Position->BuildSystemDirectory->ProjectName; +} + +void cmStateSnapshot::InitializeFromParent_ForSubdirsCommand() +{ + std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR"); + std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR"); + this->InitializeFromParent(); + this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory()); + this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory()); + + this->SetDefinition("CMAKE_CURRENT_SOURCE_DIR", currentSrcDir); + this->SetDefinition("CMAKE_CURRENT_BINARY_DIR", currentBinDir); +} + +bool cmStateSnapshot::StrictWeakOrder::operator()( + const cmStateSnapshot& lhs, const cmStateSnapshot& rhs) const +{ + return lhs.Position.StrictWeakOrdered(rhs.Position); +} + +bool operator==(const cmStateSnapshot& lhs, const cmStateSnapshot& rhs) +{ + return lhs.Position == rhs.Position; +} + +bool operator!=(const cmStateSnapshot& lhs, const cmStateSnapshot& rhs) +{ + return lhs.Position != rhs.Position; +} diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h new file mode 100644 index 0000000..63b581d --- /dev/null +++ b/Source/cmStateSnapshot.h @@ -0,0 +1,88 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#ifndef cmStateSnapshot_h +#define cmStateSnapshot_h + +#include <cmConfigure.h> // IWYU pragma: keep + +#include <map> +#include <string> +#include <vector> + +#include "cmPolicies.h" +#include "cmStateTypes.h" + +class cmState; +class cmStateDirectory; + +class cmStateSnapshot +{ +public: + cmStateSnapshot(cmState* state = CM_NULLPTR); + cmStateSnapshot(cmState* state, cmStateDetail::PositionType position); + + const char* GetDefinition(std::string const& name) const; + bool IsInitialized(std::string const& name) const; + void SetDefinition(std::string const& name, std::string const& value); + void RemoveDefinition(std::string const& name); + std::vector<std::string> UnusedKeys() const; + std::vector<std::string> ClosureKeys() const; + bool RaiseScope(std::string const& var, const char* varDef); + + void SetListFile(std::string const& listfile); + + std::string GetExecutionListFile() const; + + std::vector<cmStateSnapshot> GetChildren(); + + bool IsValid() const; + cmStateSnapshot GetBuildsystemDirectoryParent() const; + cmStateSnapshot GetCallStackParent() const; + cmStateSnapshot GetCallStackBottom() const; + cmStateEnums::SnapshotType GetType() const; + + void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); + cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const; + bool HasDefinedPolicyCMP0011(); + void PushPolicy(cmPolicies::PolicyMap entry, bool weak); + bool PopPolicy(); + bool CanPopPolicyScope(); + + cmState* GetState() const; + + cmStateDirectory GetDirectory() const; + + void SetProjectName(std::string const& name); + std::string GetProjectName() const; + + void InitializeFromParent_ForSubdirsCommand(); + + struct StrictWeakOrder + { + bool operator()(const cmStateSnapshot& lhs, + const cmStateSnapshot& rhs) const; + }; + + void SetDirectoryDefinitions(); + void SetDefaultDefinitions(); + +private: + friend bool operator==(const cmStateSnapshot& lhs, + const cmStateSnapshot& rhs); + friend bool operator!=(const cmStateSnapshot& lhs, + const cmStateSnapshot& rhs); + friend class cmState; + friend class cmStateDirectory; + friend struct StrictWeakOrder; + + void InitializeFromParent(); + + cmState* State; + cmStateDetail::PositionType Position; +}; + +bool operator==(const cmStateSnapshot& lhs, const cmStateSnapshot& rhs); +bool operator!=(const cmStateSnapshot& lhs, const cmStateSnapshot& rhs); + +#endif diff --git a/Source/cmStateTypes.h b/Source/cmStateTypes.h new file mode 100644 index 0000000..75f9e60 --- /dev/null +++ b/Source/cmStateTypes.h @@ -0,0 +1,55 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#ifndef cmStateTypes_h +#define cmStateTypes_h + +#include "cmLinkedTree.h" + +namespace cmStateDetail { +struct BuildsystemDirectoryStateType; +struct SnapshotDataType; +struct PolicyStackEntry; +typedef cmLinkedTree<cmStateDetail::SnapshotDataType>::iterator PositionType; +} + +namespace cmStateEnums { + +enum SnapshotType +{ + BaseType, + BuildsystemDirectoryType, + FunctionCallType, + MacroCallType, + IncludeFileType, + InlineListFileType, + PolicyScopeType, + VariableScopeType +}; + +enum TargetType +{ + EXECUTABLE, + STATIC_LIBRARY, + SHARED_LIBRARY, + MODULE_LIBRARY, + OBJECT_LIBRARY, + UTILITY, + GLOBAL_TARGET, + INTERFACE_LIBRARY, + UNKNOWN_LIBRARY +}; + +enum CacheEntryType +{ + BOOL = 0, + PATH, + FILEPATH, + STRING, + INTERNAL, + STATIC, + UNINITIALIZED +}; +} + +#endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3a22309..3718d95 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -13,6 +13,7 @@ #include "cmProperty.h" #include "cmSourceFile.h" #include "cmSourceFileLocation.h" +#include "cmState.h" #include "cmSystemTools.h" #include "cmTargetPropertyComputer.h" #include "cmake.h" @@ -180,7 +181,7 @@ public: std::vector<cmListFileBacktrace> LinkImplementationPropertyBacktraces; }; -cmTarget::cmTarget(std::string const& name, cmState::TargetType type, +cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, Visibility vis, cmMakefile* mf) { assert(mf); @@ -196,8 +197,8 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, this->BuildInterfaceIncludesAppended = false; // only add dependency information for library targets - if (this->TargetTypeValue >= cmState::STATIC_LIBRARY && - this->TargetTypeValue <= cmState::MODULE_LIBRARY) { + if (this->TargetTypeValue >= cmStateEnums::STATIC_LIBRARY && + this->TargetTypeValue <= cmStateEnums::MODULE_LIBRARY) { this->RecordDependencies = true; } else { this->RecordDependencies = false; @@ -214,8 +215,8 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, "Android") == 0; // Setup default property values. - if (this->GetType() != cmState::INTERFACE_LIBRARY && - this->GetType() != cmState::UTILITY) { + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && + this->GetType() != cmStateEnums::UTILITY) { this->SetPropertyDefault("ANDROID_API", CM_NULLPTR); this->SetPropertyDefault("ANDROID_API_MIN", CM_NULLPTR); this->SetPropertyDefault("ANDROID_ARCH", CM_NULLPTR); @@ -282,7 +283,7 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, mf->GetConfigurations(configNames); // Setup per-configuration property default values. - if (this->GetType() != cmState::UTILITY) { + if (this->GetType() != cmStateEnums::UTILITY) { const char* configProps[] = { /* clang-format needs this comment to break after the opening brace */ "ARCHIVE_OUTPUT_DIRECTORY_", @@ -297,7 +298,7 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, ci != configNames.end(); ++ci) { std::string configUpper = cmSystemTools::UpperCase(*ci); for (const char** p = configProps; *p; ++p) { - if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY && + if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY && strcmp(*p, "MAP_IMPORTED_CONFIG_") != 0) { continue; } @@ -311,8 +312,8 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, // compatibility with previous CMake versions in which executables // did not support this variable. Projects may still specify the // property directly. - if (this->TargetTypeValue != cmState::EXECUTABLE && - this->TargetTypeValue != cmState::INTERFACE_LIBRARY) { + if (this->TargetTypeValue != cmStateEnums::EXECUTABLE && + this->TargetTypeValue != cmStateEnums::INTERFACE_LIBRARY) { std::string property = cmSystemTools::UpperCase(*ci); property += "_POSTFIX"; this->SetPropertyDefault(property, CM_NULLPTR); @@ -357,44 +358,45 @@ cmTarget::cmTarget(std::string const& name, cmState::TargetType type, parentOptionsBts.end()); } - if (this->GetType() != cmState::INTERFACE_LIBRARY && - this->GetType() != cmState::UTILITY) { + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && + this->GetType() != cmStateEnums::UTILITY) { this->SetPropertyDefault("C_VISIBILITY_PRESET", CM_NULLPTR); this->SetPropertyDefault("CXX_VISIBILITY_PRESET", CM_NULLPTR); this->SetPropertyDefault("VISIBILITY_INLINES_HIDDEN", CM_NULLPTR); } - if (this->TargetTypeValue == cmState::EXECUTABLE) { + if (this->TargetTypeValue == cmStateEnums::EXECUTABLE) { this->SetPropertyDefault("ANDROID_GUI", CM_NULLPTR); this->SetPropertyDefault("CROSSCOMPILING_EMULATOR", CM_NULLPTR); this->SetPropertyDefault("ENABLE_EXPORTS", CM_NULLPTR); } - if (this->TargetTypeValue == cmState::SHARED_LIBRARY || - this->TargetTypeValue == cmState::MODULE_LIBRARY) { + if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY || + this->TargetTypeValue == cmStateEnums::MODULE_LIBRARY) { this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); } - if (this->TargetTypeValue == cmState::SHARED_LIBRARY || - this->TargetTypeValue == cmState::EXECUTABLE) { + if (this->TargetTypeValue == cmStateEnums::SHARED_LIBRARY || + this->TargetTypeValue == cmStateEnums::EXECUTABLE) { this->SetPropertyDefault("WINDOWS_EXPORT_ALL_SYMBOLS", CM_NULLPTR); } - if (this->GetType() != cmState::INTERFACE_LIBRARY && - this->GetType() != cmState::UTILITY) { + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && + this->GetType() != cmStateEnums::UTILITY) { this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", CM_NULLPTR); } // Record current policies for later use. this->Makefile->RecordPolicies(this->PolicyMap); - if (this->TargetTypeValue == cmState::INTERFACE_LIBRARY) { + if (this->TargetTypeValue == cmStateEnums::INTERFACE_LIBRARY) { // This policy is checked in a few conditions. The properties relevant - // to the policy are always ignored for cmState::INTERFACE_LIBRARY targets, + // to the policy are always ignored for cmStateEnums::INTERFACE_LIBRARY + // targets, // so ensure that the conditions don't lead to nonsense. this->PolicyMap.Set(cmPolicies::CMP0022, cmPolicies::NEW); } - if (this->GetType() != cmState::INTERFACE_LIBRARY && - this->GetType() != cmState::UTILITY) { + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && + this->GetType() != cmStateEnums::UTILITY) { this->SetPropertyDefault("JOB_POOL_COMPILE", CM_NULLPTR); this->SetPropertyDefault("JOB_POOL_LINK", CM_NULLPTR); } @@ -432,26 +434,27 @@ cmListFileBacktrace const& cmTarget::GetBacktrace() const bool cmTarget::IsExecutableWithExports() const { - return (this->GetType() == cmState::EXECUTABLE && + return (this->GetType() == cmStateEnums::EXECUTABLE && this->GetPropertyAsBool("ENABLE_EXPORTS")); } bool cmTarget::HasImportLibrary() const { - return (this->DLLPlatform && (this->GetType() == cmState::SHARED_LIBRARY || - this->IsExecutableWithExports())); + return (this->DLLPlatform && + (this->GetType() == cmStateEnums::SHARED_LIBRARY || + this->IsExecutableWithExports())); } bool cmTarget::IsFrameworkOnApple() const { - return (this->GetType() == cmState::SHARED_LIBRARY && + return (this->GetType() == cmStateEnums::SHARED_LIBRARY && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("FRAMEWORK")); } bool cmTarget::IsAppBundleOnApple() const { - return (this->GetType() == cmState::EXECUTABLE && + return (this->GetType() == cmStateEnums::EXECUTABLE && this->Makefile->IsOn("APPLE") && this->GetPropertyAsBool("MACOSX_BUNDLE")); } @@ -633,7 +636,7 @@ void cmTarget::ClearDependencyInformation(cmMakefile& mf, depname += "_LIB_DEPENDS"; if (this->RecordDependencies) { mf.AddCacheDefinition(depname, "", "Dependencies for target", - cmState::STATIC); + cmStateEnums::STATIC); } else { if (mf.GetDefinition(depname)) { std::string message = "Target "; @@ -730,7 +733,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib, } if (cmGeneratorExpression::Find(lib) != std::string::npos || - (tgt && tgt->GetType() == cmState::INTERFACE_LIBRARY) || + (tgt && tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) || (this->Name == lib)) { return; } @@ -771,7 +774,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, const std::string& lib, dependencies += lib; dependencies += ";"; mf.AddCacheDefinition(targetEntry, dependencies.c_str(), - "Dependencies for the target", cmState::STATIC); + "Dependencies for the target", cmStateEnums::STATIC); } } @@ -852,13 +855,15 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; - } else if (prop == "EXPORT_NAME" && this->IsImported()) { + } + if (prop == "EXPORT_NAME" && this->IsImported()) { std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; - } else if (prop == "SOURCES" && this->IsImported()) { + } + if (prop == "SOURCES" && this->IsImported()) { std::ostringstream e; e << "SOURCES property can't be set on imported targets (\"" << this->Name << "\")\n"; @@ -932,13 +937,15 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, e << "NAME property is read-only\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; - } else if (prop == "EXPORT_NAME" && this->IsImported()) { + } + if (prop == "EXPORT_NAME" && this->IsImported()) { std::ostringstream e; e << "EXPORT_NAME property can't be set on imported targets (\"" << this->Name << "\")\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return; - } else if (prop == "SOURCES" && this->IsImported()) { + } + if (prop == "SOURCES" && this->IsImported()) { std::ostringstream e; e << "SOURCES property can't be set on imported targets (\"" << this->Name << "\")\n"; @@ -986,10 +993,10 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, void cmTarget::AppendBuildInterfaceIncludes() { - if (this->GetType() != cmState::SHARED_LIBRARY && - this->GetType() != cmState::STATIC_LIBRARY && - this->GetType() != cmState::MODULE_LIBRARY && - this->GetType() != cmState::INTERFACE_LIBRARY && + if (this->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GetType() != cmStateEnums::STATIC_LIBRARY && + this->GetType() != cmStateEnums::MODULE_LIBRARY && + this->GetType() != cmStateEnums::INTERFACE_LIBRARY && !this->IsExecutableWithExports()) { return; } @@ -1255,15 +1262,15 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const const char* cmTarget::GetSuffixVariableInternal(bool implib) const { switch (this->GetType()) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_SUFFIX"; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" : "CMAKE_SHARED_LIBRARY_SUFFIX"); - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" : "CMAKE_SHARED_MODULE_SUFFIX"); - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" // Android GUI application packages store the native @@ -1280,15 +1287,15 @@ const char* cmTarget::GetSuffixVariableInternal(bool implib) const const char* cmTarget::GetPrefixVariableInternal(bool implib) const { switch (this->GetType()) { - case cmState::STATIC_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: return "CMAKE_STATIC_LIBRARY_PREFIX"; - case cmState::SHARED_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" : "CMAKE_SHARED_LIBRARY_PREFIX"); - case cmState::MODULE_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" : "CMAKE_SHARED_MODULE_PREFIX"); - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: return (implib ? "CMAKE_IMPORT_LIBRARY_PREFIX" // Android GUI application packages store the native @@ -1322,7 +1329,7 @@ std::string cmTarget::ImportedGetFullPath(const std::string& config, const char* imp = CM_NULLPTR; std::string suffix; - if (this->GetType() != cmState::INTERFACE_LIBRARY && + if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY && this->GetMappedConfig(config_upper, &loc, &imp, suffix)) { if (!pimplib) { if (loc) { @@ -1340,7 +1347,7 @@ std::string cmTarget::ImportedGetFullPath(const std::string& config, } else { if (imp) { result = imp; - } else if (this->GetType() == cmState::SHARED_LIBRARY || + } else if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->IsExecutableWithExports()) { std::string impProp = "IMPORTED_IMPLIB"; impProp += suffix; @@ -1378,9 +1385,10 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, std::string& suffix) const { - if (this->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { // This method attempts to find a config-specific LOCATION for the - // IMPORTED library. In the case of cmState::INTERFACE_LIBRARY, there is no + // IMPORTED library. In the case of cmStateEnums::INTERFACE_LIBRARY, there + // is no // LOCATION at all, so leaving *loc and *imp unchanged is the appropriate // and valid response. return true; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index bd00b3d..929e204 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -10,7 +10,7 @@ #include "cmListFileCache.h" #include "cmPolicies.h" #include "cmPropertyMap.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmTargetLinkLibraryType.h" #include <iosfwd> @@ -62,8 +62,8 @@ public: VisibilityImportedGlobally }; - cmTarget(std::string const& name, cmState::TargetType type, Visibility vis, - cmMakefile* mf); + cmTarget(std::string const& name, cmStateEnums::TargetType type, + Visibility vis, cmMakefile* mf); enum CustomCommandType { @@ -75,7 +75,7 @@ public: /** * Return the type of target. */ - cmState::TargetType GetType() const { return this->TargetTypeValue; } + cmStateEnums::TargetType GetType() const { return this->TargetTypeValue; } cmGlobalGenerator* GetGlobalGenerator() const; @@ -302,7 +302,7 @@ private: LinkLibraryVectorType OriginalLinkLibraries; cmMakefile* Makefile; cmTargetInternalPointer Internal; - cmState::TargetType TargetTypeValue; + cmStateEnums::TargetType TargetTypeValue; bool HaveInstallRule; bool RecordDependencies; bool DLLPlatform; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index d1de7ef..804dc5a 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -71,7 +71,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass( return true; } - if (this->Target->GetType() == cmState::OBJECT_LIBRARY) { + if (this->Target->GetType() == cmStateEnums::OBJECT_LIBRARY) { std::ostringstream e; e << "Object library target \"" << args[0] << "\" " << "may not link to anything."; @@ -80,7 +80,7 @@ bool cmTargetLinkLibrariesCommand::InitialPass( return true; } - if (this->Target->GetType() == cmState::UTILITY) { + if (this->Target->GetType() == cmStateEnums::UTILITY) { std::ostringstream e; const char* modal = CM_NULLPTR; cmake::MessageType messageType = cmake::AUTHOR_WARNING; @@ -278,7 +278,7 @@ void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left, bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, cmTargetLinkLibraryType llt) { - if (this->Target->GetType() == cmState::INTERFACE_LIBRARY && + if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY && this->CurrentProcessingState != ProcessingKeywordLinkInterface) { this->Makefile->IssueMessage( cmake::FATAL_ERROR, @@ -351,9 +351,9 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, cmTarget* tgt = this->Makefile->GetGlobalGenerator()->FindTarget(lib); - if (tgt && (tgt->GetType() != cmState::STATIC_LIBRARY) && - (tgt->GetType() != cmState::SHARED_LIBRARY) && - (tgt->GetType() != cmState::INTERFACE_LIBRARY) && + if (tgt && (tgt->GetType() != cmStateEnums::STATIC_LIBRARY) && + (tgt->GetType() != cmStateEnums::SHARED_LIBRARY) && + (tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) && !tgt->IsExecutableWithExports()) { std::ostringstream e; e << "Target \"" << lib << "\" of type " @@ -375,7 +375,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, } if (this->CurrentProcessingState != ProcessingKeywordPublicInterface && this->CurrentProcessingState != ProcessingPlainPublicInterface) { - if (this->Target->GetType() == cmState::STATIC_LIBRARY) { + if (this->Target->GetType() == cmStateEnums::STATIC_LIBRARY) { std::string configLib = this->Target->GetDebugGeneratorExpressions(lib, llt); if (cmGeneratorExpression::IsValidTargetName(lib) || @@ -403,7 +403,7 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib, return true; } - if (this->Target->GetType() == cmState::INTERFACE_LIBRARY) { + if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return true; } diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index a00360b..e2e02ad 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -28,12 +28,12 @@ bool cmTargetPropCommandBase::HandleArguments( this->HandleMissingTarget(args[0]); return false; } - if ((this->Target->GetType() != cmState::SHARED_LIBRARY) && - (this->Target->GetType() != cmState::STATIC_LIBRARY) && - (this->Target->GetType() != cmState::OBJECT_LIBRARY) && - (this->Target->GetType() != cmState::MODULE_LIBRARY) && - (this->Target->GetType() != cmState::INTERFACE_LIBRARY) && - (this->Target->GetType() != cmState::EXECUTABLE)) { + if ((this->Target->GetType() != cmStateEnums::SHARED_LIBRARY) && + (this->Target->GetType() != cmStateEnums::STATIC_LIBRARY) && + (this->Target->GetType() != cmStateEnums::OBJECT_LIBRARY) && + (this->Target->GetType() != cmStateEnums::MODULE_LIBRARY) && + (this->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) && + (this->Target->GetType() != cmStateEnums::EXECUTABLE)) { this->SetError("called with non-compilable target type"); return false; } @@ -86,7 +86,7 @@ bool cmTargetPropCommandBase::ProcessContentArgs( return false; } - if (this->Target->GetType() == cmState::INTERFACE_LIBRARY && + if (this->Target->GetType() == cmStateEnums::INTERFACE_LIBRARY && scope != "INTERFACE") { this->SetError("may only be set INTERFACE properties on INTERFACE " "targets"); diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx index 21408d1..36d1940 100644 --- a/Source/cmTargetPropertyComputer.cxx +++ b/Source/cmTargetPropertyComputer.cxx @@ -83,10 +83,10 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty( } bool cmTargetPropertyComputer::PassesWhitelist( - cmState::TargetType tgtType, std::string const& prop, cmMessenger* messenger, - cmListFileBacktrace const& context) + cmStateEnums::TargetType tgtType, std::string const& prop, + cmMessenger* messenger, cmListFileBacktrace const& context) { - if (tgtType == cmState::INTERFACE_LIBRARY && + if (tgtType == cmStateEnums::INTERFACE_LIBRARY && !WhiteListedInterfaceProperty(prop)) { std::ostringstream e; e << "INTERFACE_LIBRARY targets may only have whitelisted properties. " diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h index ed9a4e2..7989589 100644 --- a/Source/cmTargetPropertyComputer.h +++ b/Source/cmTargetPropertyComputer.h @@ -5,6 +5,7 @@ #include <cmConfigure.h> // IWYU pragma: keep +#include "cmAlgorithms.h" #include "cmListFileCache.h" #include "cmSystemTools.h" @@ -36,7 +37,7 @@ public: static bool WhiteListedInterfaceProperty(const std::string& prop); - static bool PassesWhitelist(cmState::TargetType tgtType, + static bool PassesWhitelist(cmStateEnums::TargetType tgtType, std::string const& prop, cmMessenger* messenger, cmListFileBacktrace const& context); @@ -59,11 +60,11 @@ private: { // Watch for special "computed" properties that are dependent on // other properties or variables. Always recompute them. - if (tgt->GetType() == cmState::EXECUTABLE || - tgt->GetType() == cmState::STATIC_LIBRARY || - tgt->GetType() == cmState::SHARED_LIBRARY || - tgt->GetType() == cmState::MODULE_LIBRARY || - tgt->GetType() == cmState::UNKNOWN_LIBRARY) { + if (tgt->GetType() == cmStateEnums::EXECUTABLE || + tgt->GetType() == cmStateEnums::STATIC_LIBRARY || + tgt->GetType() == cmStateEnums::SHARED_LIBRARY || + tgt->GetType() == cmStateEnums::MODULE_LIBRARY || + tgt->GetType() == cmStateEnums::UNKNOWN_LIBRARY) { static const std::string propLOCATION = "LOCATION"; if (prop == propLOCATION) { if (!tgt->IsImported() && @@ -75,7 +76,7 @@ private: } // Support "LOCATION_<CONFIG>". - else if (cmHasLiteralPrefix(prop, "LOCATION_")) { + if (cmHasLiteralPrefix(prop, "LOCATION_")) { if (!tgt->IsImported() && !HandleLocationPropertyPolicy(tgt->GetName(), messenger, context)) { @@ -86,8 +87,8 @@ private: } // Support "<CONFIG>_LOCATION". - else if (cmHasLiteralSuffix(prop, "_LOCATION") && - !cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) { + if (cmHasLiteralSuffix(prop, "_LOCATION") && + !cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) { std::string configName(prop.c_str(), prop.size() - 9); if (configName != "IMPORTED") { if (!tgt->IsImported() && diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 4d0cbaa..1c36dc6 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -5,6 +5,7 @@ #include "cmMakefile.h" #include "cmProperty.h" #include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" cmTest::cmTest(cmMakefile* mf) diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 3ea59cb..843f7b1 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -8,7 +8,7 @@ #include "cmOutputConverter.h" #include "cmProperty.h" #include "cmPropertyMap.h" -#include "cmState.h" +#include "cmStateTypes.h" #include "cmSystemTools.h" #include "cmTest.h" #include "cm_auto_ptr.hxx" @@ -77,7 +77,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // be translated. std::string exe = command[0]; cmGeneratorTarget* target = this->LG->FindGeneratorTargetToUse(exe); - if (target && target->GetType() == cmState::EXECUTABLE) { + if (target && target->GetType() == cmStateEnums::EXECUTABLE) { // Use the target file on disk. exe = target->GetFullPath(config); diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 5c9e41a..b248489 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -189,7 +189,8 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, strcpy(retChar, "FAILED_TO_RUN"); } this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar, - "Result of TRY_RUN", cmState::INTERNAL); + "Result of TRY_RUN", + cmStateEnums::INTERNAL); } /* This is only used when cross compiling. Instead of running the @@ -231,7 +232,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += detailsString; this->Makefile->AddCacheDefinition(this->RunResultVariable, "PLEASE_FILL_OUT-FAILED_TO_RUN", - comment.c_str(), cmState::STRING); + comment.c_str(), cmStateEnums::STRING); cmState* state = this->Makefile->GetState(); const char* existingValue = @@ -254,9 +255,9 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "would have printed on stdout and stderr on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(internalRunOutputName, - "PLEASE_FILL_OUT-NOTFOUND", - comment.c_str(), cmState::STRING); + this->Makefile->AddCacheDefinition( + internalRunOutputName, "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(), + cmStateEnums::STRING); cmState* state = this->Makefile->GetState(); const char* existing = state->GetCacheEntryValue(internalRunOutputName); if (existing) { diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 08ea21e..c816114 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmUtilitySourceCommand.h" +#include "cmState.h" + // cmUtilitySourceCommand bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, cmExecutionStatus&) @@ -98,13 +100,13 @@ bool cmUtilitySourceCommand::InitialPass(std::vector<std::string> const& args, // Enter the value into the cache. this->Makefile->AddCacheDefinition(cacheEntry, utilityExecutable.c_str(), "Path to an internal program.", - cmState::FILEPATH); + cmStateEnums::FILEPATH); // add a value into the cache that maps from the // full path to the name of the project cmSystemTools::ConvertToUnixSlashes(utilityExecutable); this->Makefile->AddCacheDefinition(utilityExecutable, utilityName.c_str(), "Executable to project name.", - cmState::INTERNAL); + cmStateEnums::INTERNAL); return true; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8524ecc..9c857f2 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -255,7 +255,7 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line, void cmVisualStudio10TargetGenerator::Generate() { // do not generate external ms projects - if (this->GeneratorTarget->GetType() == cmState::INTERFACE_LIBRARY || + if (this->GeneratorTarget->GetType() == cmStateEnums::INTERFACE_LIBRARY || this->GeneratorTarget->GetProperty("EXTERNAL_MSPROJECT")) { return; } @@ -264,7 +264,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->Name.c_str()); this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME_EXT", ".vcxproj"); - if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { + if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { if (!this->ComputeClOptions()) { return; } @@ -344,7 +344,7 @@ void cmVisualStudio10TargetGenerator::Generate() (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n"; if (this->MSTools && - this->GeneratorTarget->GetType() <= cmState::GLOBAL_TARGET) { + this->GeneratorTarget->GetType() <= cmStateEnums::GLOBAL_TARGET) { this->WriteApplicationTypeSettings(); this->VerifyNecessaryFiles(); } @@ -655,15 +655,15 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += cmVS10EscapeXML(vsConfigurationType); } else { switch (this->GeneratorTarget->GetType()) { - case cmState::SHARED_LIBRARY: - case cmState::MODULE_LIBRARY: + case cmStateEnums::SHARED_LIBRARY: + case cmStateEnums::MODULE_LIBRARY: configType += "DynamicLibrary"; break; - case cmState::OBJECT_LIBRARY: - case cmState::STATIC_LIBRARY: + case cmStateEnums::OBJECT_LIBRARY: + case cmStateEnums::STATIC_LIBRARY: configType += "StaticLibrary"; break; - case cmState::EXECUTABLE: + case cmStateEnums::EXECUTABLE: if (this->NsightTegra && !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) { // Android executables are .so too. @@ -672,8 +672,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "Application"; } break; - case cmState::UTILITY: - case cmState::GLOBAL_TARGET: + case cmStateEnums::UTILITY: + case cmStateEnums::GLOBAL_TARGET: if (this->NsightTegra) { // Tegra-Android platform does not understand "Utility". configType += "StaticLibrary"; @@ -681,8 +681,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() configType += "Utility"; } break; - case cmState::UNKNOWN_LIBRARY: - case cmState::INTERFACE_LIBRARY: + case cmStateEnums::UNKNOWN_LIBRARY: + case cmStateEnums::INTERFACE_LIBRARY: break; } } @@ -710,7 +710,7 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( std::string mfcFlagValue = mfcFlag ? mfcFlag : "0"; std::string useOfMfcValue = "false"; - if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { + if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { if (mfcFlagValue == "1") { useOfMfcValue = "Static"; } else if (mfcFlagValue == "2") { @@ -721,14 +721,15 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues( mfcLine += useOfMfcValue + "</UseOfMfc>\n"; this->WriteString(mfcLine.c_str(), 2); - if ((this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY && + if ((this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY && this->ClOptions[config]->UsingUnicode()) || this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") || this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore() || this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) { this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2); - } else if (this->GeneratorTarget->GetType() <= cmState::MODULE_LIBRARY && + } else if (this->GeneratorTarget->GetType() <= + cmStateEnums::MODULE_LIBRARY && this->ClOptions[config]->UsingSBCS()) { this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2); } else { @@ -1351,7 +1352,7 @@ void cmVisualStudio10TargetGenerator::WriteSources( void cmVisualStudio10TargetGenerator::WriteAllSources() { - if (this->GeneratorTarget->GetType() > cmState::UTILITY) { + if (this->GeneratorTarget->GetType() > cmStateEnums::UTILITY) { return; } this->WriteString("<ItemGroup>\n", 1); @@ -1573,8 +1574,8 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() { - cmState::TargetType ttype = this->GeneratorTarget->GetType(); - if (ttype > cmState::GLOBAL_TARGET) { + cmStateEnums::TargetType ttype = this->GeneratorTarget->GetType(); + if (ttype > cmStateEnums::GLOBAL_TARGET) { return; } @@ -1585,7 +1586,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() for (std::vector<std::string>::const_iterator config = this->Configurations.begin(); config != this->Configurations.end(); ++config) { - if (ttype >= cmState::UTILITY) { + if (ttype >= cmStateEnums::UTILITY) { this->WritePlatformConfigTag("IntDir", config->c_str(), 3); *this->BuildFileStream << "$(Platform)\\$(Configuration)\\$(ProjectName)\\" @@ -1598,7 +1599,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() intermediateDir += "/"; std::string outDir; std::string targetNameFull; - if (ttype == cmState::OBJECT_LIBRARY) { + if (ttype == cmStateEnums::OBJECT_LIBRARY) { outDir = intermediateDir; targetNameFull = this->GeneratorTarget->GetName(); targetNameFull += ".lib"; @@ -1645,8 +1646,8 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental( } // static libraries and things greater than modules do not need // to set this option - if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || - this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GeneratorTarget->GetType() > cmStateEnums::MODULE_LIBRARY) { return; } Options& linkOptions = *(this->LinkOptions[configName]); @@ -1767,8 +1768,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) { clOptions.AddFlag("CompileAsWinRT", "true"); // For WinRT components, add the _WINRT_DLL define to produce a lib - if (this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || - this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { clOptions.AddDefine("_WINRT_DLL"); } } else if (this->GlobalGenerator->TargetsWindowsStore() || @@ -1958,8 +1959,8 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions( void cmVisualStudio10TargetGenerator::WriteLibOptions( std::string const& config) { - if (this->GeneratorTarget->GetType() != cmState::STATIC_LIBRARY && - this->GeneratorTarget->GetType() != cmState::OBJECT_LIBRARY) { + if (this->GeneratorTarget->GetType() != cmStateEnums::STATIC_LIBRARY && + this->GeneratorTarget->GetType() != cmStateEnums::OBJECT_LIBRARY) { return; } std::string libflags; @@ -1992,9 +1993,9 @@ void cmVisualStudio10TargetGenerator::WriteLibOptions( void cmVisualStudio10TargetGenerator::WriteManifestOptions( std::string const& config) { - if (this->GeneratorTarget->GetType() != cmState::EXECUTABLE && - this->GeneratorTarget->GetType() != cmState::SHARED_LIBRARY && - this->GeneratorTarget->GetType() != cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() != cmStateEnums::EXECUTABLE && + this->GeneratorTarget->GetType() != cmStateEnums::SHARED_LIBRARY && + this->GeneratorTarget->GetType() != cmStateEnums::MODULE_LIBRARY) { return; } @@ -2145,9 +2146,9 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( bool cmVisualStudio10TargetGenerator::ComputeLinkOptions() { - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE || - this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || - this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE || + this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || + this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { for (std::vector<std::string>::const_iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { @@ -2178,10 +2179,10 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string CONFIG = cmSystemTools::UpperCase(config); const char* linkType = "SHARED"; - if (this->GeneratorTarget->GetType() == cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::MODULE_LIBRARY) { linkType = "MODULE"; } - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { linkType = "EXE"; } std::string flags; @@ -2258,7 +2259,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); @@ -2274,7 +2275,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( if (this->GeneratorTarget->GetPropertyAsBool("WIN32_EXECUTABLE")) { if (this->GlobalGenerator->TargetsWindowsCE()) { linkOptions.AddFlag("SubSystem", "WindowsCE"); - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { if (this->ClOptions[config]->UsingUnicode()) { linkOptions.AddFlag("EntryPointSymbol", "wWinMainCRTStartup"); } else { @@ -2287,7 +2288,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( } else { if (this->GlobalGenerator->TargetsWindowsCE()) { linkOptions.AddFlag("SubSystem", "WindowsCE"); - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { if (this->ClOptions[config]->UsingUnicode()) { linkOptions.AddFlag("EntryPointSymbol", "mainWCRTStartup"); } else { @@ -2325,7 +2326,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( // A Windows Runtime component uses internal .NET metadata, // so does not have an import library. if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") && - this->GeneratorTarget->GetType() != cmState::EXECUTABLE) { + this->GeneratorTarget->GetType() != cmStateEnums::EXECUTABLE) { linkOptions.AddFlag("GenerateWindowsMetadata", "true"); } else if (this->GlobalGenerator->TargetsWindowsPhone() || this->GlobalGenerator->TargetsWindowsStore()) { @@ -2356,7 +2357,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( "%(IgnoreSpecificDefaultLibraries)"); } - if ((this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + if ((this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || this->GeneratorTarget->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (this->GeneratorTarget->GetPropertyAsBool( @@ -2398,8 +2399,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( void cmVisualStudio10TargetGenerator::WriteLinkOptions( std::string const& config) { - if (this->GeneratorTarget->GetType() == cmState::STATIC_LIBRARY || - this->GeneratorTarget->GetType() > cmState::MODULE_LIBRARY) { + if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY || + this->GeneratorTarget->GetType() > cmStateEnums::MODULE_LIBRARY) { return; } Options& linkOptions = *(this->LinkOptions[config]); @@ -2432,7 +2433,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries( this->ConvertToWindowsSlash(path); libVec.push_back(path); } else if (!l->Target || - l->Target->GetType() != cmState::INTERFACE_LIBRARY) { + l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) { libVec.push_back(l->Value); } } @@ -2496,7 +2497,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1); *this->BuildFileStream << "\n"; // output cl compile flags <ClCompile></ClCompile> - if (this->GeneratorTarget->GetType() <= cmState::OBJECT_LIBRARY) { + if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) { this->WriteClOptions(*i, includes); // output rc compile flags <ResourceCompile></ResourceCompile> this->WriteRCOptions(*i, includes); @@ -2513,7 +2514,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() // output manifest flags <Manifest></Manifest> this->WriteManifestOptions(*i); if (this->NsightTegra && - this->GeneratorTarget->GetType() == cmState::EXECUTABLE && + this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE && this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI")) { this->WriteAntBuildOptions(*i); } @@ -2525,7 +2526,7 @@ void cmVisualStudio10TargetGenerator::WriteEvents( std::string const& configName) { bool addedPrelink = false; - if ((this->GeneratorTarget->GetType() == cmState::SHARED_LIBRARY || + if ((this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY || this->GeneratorTarget->IsExecutableWithExports()) && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { if (this->GeneratorTarget->GetPropertyAsBool( @@ -2592,7 +2593,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() for (OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { cmGeneratorTarget const* dt = *i; - if (dt->GetType() == cmState::INTERFACE_LIBRARY) { + if (dt->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } // skip fortran targets as they can not be processed by MSBuild @@ -2728,7 +2729,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile() { if ((this->GlobalGenerator->TargetsWindowsStore() || this->GlobalGenerator->TargetsWindowsPhone()) && - (cmState::EXECUTABLE == this->GeneratorTarget->GetType())) { + (cmStateEnums::EXECUTABLE == this->GeneratorTarget->GetType())) { std::string pfxFile; std::vector<cmSourceFile const*> certificates; this->GeneratorTarget->GetCertificates(certificates, ""); @@ -2853,7 +2854,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() "</MinimumVisualStudioVersion>\n", 2); - if (this->GeneratorTarget->GetType() < cmState::UTILITY) { + if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { isAppContainer = true; } } else if (v == "8.1") { @@ -2865,7 +2866,7 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() "</MinimumVisualStudioVersion>\n", 2); - if (this->GeneratorTarget->GetType() < cmState::UTILITY) { + if (this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { isAppContainer = true; } } else if (v == "8.0") { @@ -2878,10 +2879,11 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings() 2); if (isWindowsStore && - this->GeneratorTarget->GetType() < cmState::UTILITY) { + this->GeneratorTarget->GetType() < cmStateEnums::UTILITY) { isAppContainer = true; } else if (isWindowsPhone && - this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + this->GeneratorTarget->GetType() == + cmStateEnums::EXECUTABLE) { this->WriteString("<XapOutputs>true</XapOutputs>\n", 2); this->WriteString("<XapFilename>", 2); (*this->BuildFileStream) @@ -2931,7 +2933,7 @@ void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles() { // For Windows and Windows Phone executables, we will assume that if a // manifest is not present that we need to add all the necessary files - if (this->GeneratorTarget->GetType() == cmState::EXECUTABLE) { + if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { std::vector<cmSourceFile const*> manifestSources; this->GeneratorTarget->GetAppManifest(manifestSources, ""); { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 5936d77..388984f 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -315,7 +315,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } } std::string var, value; - cmState::CacheEntryType type = cmState::UNINITIALIZED; + cmStateEnums::CacheEntryType type = cmStateEnums::UNINITIALIZED; if (cmState::ParseCacheEntry(entry, var, value, type)) { // The value is transformed if it is a filepath for example, so // we can't compare whether the value is already in the cache until @@ -410,8 +410,8 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) std::vector<std::string> cacheKeys = this->State->GetCacheEntryKeys(); for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); it != cacheKeys.end(); ++it) { - cmState::CacheEntryType t = this->State->GetCacheEntryType(*it); - if (t != cmState::STATIC) { + cmStateEnums::CacheEntryType t = this->State->GetCacheEntryType(*it); + if (t != cmStateEnums::STATIC) { if (regex.find(it->c_str())) { entriesToDelete.push_back(*it); } @@ -481,7 +481,7 @@ void cmake::ReadListFile(const std::vector<std::string>& args, std::string homeOutputDir = this->GetHomeOutputDirectory(); this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - cmState::Snapshot snapshot = this->GetCurrentSnapshot(); + cmStateSnapshot snapshot = this->GetCurrentSnapshot(); snapshot.GetDirectory().SetCurrentBinary( cmSystemTools::GetCurrentWorkingDirectory()); snapshot.GetDirectory().SetCurrentSource( @@ -517,7 +517,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) cmGlobalGenerator* gg = new cmGlobalGenerator(this); this->SetGlobalGenerator(gg); - cmState::Snapshot snapshot = this->GetCurrentSnapshot(); + cmStateSnapshot snapshot = this->GetCurrentSnapshot(); snapshot.GetDirectory().SetCurrentBinary( cmSystemTools::GetCurrentWorkingDirectory()); snapshot.GetDirectory().SetCurrentSource( @@ -859,14 +859,14 @@ int cmake::AddCMakePaths() // Save the value in the cache this->AddCacheEntry("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), - "Path to CMake executable.", cmState::INTERNAL); + "Path to CMake executable.", cmStateEnums::INTERNAL); #ifdef CMAKE_BUILD_WITH_CMAKE - this->AddCacheEntry("CMAKE_CTEST_COMMAND", - cmSystemTools::GetCTestCommand().c_str(), - "Path to ctest program executable.", cmState::INTERNAL); - this->AddCacheEntry("CMAKE_CPACK_COMMAND", - cmSystemTools::GetCPackCommand().c_str(), - "Path to cpack program executable.", cmState::INTERNAL); + this->AddCacheEntry( + "CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), + "Path to ctest program executable.", cmStateEnums::INTERNAL); + this->AddCacheEntry( + "CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), + "Path to cpack program executable.", cmStateEnums::INTERNAL); #endif if (!cmSystemTools::FileExists( (cmSystemTools::GetCMakeRoot() + "/Modules/CMake.cmake").c_str())) { @@ -879,7 +879,7 @@ int cmake::AddCMakePaths() return 0; } this->AddCacheEntry("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), - "Path to CMake installation.", cmState::INTERNAL); + "Path to CMake installation.", cmStateEnums::INTERNAL); return 1; } @@ -1147,7 +1147,7 @@ struct SaveCacheEntry std::string key; std::string value; std::string help; - cmState::CacheEntryType type; + cmStateEnums::CacheEntryType type; }; int cmake::HandleDeleteCacheVariables(const std::string& var) @@ -1291,7 +1291,7 @@ int cmake::ActualConfigure() "CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(), "Source directory with the top level CMakeLists.txt file for this " "project", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } // no generator specified on the command line @@ -1338,11 +1338,11 @@ int cmake::ActualConfigure() if (!this->State->GetInitializedCacheValue("CMAKE_GENERATOR")) { this->AddCacheEntry("CMAKE_GENERATOR", this->GlobalGenerator->GetName().c_str(), - "Name of generator.", cmState::INTERNAL); + "Name of generator.", cmStateEnums::INTERNAL); this->AddCacheEntry("CMAKE_EXTRA_GENERATOR", this->GlobalGenerator->GetExtraGeneratorName().c_str(), "Name of external makefile project generator.", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } if (const char* platformName = @@ -1362,7 +1362,7 @@ int cmake::ActualConfigure() } else { this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", this->GeneratorPlatform.c_str(), - "Name of generator platform.", cmState::INTERNAL); + "Name of generator platform.", cmStateEnums::INTERNAL); } if (const char* tsName = @@ -1382,7 +1382,7 @@ int cmake::ActualConfigure() } else { this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET", this->GeneratorToolset.c_str(), - "Name of generator toolset.", cmState::INTERNAL); + "Name of generator toolset.", cmStateEnums::INTERNAL); } // reset any system configuration information, except for when we are @@ -1411,13 +1411,14 @@ int cmake::ActualConfigure() if (!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) { this->AddCacheEntry( "LIBRARY_OUTPUT_PATH", "", - "Single output directory for building all libraries.", cmState::PATH); + "Single output directory for building all libraries.", + cmStateEnums::PATH); } if (!this->State->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) { this->AddCacheEntry( "EXECUTABLE_OUTPUT_PATH", "", "Single output directory for building all executables.", - cmState::PATH); + cmStateEnums::PATH); } } @@ -1640,7 +1641,7 @@ void cmake::AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type) { this->State->AddCacheEntry(key, value, helpString, - cmState::CacheEntryType(type)); + cmStateEnums::CacheEntryType(type)); this->UnwatchUnusedCli(key); } @@ -1694,7 +1695,8 @@ void cmake::AddDefaultGenerators() } bool cmake::ParseCacheEntry(const std::string& entry, std::string& var, - std::string& value, cmState::CacheEntryType& type) + std::string& value, + cmStateEnums::CacheEntryType& type) { return cmState::ParseCacheEntry(entry, var, value, type); } @@ -2464,7 +2466,7 @@ void cmake::SetSuppressDevWarnings(bool b) this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", value.c_str(), "Suppress Warnings that are meant for" " the author of the CMakeLists.txt files.", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } bool cmake::GetSuppressDeprecatedWarnings() const @@ -2488,7 +2490,7 @@ void cmake::SetSuppressDeprecatedWarnings(bool b) this->AddCacheEntry("CMAKE_WARN_DEPRECATED", value.c_str(), "Whether to issue warnings for deprecated " "functionality.", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } bool cmake::GetDevWarningsAsErrors() const @@ -2512,7 +2514,7 @@ void cmake::SetDevWarningsAsErrors(bool b) this->AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_ERRORS", value.c_str(), "Suppress errors that are meant for" " the author of the CMakeLists.txt files.", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } bool cmake::GetDeprecatedWarningsAsErrors() const @@ -2536,5 +2538,5 @@ void cmake::SetDeprecatedWarningsAsErrors(bool b) this->AddCacheEntry("CMAKE_ERROR_DEPRECATED", value.c_str(), "Whether to issue deprecation errors for macros" " and functions.", - cmState::INTERNAL); + cmStateEnums::INTERNAL); } diff --git a/Source/cmake.h b/Source/cmake.h index 865748b..cd00c61 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -7,7 +7,7 @@ #include "cmInstalledFile.h" #include "cmListFileCache.h" -#include "cmState.h" +#include "cmStateSnapshot.h" #include <map> #include <set> @@ -161,7 +161,7 @@ public: ///! Break up a line like VAR:type="value" into var, type and value static bool ParseCacheEntry(const std::string& entry, std::string& var, std::string& value, - cmState::CacheEntryType& type); + cmStateEnums::CacheEntryType& type); int LoadCache(); bool LoadCache(const std::string& path); @@ -407,14 +407,11 @@ public: void WatchUnusedCli(const std::string& var); cmState* GetState() const { return this->State; } - void SetCurrentSnapshot(cmState::Snapshot snapshot) + void SetCurrentSnapshot(cmStateSnapshot snapshot) { this->CurrentSnapshot = snapshot; } - cmState::Snapshot GetCurrentSnapshot() const - { - return this->CurrentSnapshot; - } + cmStateSnapshot GetCurrentSnapshot() const { return this->CurrentSnapshot; } protected: void RunCheckForUnusedVariables(); @@ -490,7 +487,7 @@ private: InstalledFilesMap InstalledFiles; cmState* State; - cmState::Snapshot CurrentSnapshot; + cmStateSnapshot CurrentSnapshot; cmMessenger* Messenger; std::vector<std::string> TraceOnlyThisSources; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 0d1f1ce..d1159c3 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -292,9 +292,9 @@ int do_cmake(int ac, char const* const* av) std::vector<std::string> keys = cm.GetState()->GetCacheEntryKeys(); for (std::vector<std::string>::const_iterator it = keys.begin(); it != keys.end(); ++it) { - cmState::CacheEntryType t = cm.GetState()->GetCacheEntryType(*it); - if (t != cmState::INTERNAL && t != cmState::STATIC && - t != cmState::UNINITIALIZED) { + cmStateEnums::CacheEntryType t = cm.GetState()->GetCacheEntryType(*it); + if (t != cmStateEnums::INTERNAL && t != cmStateEnums::STATIC && + t != cmStateEnums::UNINITIALIZED) { const char* advancedProp = cm.GetState()->GetCacheEntryProperty(*it, "ADVANCED"); if (list_all_cached || !advancedProp) { diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 4387bf6..c008791 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -7,7 +7,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmQtAutoGenerators.h" -#include "cmState.h" +#include "cmStateDirectory.h" #include "cmSystemTools.h" #include "cmUtils.hxx" #include "cmVersion.h" @@ -414,7 +414,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 0; } - else if (args[1] == "env") { + if (args[1] == "env") { std::vector<std::string>::const_iterator ai = args.begin() + 2; std::vector<std::string>::const_iterator ae = args.end(); for (; ai != ae; ++ai) { @@ -454,7 +454,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } #if defined(CMAKE_BUILD_WITH_CMAKE) - else if (args[1] == "environment") { + if (args[1] == "environment") { std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables(); std::vector<std::string>::iterator it; for (it = env.begin(); it != env.end(); ++it) { @@ -464,7 +464,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } #endif - else if (args[1] == "make_directory" && args.size() > 2) { + if (args[1] == "make_directory" && args.size() > 2) { // If error occurs we want to continue copying next files. bool return_value = 0; for (std::string::size_type cc = 2; cc < args.size(); cc++) { @@ -476,7 +476,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return return_value; } - else if (args[1] == "remove_directory" && args.size() == 3) { + if (args[1] == "remove_directory" && args.size() == 3) { if (cmSystemTools::FileIsDirectory(args[2]) && !cmSystemTools::RemoveADirectory(args[2])) { std::cerr << "Error removing directory \"" << args[2] << "\".\n"; @@ -486,7 +486,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Remove file - else if (args[1] == "remove" && args.size() > 2) { + if (args[1] == "remove" && args.size() > 2) { bool force = false; for (std::string::size_type cc = 2; cc < args.size(); cc++) { if (args[cc] == "\\-f" || args[cc] == "-f") { @@ -502,8 +502,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } return 0; } + // Touch file - else if (args[1] == "touch" && args.size() > 2) { + if (args[1] == "touch" && args.size() > 2) { for (std::string::size_type cc = 2; cc < args.size(); cc++) { if (!cmSystemTools::Touch(args[cc], true)) { return 1; @@ -511,8 +512,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } return 0; } + // Touch file - else if (args[1] == "touch_nocreate" && args.size() > 2) { + if (args[1] == "touch_nocreate" && args.size() > 2) { for (std::string::size_type cc = 2; cc < args.size(); cc++) { // Complain if the file could not be removed, still exists, // and the -f option was not given. @@ -522,8 +524,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } return 0; } + // capabilities - else if (args[1] == "capabilities") { + if (args[1] == "capabilities") { if (args.size() > 2) { std::cerr << "-E capabilities accepts no additional arguments\n"; return 1; @@ -538,7 +541,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Sleep command - else if (args[1] == "sleep" && args.size() > 2) { + if (args[1] == "sleep" && args.size() > 2) { double total = 0; for (size_t i = 2; i < args.size(); ++i) { double num = 0.0; @@ -559,7 +562,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Clock command - else if (args[1] == "time" && args.size() > 2) { + if (args[1] == "time" && args.size() > 2) { std::vector<std::string> command(args.begin() + 2, args.end()); clock_t clock_start, clock_finish; @@ -583,8 +586,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) << "\n"; return ret; } + // Command to calculate the md5sum of a file - else if (args[1] == "md5sum" && args.size() >= 3) { + if (args[1] == "md5sum" && args.size() >= 3) { char md5out[32]; int retval = 0; for (std::string::size_type cc = 2; cc < args.size(); cc++) { @@ -606,7 +610,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Command to change directory and run a program. - else if (args[1] == "chdir" && args.size() >= 4) { + if (args[1] == "chdir" && args.size() >= 4) { std::string directory = args[2]; if (!cmSystemTools::FileExists(directory.c_str())) { cmSystemTools::Error("Directory does not exist for chdir command: ", @@ -628,7 +632,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Command to start progress for a build - else if (args[1] == "cmake_progress_start" && args.size() == 4) { + if (args[1] == "cmake_progress_start" && args.size() == 4) { // basically remove the directory std::string dirName = args[2]; dirName += "/Progress"; @@ -660,7 +664,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Command to report progress for a build - else if (args[1] == "cmake_progress_report" && args.size() >= 3) { + if (args[1] == "cmake_progress_report" && args.size() >= 3) { // This has been superseded by cmake_echo_color --progress-* // options. We leave it here to avoid errors if somehow this // is invoked by an existing makefile without regenerating. @@ -669,7 +673,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Command to create a symbolic link. Fails on platforms not // supporting them. - else if (args[1] == "create_symlink" && args.size() == 4) { + if (args[1] == "create_symlink" && args.size() == 4) { const char* destinationFileName = args[3].c_str(); if ((cmSystemTools::FileExists(destinationFileName) || cmSystemTools::FileIsSymlink(destinationFileName)) && @@ -690,16 +694,17 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Internal CMake shared library support. - else if (args[1] == "cmake_symlink_library" && args.size() == 5) { + if (args[1] == "cmake_symlink_library" && args.size() == 5) { return cmcmd::SymlinkLibrary(args); } + // Internal CMake versioned executable support. - else if (args[1] == "cmake_symlink_executable" && args.size() == 4) { + if (args[1] == "cmake_symlink_executable" && args.size() == 4) { return cmcmd::SymlinkExecutable(args); } // Internal CMake dependency scanning support. - else if (args[1] == "cmake_depends" && args.size() >= 6) { + if (args[1] == "cmake_depends" && args.size() >= 6) { const bool verbose = isCMakeVerbose(); // Create a cmake object instance to process dependencies. @@ -760,7 +765,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) cm.GetCurrentSnapshot().SetDefaultDefinitions(); if (cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen)) { cm.SetGlobalGenerator(ggd); - cmState::Snapshot snapshot = cm.GetCurrentSnapshot(); + cmStateSnapshot snapshot = cm.GetCurrentSnapshot(); snapshot.GetDirectory().SetCurrentBinary(startOutDir); snapshot.GetDirectory().SetCurrentSource(startDir); CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(ggd, snapshot)); @@ -774,41 +779,47 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Internal CMake link script support. - else if (args[1] == "cmake_link_script" && args.size() >= 3) { + if (args[1] == "cmake_link_script" && args.size() >= 3) { return cmcmd::ExecuteLinkScript(args); } #ifdef CMAKE_BUILD_WITH_CMAKE // Internal CMake ninja dependency scanning support. - else if (args[1] == "cmake_ninja_depends") { + if (args[1] == "cmake_ninja_depends") { return cmcmd_cmake_ninja_depends(args.begin() + 2, args.end()); } // Internal CMake ninja dyndep support. - else if (args[1] == "cmake_ninja_dyndep") { + if (args[1] == "cmake_ninja_dyndep") { return cmcmd_cmake_ninja_dyndep(args.begin() + 2, args.end()); } #endif // Internal CMake unimplemented feature notification. - else if (args[1] == "cmake_unimplemented_variable") { + if (args[1] == "cmake_unimplemented_variable") { std::cerr << "Feature not implemented for this platform."; if (args.size() == 3) { std::cerr << " Variable " << args[2] << " is not set."; } std::cerr << std::endl; return 1; - } else if (args[1] == "vs_link_exe") { + } + + if (args[1] == "vs_link_exe") { return cmcmd::VisualStudioLink(args, 1); - } else if (args[1] == "vs_link_dll") { + } + + if (args[1] == "vs_link_dll") { return cmcmd::VisualStudioLink(args, 2); } + // Internal CMake color makefile support. - else if (args[1] == "cmake_echo_color") { + if (args[1] == "cmake_echo_color") { return cmcmd::ExecuteEchoColor(args); } + #ifdef CMAKE_BUILD_WITH_CMAKE - else if (args[1] == "cmake_autogen" && args.size() >= 4) { + if (args[1] == "cmake_autogen" && args.size() >= 4) { cmQtAutoGenerators autogen; std::string const& config = args[3]; bool autogenSuccess = autogen.Run(args[2], config); @@ -817,7 +828,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) #endif // Tar files - else if (args[1] == "tar" && args.size() > 3) { + if (args[1] == "tar" && args.size() > 3) { const char* knownFormats[] = { "7zip", "gnutar", "pax", "paxr", "zip" }; std::string flags = args[2]; @@ -921,7 +932,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) #endif } return 0; - } else if (args[1] == "server") { + } + + if (args[1] == "server") { const std::string pipePrefix = "--pipe="; bool supportExperimental = false; bool isDebug = false; @@ -958,28 +971,26 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::string errorMessage; if (server.Serve(&errorMessage)) { return 0; - } else { - cmSystemTools::Error(errorMessage.c_str()); - return 1; } + cmSystemTools::Error(errorMessage.c_str()); #else static_cast<void>(supportExperimental); static_cast<void>(isDebug); cmSystemTools::Error("CMake was not built with server mode enabled"); - return 1; #endif + return 1; } #if defined(CMAKE_BUILD_WITH_CMAKE) // Internal CMake Fortran module support. - else if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) { + if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) { return cmDependsFortran::CopyModule(args) ? 0 : 1; } #endif #if defined(_WIN32) && !defined(__CYGWIN__) // Write registry value - else if (args[1] == "write_regv" && args.size() > 3) { + if (args[1] == "write_regv" && args.size() > 3) { return cmSystemTools::WriteRegistryValue(args[2].c_str(), args[3].c_str()) ? 0 @@ -987,16 +998,21 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // Delete registry value - else if (args[1] == "delete_regv" && args.size() > 2) { + if (args[1] == "delete_regv" && args.size() > 2) { return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1; } + // Remove file - else if (args[1] == "comspec" && args.size() > 2) { + if (args[1] == "comspec" && args.size() > 2) { std::cerr << "Win9x helper \"cmake -E comspec\" no longer supported\n"; return 1; - } else if (args[1] == "env_vs8_wince" && args.size() == 3) { + } + + if (args[1] == "env_vs8_wince" && args.size() == 3) { return cmcmd::WindowsCEEnvironment("8.0", args[2]); - } else if (args[1] == "env_vs9_wince" && args.size() == 3) { + } + + if (args[1] == "env_vs9_wince" && args.size() == 3) { return cmcmd::WindowsCEEnvironment("9.0", args[2]); } #endif @@ -292,6 +292,8 @@ CMAKE_CXX_SOURCES="\ cmSourceFile \ cmSourceFileLocation \ cmState \ + cmStateDirectory \ + cmStateSnapshot \ cmSystemTools \ cmTestGenerator \ cmVersion \ |