diff options
64 files changed, 722 insertions, 518 deletions
diff --git a/Auxiliary/cmake-mode.el b/Auxiliary/cmake-mode.el index 11e33b3..08ac490 100644 --- a/Auxiliary/cmake-mode.el +++ b/Auxiliary/cmake-mode.el @@ -70,11 +70,11 @@ set the path with these commands: (defconst cmake-regex-indented (rx-to-string `(and bol (* (group (or (regexp ,cmake-regex-token) (any space ?\n))))))) (defconst cmake-regex-block-open - (rx-to-string `(and bow (or ,@(append cmake-keywords-block-open - (mapcar 'downcase cmake-keywords-block-open))) eow))) + (rx-to-string `(and symbol-start (or ,@(append cmake-keywords-block-open + (mapcar 'downcase cmake-keywords-block-open))) symbol-end))) (defconst cmake-regex-block-close - (rx-to-string `(and bow (or ,@(append cmake-keywords-block-close - (mapcar 'downcase cmake-keywords-block-close))) eow))) + (rx-to-string `(and symbol-start (or ,@(append cmake-keywords-block-close + (mapcar 'downcase cmake-keywords-block-close))) symbol-end))) (defconst cmake-regex-close (rx-to-string `(and bol (* space) (regexp ,cmake-regex-block-close) (* space) (regexp ,cmake-regex-paren-left)))) @@ -177,7 +177,7 @@ the indentation. Otherwise it retains the same position on the line" (interactive) (save-excursion (goto-char (point-min)) - (while (re-search-forward "^\\([ \t]*\\)\\(\\w+\\)\\([ \t]*(\\)" nil t) + (while (re-search-forward "^\\([ \t]*\\)\\_<\\(\\(?:\\w\\|\\s_\\)+\\)\\_>\\([ \t]*(\\)" nil t) (replace-match (concat (match-string 1) diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index fe7735c..5033e18 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -36,6 +36,12 @@ property is set to ``ON`` automatically. A ``SHARED`` library may be marked with the :prop_tgt:`FRAMEWORK` target property to create an OS X Framework. +If a library does not export any symbols, it must not be declared as a +``SHARED`` library. For example, a Windows resource DLL or a managed C++/CLI +DLL that exports no unmanaged symbols would need to be a ``MODULE`` library. +This is because CMake expects a ``SHARED`` library to always have an +associated import library on Windows. + By default the library file will be created in the build tree directory corresponding to the source tree directory in which the command was invoked. See documentation of the :prop_tgt:`ARCHIVE_OUTPUT_DIRECTORY`, diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst index 357aae9..bc633e6 100644 --- a/Help/manual/cmake-buildsystem.7.rst +++ b/Help/manual/cmake-buildsystem.7.rst @@ -80,6 +80,10 @@ regardless of the library type. The ``MODULE`` library type is dissimilar in that it is generally not linked to -- it is not used in the right-hand-side of the :command:`target_link_libraries` command. It is a type which is loaded as a plugin using runtime techniques. +If the library does not export any unmanaged symbols (e.g. Windows +resource DLL, C++/CLI DLL), it is required that the library not be a +``SHARED`` library because CMake expects ``SHARED`` libraries to export +at least one symbol. .. code-block:: cmake @@ -781,7 +785,8 @@ An *archive* output artifact of a buildsystem target may be: * On DLL platforms: the import library file (e.g. ``.lib``) of a shared library target created by the :command:`add_library` command - with the ``SHARED`` option. + with the ``SHARED`` option. This file is only guaranteed to exist if + the library exports at least one unmanaged symbol. * On DLL platforms: the import library file (e.g. ``.lib``) of an executable target created by the :command:`add_executable` command diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 2dc67bc..caf5bac 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -308,4 +308,4 @@ versions specified for each: * ``Clang``: Clang compiler versions 2.9 through 3.4. * ``GNU``: GNU compiler versions 4.4 through 5.0. * ``MSVC``: Microsoft Visual Studio versions 2010 through 2015. -* ``SunPro``: Oracle SolarisStudio version 12.4 on a Linux host. +* ``SunPro``: Oracle SolarisStudio version 12.4. diff --git a/Help/release/dev/FindGTK2_sigc++_c++11.rst b/Help/release/dev/FindGTK2_sigc++_c++11.rst new file mode 100644 index 0000000..2ba1459 --- /dev/null +++ b/Help/release/dev/FindGTK2_sigc++_c++11.rst @@ -0,0 +1,7 @@ +FindGTK2_sigc++_c++11 +--------------------- + +* Starting with sigc++ 2.5.1, c++11 must be enabled in order to use + sigc++. The GTK2::sigc++ imported target will automatically enable the + required build flags in order to build with the version found on the + system. diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake index 5fe51a6..bef8e16 100644 --- a/Modules/CPackWIX.cmake +++ b/Modules/CPackWIX.cmake @@ -16,7 +16,7 @@ # # Will be automatically generated unless explicitly provided. # -# It should be explicitly set to a constant generated gloabally unique +# It should be explicitly set to a constant generated globally unique # identifier (GUID) to allow your installers to replace existing # installations that use the same GUID. # @@ -226,7 +226,7 @@ # This variable can be used to provide a value for # the Windows Installer property ``<PROPERTY>`` # -# The follwing list contains some example properties that can be used to +# The following list contains some example properties that can be used to # customize information under # "Programs and Features" (also known as "Add or Remove Programs") # diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 0e936ca..50d68ee 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -31,21 +31,17 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -xar -o <TARGET> <OBJECTS> " "<CMAKE_RANLIB> <TARGET> ") -if (CMAKE_SYSTEM_NAME STREQUAL Linux) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++03") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=c++03") - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") - endif() +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") +endif() - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - if (NOT CMAKE_CXX_COMPILER_FORCED) - if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) - message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}") - endif() - set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}) +if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + if (NOT CMAKE_CXX_COMPILER_FORCED) + if (NOT CMAKE_CXX_STANDARD_COMPUTED_DEFAULT) + message(FATAL_ERROR "CMAKE_CXX_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER}) version ${CMAKE_CXX_COMPILER_VERSION}") endif() + set(CMAKE_CXX_STANDARD_DEFAULT ${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}) endif() endif() @@ -55,12 +51,10 @@ macro(cmake_record_cxx_compile_features) endmacro() set(_result 0) - if (CMAKE_SYSTEM_NAME STREQUAL Linux) - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) - _get_solaris_studio_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) - if (_result EQUAL 0) - _get_solaris_studio_features("" CMAKE_CXX98_COMPILE_FEATURES) - endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) + _get_solaris_studio_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) + if (_result EQUAL 0) + _get_solaris_studio_features("" CMAKE_CXX98_COMPILE_FEATURES) endif() endif() endmacro() diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 72bb8eb..ab4ef3e 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -202,6 +202,43 @@ function(_GTK2_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr) endif() endfunction() + +#============================================================= +# _GTK2_SIGCXX_GET_VERSION +# Internal function to parse the version number in +# sigc++config.h +# _OUT_major = Major version number +# _OUT_minor = Minor version number +# _OUT_micro = Micro version number +# _sigcxxversion_hdr = Header file to parse +#============================================================= + +function(_GTK2_SIGCXX_GET_VERSION _OUT_major _OUT_minor _OUT_micro _sigcxxversion_hdr) + file(STRINGS ${_sigcxxversion_hdr} _contents REGEX "#define SIGCXX_M[A-Z]+_VERSION[ \t]+") + if(_contents) + string(REGEX REPLACE ".*#define SIGCXX_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_major} "${_contents}") + string(REGEX REPLACE ".*#define SIGCXX_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_minor} "${_contents}") + string(REGEX REPLACE ".*#define SIGCXX_MICRO_VERSION[ \t]+([0-9]+).*" "\\1" ${_OUT_micro} "${_contents}") + + if(NOT ${_OUT_major} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for SIGCXX_MAJOR_VERSION!") + endif() + if(NOT ${_OUT_minor} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for SIGCXX_MINOR_VERSION!") + endif() + if(NOT ${_OUT_micro} MATCHES "[0-9]+") + message(FATAL_ERROR "Version parsing failed for SIGCXX_MICRO_VERSION!") + endif() + + set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE) + set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE) + set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE) + else() + message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist") + endif() +endfunction() + + #============================================================= # _GTK2_FIND_INCLUDE_DIR # Internal function to find the GTK include directories @@ -734,6 +771,27 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(SIGC++CONFIG sigc++config.h) _GTK2_FIND_LIBRARY (SIGC++ sigc true true) _GTK2_ADD_TARGET (SIGC++) + # Since sigc++ 2.5.1 c++11 support is required + if(GTK2_SIGC++CONFIG_INCLUDE_DIR) + _GTK2_SIGCXX_GET_VERSION(GTK2_SIGC++_VERSION_MAJOR + GTK2_SIGC++_VERSION_MINOR + GTK2_SIGC++_VERSION_MICRO + ${GTK2_SIGC++CONFIG_INCLUDE_DIR}/sigc++config.h) + if(NOT ${GTK2_SIGC++_VERSION_MAJOR}.${GTK2_SIGC++_VERSION_MINOR}.${GTK2_SIGC++_VERSION_MICRO} VERSION_LESS 2.5.1) + # These are the features needed by clients in order to include the + # project headers: + set_property(TARGET GTK2::sigc++ + PROPERTY INTERFACE_COMPILE_FEATURES cxx_alias_templates + cxx_auto_type + cxx_decltype + cxx_deleted_functions + cxx_noexcept + cxx_nullptr + cxx_right_angle_brackets + cxx_rvalue_references + cxx_variadic_templates) + endif() + endif() _GTK2_FIND_INCLUDE_DIR(GLIBMM glibmm.h) _GTK2_FIND_INCLUDE_DIR(GLIBMMCONFIG glibmmconfig.h) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ae5b03f..ee690e6 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -548,6 +548,19 @@ foreach(v CURL_CA_BUNDLE CURL_CA_PATH) endif() endforeach() +foreach(check + STAT_HAS_ST_MTIM + STAT_HAS_ST_MTIMESPEC + ) + if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry + set(CMake_${check} 1) + else() + set(CMake_${check} 0) + endif() + set_property(SOURCE cmFileTimeComparison.cxx APPEND PROPERTY + COMPILE_DEFINITIONS CMake_${check}=${CMake_${check}}) +endforeach() + # create a library used by the command line and the GUI add_library(CMakeLib ${SRCS}) target_link_libraries(CMakeLib cmsys diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 852d360..8095229 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 4) -set(CMake_VERSION_PATCH 20151008) +set(CMake_VERSION_PATCH 20151012) #set(CMake_VERSION_RC 1) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 7da334e..06eb3ec 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -51,14 +51,14 @@ void CCONV cmSetError(void *info, const char *err) unsigned int CCONV cmGetCacheMajorVersion(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); - cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager(); - return manager->GetCacheMajorVersion(); + cmState *state = mf->GetState(); + return state->GetCacheMajorVersion(); } unsigned int CCONV cmGetCacheMinorVersion(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); - cmCacheManager *manager = mf->GetCMakeInstance()->GetCacheManager(); - return manager->GetCacheMinorVersion(); + cmState *state = mf->GetState(); + return state->GetCacheMinorVersion(); } unsigned int CCONV cmGetMajorVersion(void *) @@ -116,7 +116,7 @@ const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); static std::string name; - name = mf->GetProjectName(); + name = mf->GetStateSnapshot().GetProjectName(); return name.c_str(); } diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 54209c5..ce8af55 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -13,7 +13,6 @@ #include "cmCacheManager.h" #include "cmSystemTools.h" #include "cmGeneratedFileStream.h" -#include "cmMakefile.h" #include "cmake.h" #include "cmVersion.h" @@ -22,101 +21,10 @@ #include <cmsys/FStream.hxx> #include <cmsys/RegularExpression.hxx> -cmCacheManager::cmCacheManager(cmake* cm) +cmCacheManager::cmCacheManager() { this->CacheMajorVersion = 0; this->CacheMinorVersion = 0; - this->CMakeInstance = cm; -} - -bool cmCacheManager::LoadCache(const std::string& path) -{ - std::set<std::string> emptySet; - return this->LoadCache(path, true, emptySet, emptySet); -} - -static bool ParseEntryWithoutType(const std::string& entry, - std::string& var, - std::string& value) -{ - // input line is: key=value - static cmsys::RegularExpression reg( - "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - // input line is: "key"=value - static cmsys::RegularExpression regQuoted( - "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - bool flag = false; - if(regQuoted.find(entry)) - { - var = regQuoted.match(1); - value = regQuoted.match(2); - flag = true; - } - else if (reg.find(entry)) - { - var = reg.match(1); - value = reg.match(2); - flag = true; - } - - // if value is enclosed in single quotes ('foo') then remove them - // it is used to enclose trailing space or tab - if (flag && - value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') - { - value = value.substr(1, - value.size() - 2); - } - - return flag; -} - -bool cmCacheManager::ParseEntry(const std::string& entry, - std::string& var, - std::string& value, - cmState::CacheEntryType& type) -{ - // input line is: key:type=value - static cmsys::RegularExpression reg( - "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - // input line is: "key":type=value - static cmsys::RegularExpression regQuoted( - "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); - bool flag = false; - if(regQuoted.find(entry)) - { - var = regQuoted.match(1); - type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str()); - value = regQuoted.match(3); - flag = true; - } - else if (reg.find(entry)) - { - var = reg.match(1); - type = cmState::StringToCacheEntryType(reg.match(2).c_str()); - value = reg.match(3); - flag = true; - } - - // if value is enclosed in single quotes ('foo') then remove them - // it is used to enclose trailing space or tab - if (flag && - value.size() >= 2 && - value[0] == '\'' && - value[value.size() - 1] == '\'') - { - value = value.substr(1, - value.size() - 2); - } - - if (!flag) - { - return ParseEntryWithoutType(entry, var, value); - } - - return flag; } void cmCacheManager::CleanCMakeFiles(const std::string& path) @@ -195,7 +103,7 @@ bool cmCacheManager::LoadCache(const std::string& path, } } e.SetProperty("HELPSTRING", helpString.c_str()); - if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type)) + if(cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) { if ( excludes.find(entryKey) == excludes.end() ) { @@ -678,7 +586,6 @@ void cmCacheManager::AddCacheEntry(const std::string& key, } e.SetProperty("HELPSTRING", helpString? helpString : "(This variable does not exist and should not be used)"); - this->CMakeInstance->UnwatchUnusedCli(key); } bool cmCacheManager::CacheIterator::IsAtEnd() const diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 8462259..6f063eb 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -16,9 +16,7 @@ #include "cmPropertyMap.h" #include "cmState.h" -class cmMakefile; class cmMarkAsAdvancedCommand; -class cmake; /** \class cmCacheManager * \brief Control class for cmake's cache @@ -29,7 +27,7 @@ class cmake; class cmCacheManager { public: - cmCacheManager(cmake* cm); + cmCacheManager(); class CacheIterator; friend class cmCacheManager::CacheIterator; @@ -100,7 +98,6 @@ public: } ///! Load a cache for given makefile. Loads from path/CMakeCache.txt. - bool LoadCache(const std::string& path); bool LoadCache(const std::string& path, bool internal, std::set<std::string>& excludes, std::set<std::string>& includes); @@ -124,12 +121,6 @@ public: int GetSize() { return static_cast<int>(this->Cache.size()); } - ///! Break up a line like VAR:type="value" into var, type and value - static bool ParseEntry(const std::string& entry, - std::string& var, - std::string& value, - cmState::CacheEntryType& type); - ///! Get a value from the cache given a key const char* GetInitializedCacheValue(const std::string& key) const; @@ -241,7 +232,7 @@ private: void WritePropertyEntries(std::ostream& os, CacheIterator const& i); CacheEntryMap Cache; - // Only cmake and cmMakefile should be able to add cache values + // Only cmake and cmState should be able to add cache values // the commands should never use the cmCacheManager directly friend class cmState; // allow access to add cache values friend class cmake; // allow access to add cache values diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 5ad8714..fc484de 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -65,8 +65,6 @@ private: std::string Config; EntryVector FinalLinkEntries; - typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType; - std::map<std::string, int>::iterator AllocateLinkEntry(std::string const& item); int AddLinkEntry(cmLinkItem const& item); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 7e34611..c76cb7a 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -284,7 +284,7 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from @@ -521,7 +521,7 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. const char* lss = - this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); + this->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -855,7 +855,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() // Lookup the starting link type from the target (linked statically?). const char* lss = - this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); + this->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1914,7 +1914,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = (outputRuntime && this->Target->HaveInstallTreeRPATH() && linking_for_install); @@ -1924,14 +1924,14 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set<std::string> emitted; if(use_install_rpath) { const char* install_rpath = - this->Target->Target->GetProperty("INSTALL_RPATH"); + this->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -1971,8 +1971,9 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, else if(use_link_rpath) { // Do not add any path inside the source or build tree. - const char* topSourceDir = this->Makefile->GetHomeDirectory(); - const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory(); + const char* topSourceDir = this->CMakeInstance->GetHomeDirectory(); + const char* topBinaryDir = + this->CMakeInstance->GetHomeOutputDirectory(); if(!cmSystemTools::ComparePath(*ri, topSourceDir) && !cmSystemTools::ComparePath(*ri, topBinaryDir) && !cmSystemTools::IsSubDirectory(*ri, topSourceDir) && diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 7f3b651..4b6bd50 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -101,7 +101,7 @@ cmCustomCommandGenerator } else { - cmOutputConverter converter(this->LG->GetMakefile()->GetStateSnapshot()); + cmOutputConverter converter(this->LG->GetStateSnapshot()); cmd += converter.EscapeForShell(arg, this->MakeVars); } } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 856dcd4..80f560f 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -160,7 +160,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends, if (mod_dir.empty()) { mod_dir = - this->LocalGenerator->GetMakefile()->GetCurrentBinaryDirectory(); + this->LocalGenerator->GetCurrentBinaryDirectory(); } // Actually write dependencies to the streams. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index d6149b3..5d530a0 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -241,12 +241,14 @@ static bool isSubDirectory(const char* a, const char* b) //---------------------------------------------------------------------------- static bool checkInterfaceDirs(const std::string &prepro, - cmTarget *target, const std::string& prop) + cmGeneratorTarget *target, const std::string& prop) { const char* installDir = - target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); - const char* topSourceDir = target->GetMakefile()->GetHomeDirectory(); - const char* topBinaryDir = target->GetMakefile()->GetHomeOutputDirectory(); + target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); + const char* topSourceDir = + target->GetLocalGenerator()->GetSourceDirectory(); + const char* topBinaryDir = + target->GetLocalGenerator()->GetBinaryDirectory(); std::vector<std::string> parts; cmGeneratorExpression::Split(prepro, parts); @@ -269,7 +271,7 @@ static bool checkInterfaceDirs(const std::string &prepro, { if (prop == "INTERFACE_INCLUDE_DIRECTORIES") { - switch (target->GetPolicyStatusCMP0041()) + switch (target->Target->GetPolicyStatusCMP0041()) { case cmPolicies::WARN: messageType = cmake::WARNING; @@ -298,7 +300,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains relative path:\n" " \"" << *li << "\""; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } bool inBinary = isSubDirectory(li->c_str(), topBinaryDir); bool inSource = isSubDirectory(li->c_str(), topSourceDir); @@ -316,7 +318,7 @@ static bool checkInterfaceDirs(const std::string &prepro, { if (!shouldContinue) { - switch(target->GetPolicyStatusCMP0052()) + switch(target->Target->GetPolicyStatusCMP0052()) { case cmPolicies::WARN: { @@ -329,7 +331,7 @@ static bool checkInterfaceDirs(const std::string &prepro, "a subdirectory of the " << (inBinary ? "build" : "source") << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir) << "\"" << std::endl; - target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING, + target->GetLocalGenerator()->IssueMessage(cmake::AUTHOR_WARNING, s.str()); } case cmPolicies::OLD: @@ -352,7 +354,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the build directory."; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } if (!inSourceBuild) { @@ -361,7 +363,7 @@ static bool checkInterfaceDirs(const std::string &prepro, e << "Target \"" << target->GetName() << "\" " << prop << " property contains path:\n" " \"" << *li << "\"\nwhich is prefixed in the source directory."; - target->GetMakefile()->IssueMessage(messageType, e.str()); + target->GetLocalGenerator()->IssueMessage(messageType, e.str()); } } } @@ -421,7 +423,9 @@ void cmExportFileGenerator::PopulateSourcesInterface( this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets); - if (!checkInterfaceDirs(prepro, target, propName)) + cmGeneratorTarget* gt = target->GetMakefile() + ->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!checkInterfaceDirs(prepro, gt, propName)) { return; } @@ -491,7 +495,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface( this->ResolveTargetsInGeneratorExpressions(prepro, target->Target, missingTargets); - if (!checkInterfaceDirs(prepro, target->Target, propName)) + if (!checkInterfaceDirs(prepro, target, propName)) { return; } diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 7915a6e..0406644 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -76,9 +76,8 @@ void cmExtraCodeBlocksGenerator::Generate() void cmExtraCodeBlocksGenerator::CreateProjectFile( const std::vector<cmLocalGenerator*>& lgs) { - const cmMakefile* mf=lgs[0]->GetMakefile(); - std::string outputDir=mf->GetCurrentBinaryDirectory(); - std::string projectName=mf->GetProjectName(); + std::string outputDir=lgs[0]->GetCurrentBinaryDirectory(); + std::string projectName=lgs[0]->GetProjectName(); std::string filename=outputDir+"/"; filename+=projectName+".cbp"; @@ -273,7 +272,7 @@ void cmExtraCodeBlocksGenerator } const std::string &relative = cmSystemTools::RelativePath( - it->second[0]->GetMakefile()->GetHomeDirectory(), + it->second[0]->GetSourceDirectory(), jt->c_str()); std::vector<std::string> splitted; cmSystemTools::SplitPath(relative, splitted, false); @@ -297,7 +296,7 @@ void cmExtraCodeBlocksGenerator tree.BuildVirtualFolder(virtualFolders); // And one for <Unit> std::string unitFiles; - tree.BuildUnit(unitFiles, std::string(mf->GetHomeDirectory()) + "/"); + tree.BuildUnit(unitFiles, std::string(lgs[0]->GetSourceDirectory()) + "/"); // figure out the compiler std::string compiler = this->GetCBCompilerId(mf); @@ -307,7 +306,7 @@ void cmExtraCodeBlocksGenerator "<CodeBlocks_project_file>\n" " <FileVersion major=\"1\" minor=\"6\" />\n" " <Project>\n" - " <Option title=\"" << mf->GetProjectName()<<"\" />\n" + " <Option title=\"" << lgs[0]->GetProjectName()<<"\" />\n" " <Option makefile_is_custom=\"1\" />\n" " <Option compiler=\"" << compiler << "\" />\n" " "<<virtualFolders<<"\n" @@ -331,8 +330,8 @@ void cmExtraCodeBlocksGenerator { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs - if (strcmp(makefile->GetCurrentBinaryDirectory(), - makefile->GetHomeOutputDirectory())==0) + if (strcmp((*lg)->GetCurrentBinaryDirectory(), + (*lg)->GetBinaryDirectory())==0) { this->AppendTarget(fout, ti->first, 0, make.c_str(), *lg, compiler.c_str()); @@ -524,11 +523,10 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile( cmLocalGenerator* lg, cmTarget* target) const { - cmMakefile *mf = lg->GetMakefile(); // this file doesn't seem to be used by C::B in custom makefile mode, // but we generate a unique file for each OBJECT library so in case // C::B uses it in some way, the targets don't interfere with each other. - std::string filename = mf->GetCurrentBinaryDirectory(); + std::string filename = lg->GetCurrentBinaryDirectory(); filename += "/"; filename += lg->GetTargetDirectory(*target); filename += "/"; @@ -555,14 +553,14 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, const char* compiler) { cmMakefile const* makefile = lg->GetMakefile(); - std::string makefileName = makefile->GetCurrentBinaryDirectory(); + std::string makefileName = lg->GetCurrentBinaryDirectory(); makefileName += "/Makefile"; fout<<" <Target title=\"" << targetName << "\">\n"; if (target!=0) { int cbTargetType = this->GetCBTargetType(target); - std::string workingDir = makefile->GetCurrentBinaryDirectory(); + std::string workingDir = lg->GetCurrentBinaryDirectory(); if ( target->GetType()==cmTarget::EXECUTABLE) { // Determine the directory where the executable target is created, and @@ -659,7 +657,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, else // e.g. all and the GLOBAL and UTILITY targets { fout<<" <Option working_dir=\"" - << makefile->GetCurrentBinaryDirectory() << "\" />\n" + << lg->GetCurrentBinaryDirectory() << "\" />\n" <<" <Option type=\"" << 4 << "\" />\n"; } @@ -693,8 +691,6 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf) compilerIdVar = "CMAKE_C_COMPILER_ID"; } - std::string hostSystemName = mf->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); - std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); std::string compilerId = mf->GetSafeDefinition(compilerIdVar); std::string compiler = "gcc"; // default to gcc if (compilerId == "MSVC") diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 496c1a8..31dbf3d 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -68,15 +68,15 @@ void cmExtraCodeLiteGenerator::Generate() const cmMakefile* mf =it->second[0]->GetMakefile(); this->ConfigName = GetConfigurationName( mf ); - if (strcmp(mf->GetCurrentBinaryDirectory(), - mf->GetHomeOutputDirectory()) == 0) + if (strcmp(it->second[0]->GetCurrentBinaryDirectory(), + it->second[0]->GetBinaryDirectory()) == 0) { - workspaceOutputDir = mf->GetCurrentBinaryDirectory(); - workspaceProjectName = mf->GetProjectName(); - workspaceSourcePath = mf->GetHomeDirectory(); + workspaceOutputDir = it->second[0]->GetCurrentBinaryDirectory(); + workspaceProjectName = it->second[0]->GetProjectName(); + workspaceSourcePath = it->second[0]->GetSourceDirectory(); workspaceFileName = workspaceOutputDir+"/"; workspaceFileName += workspaceProjectName + ".workspace"; - this->WorkspacePath = mf->GetCurrentBinaryDirectory();; + this->WorkspacePath = it->second[0]->GetCurrentBinaryDirectory();; fout.Open(workspaceFileName.c_str(), false, false); fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" @@ -91,9 +91,8 @@ void cmExtraCodeLiteGenerator::Generate() ++it) { // retrive project information - const cmMakefile* mf = it->second[0]->GetMakefile(); - std::string outputDir = mf->GetCurrentBinaryDirectory(); - std::string projectName = mf->GetProjectName(); + std::string outputDir = it->second[0]->GetCurrentBinaryDirectory(); + std::string projectName = it->second[0]->GetProjectName(); std::string filename = outputDir + "/" + projectName + ".project"; // Make the project file relative to the workspace @@ -121,9 +120,8 @@ void cmExtraCodeLiteGenerator::Generate() void cmExtraCodeLiteGenerator::CreateProjectFile( const std::vector<cmLocalGenerator*>& lgs) { - const cmMakefile* mf = lgs[0]->GetMakefile(); - std::string outputDir = mf->GetCurrentBinaryDirectory(); - std::string projectName = mf->GetProjectName(); + std::string outputDir = lgs[0]->GetCurrentBinaryDirectory(); + std::string projectName = lgs[0]->GetProjectName(); std::string filename = outputDir + "/"; filename += projectName + ".project"; @@ -143,7 +141,7 @@ void cmExtraCodeLiteGenerator //////////////////////////////////// fout << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" - "<CodeLite_Project Name=\"" << mf->GetProjectName() + "<CodeLite_Project Name=\"" << lgs[0]->GetProjectName() << "\" InternalType=\"\">\n"; // Collect all used source files in the project diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 6dc18c2..fdfa35e 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -79,8 +79,8 @@ void cmExtraEclipseCDT4Generator //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::Generate() { - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + const cmMakefile* mf = lg->GetMakefile(); std::string eclipseVersion = mf->GetSafeDefinition("CMAKE_ECLIPSE_VERSION"); cmsys::RegularExpression regex(".*([0-9]+\\.[0-9]+).*"); @@ -106,8 +106,8 @@ void cmExtraEclipseCDT4Generator::Generate() } // TODO: Decide if these are local or member variables - this->HomeDirectory = mf->GetHomeDirectory(); - this->HomeOutputDirectory = mf->GetHomeOutputDirectory(); + this->HomeDirectory = lg->GetSourceDirectory(); + this->HomeOutputDirectory = lg->GetBinaryDirectory(); this->GenerateLinkedResources = mf->IsOn( "CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES"); @@ -157,9 +157,8 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() assert(this->HomeDirectory != this->HomeOutputDirectory); // set up the project name: <project>-Source@<baseSourcePathName> - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); - std::string name = this->GenerateProjectName(mf->GetProjectName(), "Source", + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + std::string name = this->GenerateProjectName(lg->GetProjectName(), "Source", this->GetPathBasename(this->HomeDirectory)); const std::string filename = this->HomeDirectory + "/.project"; @@ -197,8 +196,11 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, - const char* envVar, cmMakefile* mf) + const char* envVar, + cmLocalGenerator* lg) { + cmMakefile* mf = lg->GetMakefile(); + // get the variables from the environment and from the cache and then // figure out which one to use: @@ -206,7 +208,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_"; cacheEntryName += envVar; - const char* cacheValue = mf->GetState()->GetInitializedCacheValue( + const char* cacheValue = lg->GetState()->GetInitializedCacheValue( cacheEntryName); // now we have both, decide which one to use @@ -224,7 +226,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmState::STRING, true); - mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); } else if (envVarValue==0 && cacheValue!=0) { @@ -245,7 +247,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(), cacheEntryName.c_str(), cmState::STRING, true); - mf->GetCMakeInstance()->SaveCache(mf->GetHomeOutputDirectory()); + mf->GetCMakeInstance()->SaveCache(lg->GetBinaryDirectory()); } } @@ -259,8 +261,8 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout, //---------------------------------------------------------------------------- void cmExtraEclipseCDT4Generator::CreateProjectFile() { - cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + cmMakefile* mf = lg->GetMakefile(); const std::string filename = this->HomeOutputDirectory + "/.project"; @@ -280,7 +282,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<projectDescription>\n" "\t<name>" << - this->GenerateProjectName(mf->GetProjectName(), + this->GenerateProjectName(lg->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), this->GetPathBasename(this->HomeOutputDirectory)) << "</name>\n" @@ -361,17 +363,17 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // but not necessarily when eclipse is open if (compilerId == "MSVC") { - AddEnvVar(fout, "PATH", mf); - AddEnvVar(fout, "INCLUDE", mf); - AddEnvVar(fout, "LIB", mf); - AddEnvVar(fout, "LIBPATH", mf); + AddEnvVar(fout, "PATH", lg); + AddEnvVar(fout, "INCLUDE", lg); + AddEnvVar(fout, "LIB", lg); + AddEnvVar(fout, "LIBPATH", lg); } else if (compilerId == "Intel") { // if the env.var is set, use this one and put it in the cache // if the env.var is not set, but the value is in the cache, // use it from the cache: - AddEnvVar(fout, "INTEL_LICENSE_FILE", mf); + AddEnvVar(fout, "INTEL_LICENSE_FILE", lg); } fout << "</value>\n" @@ -495,7 +497,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() std::string sourceLinkedResourceName = "[Source directory]"; std::string linkSourceDirectory = this->GetEclipsePath( - mf->GetCurrentSourceDirectory()); + lg->GetCurrentSourceDirectory()); // .project dir can't be subdir of a linked resource dir if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory, linkSourceDirectory)) @@ -636,7 +638,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects( ++it) { std::string linkSourceDirectory = this->GetEclipsePath( - it->second[0]->GetMakefile()->GetCurrentSourceDirectory()); + it->second[0]->GetCurrentSourceDirectory()); // a linked resource must not point to a parent directory of .project or // .project itself if ((baseDir != linkSourceDirectory) && @@ -696,8 +698,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const { std::set<std::string> emmited; - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + const cmMakefile* mf = lg->GetMakefile(); const std::string filename = this->HomeOutputDirectory + "/.cproject"; @@ -1034,8 +1036,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const ++it) { const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); - cmMakefile* makefile=(*it)->GetMakefile(); - std::string subdir = (*it)->Convert(makefile->GetCurrentBinaryDirectory(), + std::string subdir = (*it)->Convert((*it)->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); if (subdir == ".") { @@ -1089,14 +1090,14 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const virtDir += prefix; virtDir += ti->first; std::string buildArgs = "-C \""; - buildArgs += makefile->GetHomeOutputDirectory(); + buildArgs += (*it)->GetBinaryDirectory(); buildArgs += "\" "; buildArgs += makeArgs; this->AppendTarget(fout, "Build", make, buildArgs, virtDir, "", ti->first.c_str()); std::string cleanArgs = "-E chdir \""; - cleanArgs += makefile->GetCurrentBinaryDirectory(); + cleanArgs += (*it)->GetCurrentBinaryDirectory(); cleanArgs += "\" \""; cleanArgs += cmSystemTools::GetCMakeCommand(); cleanArgs += "\" -P \""; @@ -1151,8 +1152,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const fout << "</cconfiguration>\n" "</storageModule>\n" "<storageModule moduleId=\"cdtBuildSystem\" version=\"4.0.0\">\n" - "<project id=\"" << this->EscapeForXML(mf->GetProjectName()) - << ".null.1\" name=\"" << this->EscapeForXML(mf->GetProjectName()) + "<project id=\"" << this->EscapeForXML(lg->GetProjectName()) + << ".null.1\" name=\"" << this->EscapeForXML(lg->GetProjectName()) << "\"/>\n" "</storageModule>\n" "</cproject>\n" diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index ef99760..16675f2 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -100,7 +100,7 @@ private: std::set<std::string>& emittedDirs); static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar, - cmMakefile* mf); + cmLocalGenerator* lg); void CreateLinksToSubprojects(cmGeneratedFileStream& fout, const std::string& baseDir); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index f83b5cf..fe77026 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -46,21 +46,22 @@ cmExtraKateGenerator::cmExtraKateGenerator() void cmExtraKateGenerator::Generate() { - const cmMakefile* mf - = this->GlobalGenerator->GetLocalGenerators()[0]->GetMakefile(); - this->ProjectName = this->GenerateProjectName(mf->GetProjectName(), + cmLocalGenerator* lg = this->GlobalGenerator->GetLocalGenerators()[0]; + const cmMakefile* mf = lg->GetMakefile(); + this->ProjectName = this->GenerateProjectName(lg->GetProjectName(), mf->GetSafeDefinition("CMAKE_BUILD_TYPE"), - this->GetPathBasename(mf->GetHomeOutputDirectory())); + this->GetPathBasename(lg->GetBinaryDirectory())); this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja"); - this->CreateKateProjectFile(mf); - this->CreateDummyKateProjectFile(mf); + this->CreateKateProjectFile(lg); + this->CreateDummyKateProjectFile(lg); } -void cmExtraKateGenerator::CreateKateProjectFile(const cmMakefile* mf) const +void cmExtraKateGenerator::CreateKateProjectFile( + const cmLocalGenerator* lg) const { - std::string filename = mf->GetHomeOutputDirectory(); + std::string filename = lg->GetBinaryDirectory(); filename += "/.kateproject"; cmGeneratedFileStream fout(filename.c_str()); if (!fout) @@ -68,31 +69,29 @@ void cmExtraKateGenerator::CreateKateProjectFile(const cmMakefile* mf) const return; } - std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - std::string args = mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); - fout << "{\n" "\t\"name\": \"" << this->ProjectName << "\",\n" - "\t\"directory\": \"" << mf->GetHomeDirectory() << "\",\n" - "\t\"files\": [ { " << this->GenerateFilesString(mf) << "} ],\n"; - this->WriteTargets(mf, fout); + "\t\"directory\": \"" << lg->GetSourceDirectory() << "\",\n" + "\t\"files\": [ { " << this->GenerateFilesString(lg) << "} ],\n"; + this->WriteTargets(lg, fout); fout << "}\n"; } void -cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, +cmExtraKateGenerator::WriteTargets(const cmLocalGenerator* lg, cmGeneratedFileStream& fout) const { + cmMakefile const* mf = lg->GetMakefile(); const std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); const std::string makeArgs = mf->GetSafeDefinition( "CMAKE_KATE_MAKE_ARGUMENTS"); - const char* homeOutputDir = mf->GetHomeOutputDirectory(); + const char* homeOutputDir = lg->GetBinaryDirectory(); fout << "\t\"build\": {\n" - "\t\t\"directory\": \"" << mf->GetHomeOutputDirectory() << "\",\n" + "\t\t\"directory\": \"" << lg->GetBinaryDirectory() << "\",\n" "\t\t\"default_target\": \"all\",\n" "\t\t\"clean_target\": \"clean\",\n"; @@ -122,8 +121,8 @@ cmExtraKateGenerator::WriteTargets(const cmMakefile* mf, { const cmTargets& targets = (*it)->GetMakefile()->GetTargets(); cmMakefile* makefile=(*it)->GetMakefile(); - std::string currentDir = makefile->GetCurrentBinaryDirectory(); - bool topLevel = (currentDir == makefile->GetHomeOutputDirectory()); + std::string currentDir = (*it)->GetCurrentBinaryDirectory(); + bool topLevel = (currentDir == (*it)->GetBinaryDirectory()); for(cmTargets::const_iterator ti=targets.begin(); ti!=targets.end(); ++ti) { @@ -234,9 +233,10 @@ cmExtraKateGenerator::AppendTarget(cmGeneratedFileStream& fout, void -cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const +cmExtraKateGenerator::CreateDummyKateProjectFile( + const cmLocalGenerator* lg) const { - std::string filename = mf->GetHomeOutputDirectory(); + std::string filename = lg->GetBinaryDirectory(); filename += "/"; filename += this->ProjectName; filename += ".kateproject"; @@ -252,23 +252,23 @@ cmExtraKateGenerator::CreateDummyKateProjectFile(const cmMakefile* mf) const std::string -cmExtraKateGenerator::GenerateFilesString(const cmMakefile* mf) const +cmExtraKateGenerator::GenerateFilesString(const cmLocalGenerator* lg) const { - std::string s = mf->GetHomeDirectory(); + std::string s = lg->GetSourceDirectory(); s += "/.git"; if(cmSystemTools::FileExists(s.c_str())) { return std::string("\"git\": 1 "); } - s = mf->GetHomeDirectory(); + s = lg->GetSourceDirectory(); s += "/.svn"; if(cmSystemTools::FileExists(s.c_str())) { return std::string("\"svn\": 1 "); } - s = mf->GetHomeDirectory(); + s = lg->GetSourceDirectory(); s += "/"; std::set<std::string> files; diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h index f800feb..b20d0a7 100644 --- a/Source/cmExtraKateGenerator.h +++ b/Source/cmExtraKateGenerator.h @@ -39,9 +39,10 @@ public: virtual void Generate(); private: - void CreateKateProjectFile(const cmMakefile* mf) const; - void CreateDummyKateProjectFile(const cmMakefile* mf) const; - void WriteTargets(const cmMakefile* mf, cmGeneratedFileStream& fout) const; + void CreateKateProjectFile(const cmLocalGenerator* lg) const; + void CreateDummyKateProjectFile(const cmLocalGenerator* lg) const; + void WriteTargets(const cmLocalGenerator* lg, + cmGeneratedFileStream& fout) const; void AppendTarget(cmGeneratedFileStream& fout, const std::string& target, const std::string& make, @@ -49,7 +50,7 @@ private: const std::string& path, const char* homeOutputDir) const; - std::string GenerateFilesString(const cmMakefile* mf) const; + std::string GenerateFilesString(const cmLocalGenerator* lg) const; std::string GetPathBasename(const std::string& path) const; std::string GenerateProjectName(const std::string& name, const std::string& type, diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 11410a7..6306360 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -77,9 +77,8 @@ void cmExtraSublimeTextGenerator::Generate() void cmExtraSublimeTextGenerator::CreateProjectFile( const std::vector<cmLocalGenerator*>& lgs) { - const cmMakefile* mf=lgs[0]->GetMakefile(); - std::string outputDir=mf->GetCurrentBinaryDirectory(); - std::string projectName=mf->GetProjectName(); + std::string outputDir=lgs[0]->GetCurrentBinaryDirectory(); + std::string projectName=lgs[0]->GetProjectName(); const std::string filename = outputDir + "/" + projectName + ".sublime-project"; @@ -99,8 +98,8 @@ void cmExtraSublimeTextGenerator } const std::string &sourceRootRelativeToOutput = cmSystemTools::RelativePath( - mf->GetHomeOutputDirectory(), - mf->GetHomeDirectory()); + lgs[0]->GetBinaryDirectory(), + lgs[0]->GetSourceDirectory()); // Write the folder entries to the project file fout << "{\n"; fout << "\t\"folders\":\n\t[\n\t"; @@ -108,8 +107,8 @@ void cmExtraSublimeTextGenerator { fout << "\t{\n\t\t\t\"path\": \"" << sourceRootRelativeToOutput << "\""; const std::string &outputRelativeToSourceRoot = - cmSystemTools::RelativePath(mf->GetHomeDirectory(), - mf->GetHomeOutputDirectory()); + cmSystemTools::RelativePath(lgs[0]->GetSourceDirectory(), + lgs[0]->GetBinaryDirectory()); if ((!outputRelativeToSourceRoot.empty()) && ((outputRelativeToSourceRoot.length() < 3) || (outputRelativeToSourceRoot.substr(0, 3) != "../"))) @@ -173,8 +172,8 @@ void cmExtraSublimeTextGenerator:: { // Only add the global targets from CMAKE_BINARY_DIR, // not from the subdirs - if (strcmp(makefile->GetCurrentBinaryDirectory(), - makefile->GetHomeOutputDirectory())==0) + if (strcmp((*lg)->GetCurrentBinaryDirectory(), + (*lg)->GetBinaryDirectory())==0) { this->AppendTarget(fout, ti->first, *lg, 0, make.c_str(), makefile, compiler.c_str(), @@ -302,7 +301,7 @@ void cmExtraSublimeTextGenerator:: { fout << ",\n\t"; } - fout << "\t{\n\t\t\t\"name\": \"" << makefile->GetProjectName() << " - " << + fout << "\t{\n\t\t\t\"name\": \"" << lg->GetProjectName() << " - " << targetName << "\",\n"; fout << "\t\t\t\"cmd\": [" << this->BuildMakeCommand(make, makefileName.c_str(), targetName) << diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx index 13e2a66..279b61d 100644 --- a/Source/cmFileTimeComparison.cxx +++ b/Source/cmFileTimeComparison.cxx @@ -148,7 +148,7 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1, cmFileTimeComparison_Type* s2) { #if !defined(_WIN32) || defined(__CYGWIN__) -# if cmsys_STAT_HAS_ST_MTIM +# if CMake_STAT_HAS_ST_MTIM // Compare using nanosecond resolution. if(s1->st_mtim.tv_sec < s2->st_mtim.tv_sec) { @@ -166,6 +166,24 @@ int cmFileTimeComparisonInternal::Compare(cmFileTimeComparison_Type* s1, { return 1; } +# elif CMake_STAT_HAS_ST_MTIMESPEC + // Compare using nanosecond resolution. + if(s1->st_mtimespec.tv_sec < s2->st_mtimespec.tv_sec) + { + return -1; + } + else if(s1->st_mtimespec.tv_sec > s2->st_mtimespec.tv_sec) + { + return 1; + } + else if(s1->st_mtimespec.tv_nsec < s2->st_mtimespec.tv_nsec) + { + return -1; + } + else if(s1->st_mtimespec.tv_nsec > s2->st_mtimespec.tv_nsec) + { + return 1; + } # else // Compare using 1 second resolution. if(s1->st_mtime < s2->st_mtime) @@ -190,7 +208,7 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1, cmFileTimeComparison_Type* s2) { #if !defined(_WIN32) || defined(__CYGWIN__) -# if cmsys_STAT_HAS_ST_MTIM +# if CMake_STAT_HAS_ST_MTIM // Times are integers in units of 1ns. long long bil = 1000000000; long long t1 = s1->st_mtim.tv_sec * bil + s1->st_mtim.tv_nsec; @@ -207,6 +225,23 @@ bool cmFileTimeComparisonInternal::TimesDiffer(cmFileTimeComparison_Type* s1, { return false; } +# elif CMake_STAT_HAS_ST_MTIMESPEC + // Times are integers in units of 1ns. + long long bil = 1000000000; + long long t1 = s1->st_mtimespec.tv_sec * bil + s1->st_mtimespec.tv_nsec; + long long t2 = s2->st_mtimespec.tv_sec * bil + s2->st_mtimespec.tv_nsec; + if(t1 < t2) + { + return (t2 - t1) >= bil; + } + else if(t2 < t1) + { + return (t1 - t2) >= bil; + } + else + { + return false; + } # else // Times are integers in units of 1s. if(s1->st_mtime < s2->st_mtime) diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx index e4d9f10..8ac5cbc 100644 --- a/Source/cmGeneratorExpressionEvaluationFile.cxx +++ b/Source/cmGeneratorExpressionEvaluationFile.cxx @@ -139,7 +139,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(cmLocalGenerator *lg) { std::ostringstream e; e << "Evaluation file \"" << this->Input << "\" cannot be read."; - lg->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + lg->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f39a67d..f3d34e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -437,7 +437,7 @@ std::string cmGeneratorTarget::GetOutputName(const std::string& config, for(std::vector<std::string>::const_iterator it = props.begin(); it != props.end(); ++it) { - if (const char* outNameProp = this->Target->GetProperty(*it)) + if (const char* outNameProp = this->GetProperty(*it)) { outName = outNameProp; break; @@ -612,12 +612,12 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature, std::string featureConfig = feature; featureConfig += "_"; featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->Target->GetProperty(featureConfig)) + if(const char* value = this->GetProperty(featureConfig)) { return value; } } - if(const char* value = this->Target->GetProperty(feature)) + if(const char* value = this->GetProperty(feature)) { return value; } @@ -850,7 +850,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, "SYSTEM_INCLUDE_DIRECTORIES", 0, 0); bool excludeImported - = this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); + = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED"); std::vector<std::string> result; for (std::set<std::string>::const_iterator @@ -1163,13 +1163,13 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string configUpper = cmSystemTools::UpperCase(config); std::string configProp = "COMPILE_PDB_NAME_"; configProp += configUpper; - const char* config_name = this->Target->GetProperty(configProp); + const char* config_name = this->GetProperty(configProp); if(config_name && *config_name) { return prefix + config_name + ".pdb"; } - const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + const char* name = this->GetProperty("COMPILE_PDB_NAME"); if(name && *name) { return prefix + name + ".pdb"; @@ -1541,7 +1541,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, std::string fpath; fpath += this->GetOutputName(config, false); fpath += "."; - const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + const char *ext = this->GetProperty("BUNDLE_EXTENSION"); if (!ext) { if (this->Target->IsXCTestOnApple()) @@ -2461,11 +2461,11 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, { std::string defVarName = "OSX_ARCHITECTURES_"; defVarName += cmSystemTools::UpperCase(config); - archs = this->Target->GetProperty(defVarName); + archs = this->GetProperty(defVarName); } if(!archs) { - archs = this->Target->GetProperty("OSX_ARCHITECTURES"); + archs = this->GetProperty("OSX_ARCHITECTURES"); } if(archs) { @@ -2968,7 +2968,7 @@ void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list, { std::string configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); - const char *configProp = this->Target->GetProperty(configPropName); + const char *configProp = this->GetProperty(configPropName); if (configProp) { switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) @@ -3552,7 +3552,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const this->SourceFileFlagsConstructed = true; // Process public headers to mark the source files. - if(const char* files = this->Target->GetProperty("PUBLIC_HEADER")) + if(const char* files = this->GetProperty("PUBLIC_HEADER")) { std::vector<std::string> relFiles; cmSystemTools::ExpandListArgument(files, relFiles); @@ -3570,7 +3570,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const // Process private headers after public headers so that they take // precedence if a file is listed in both. - if(const char* files = this->Target->GetProperty("PRIVATE_HEADER")) + if(const char* files = this->GetProperty("PRIVATE_HEADER")) { std::vector<std::string> relFiles; cmSystemTools::ExpandListArgument(files, relFiles); @@ -3587,7 +3587,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } // Mark sources listed as resources. - if(const char* files = this->Target->GetProperty("RESOURCE")) + if(const char* files = this->GetProperty("RESOURCE")) { std::vector<std::string> relFiles; cmSystemTools::ExpandListArgument(files, relFiles); @@ -5246,7 +5246,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages( //---------------------------------------------------------------------------- bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const { - if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH")) + if (this->GetPropertyAsBool("SKIP_BUILD_RPATH")) { return false; } diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index bfcef43..79e3a4c 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -68,7 +68,9 @@ cmGhsMultiTargetGenerator::GetRelBuildFilePath(const cmTarget *target) std::string cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmTarget *target) { - return target->GetMakefile()->GetHomeOutputDirectory(); + cmGeneratorTarget* gt = target->GetMakefile()->GetGlobalGenerator() + ->GetGeneratorTarget(target); + return gt->GetLocalGenerator()->GetBinaryDirectory(); } std::string @@ -450,7 +452,7 @@ void cmGhsMultiTargetGenerator::WriteSources( cmSystemTools::ConvertToUnixSlashes(sgPath); cmGlobalGhsMultiGenerator::AddFilesUpToPath( this->GetFolderBuildStreams(), &this->FolderBuildStreams, - this->Makefile->GetHomeOutputDirectory(), sgPath, + this->LocalGenerator->GetBinaryDirectory(), sgPath, GhsMultiGpj::SUBPROJECT, this->RelBuildFilePath); std::string fullSourcePath((*si)->GetFullPath()); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index eb4dfee..765a538 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -399,7 +399,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, bool fatalError = false; mf->AddDefinition("RUN_CONFIGURE", true); - std::string rootBin = mf->GetHomeOutputDirectory(); + std::string rootBin = this->CMakeInstance->GetHomeOutputDirectory(); rootBin += cmake::GetCMakeFilesDirectory(); // If the configuration files path has been set, @@ -2033,7 +2033,7 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const { if(target->GetType() == cmTarget::INTERFACE_LIBRARY - || target->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + || target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This target is excluded from its directory. return true; @@ -2105,7 +2105,7 @@ cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const for(std::vector<cmLocalGenerator*>::const_iterator it = this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it) { - std::string sd = (*it)->GetMakefile()->GetCurrentSourceDirectory(); + std::string sd = (*it)->GetCurrentSourceDirectory(); if (sd == start_dir) { return *it; @@ -2879,10 +2879,8 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile) //---------------------------------------------------------------------------- void cmGlobalGenerator::WriteSummary() { - cmMakefile* mf = this->LocalGenerators[0]->GetMakefile(); - // Record all target directories in a central location. - std::string fname = mf->GetHomeOutputDirectory(); + std::string fname = this->CMakeInstance->GetHomeOutputDirectory(); fname += cmake::GetCMakeFilesDirectory(); fname += "/TargetDirectories.txt"; cmGeneratedFileStream fout(fname.c_str()); diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index c40f846..f955ef7 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -49,10 +49,9 @@ void cmGlobalKdevelopGenerator::Generate() it!= this->GlobalGenerator->GetProjectMap().end(); ++it) { - cmMakefile* mf = it->second[0]->GetMakefile(); - std::string outputDir=mf->GetCurrentBinaryDirectory(); - std::string projectDir=mf->GetHomeDirectory(); - std::string projectName=mf->GetProjectName(); + std::string outputDir=it->second[0]->GetCurrentBinaryDirectory(); + std::string projectDir=it->second[0]->GetSourceDirectory(); + std::string projectName=it->second[0]->GetProjectName(); std::string cmakeFilePattern("CMakeLists.txt;*.cmake;"); std::string fileToOpen; const std::vector<cmLocalGenerator*>& lgs= it->second; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 9d8193b..32e6077 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1198,16 +1198,15 @@ void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os) void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) { cmLocalGenerator *lg = this->LocalGenerators[0]; - cmMakefile* mfRoot = lg->GetMakefile(); std::ostringstream cmd; cmd << lg->ConvertToOutputFormat(cmSystemTools::GetCMakeCommand(), cmLocalGenerator::SHELL) << " -H" - << lg->ConvertToOutputFormat(mfRoot->GetHomeDirectory(), + << lg->ConvertToOutputFormat(lg->GetSourceDirectory(), cmLocalGenerator::SHELL) << " -B" - << lg->ConvertToOutputFormat(mfRoot->GetHomeOutputDirectory(), + << lg->ConvertToOutputFormat(lg->GetBinaryDirectory(), cmLocalGenerator::SHELL); WriteRule(*this->RulesFileStream, "RERUN_CMAKE", diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index cb13fcf..218e702 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -163,7 +163,7 @@ void cmGlobalUnixMakefileGenerator3::Generate() { cmLocalUnixMakefileGenerator3 *lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]); - std::string markFileName = lg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string markFileName = lg->GetCurrentBinaryDirectory(); markFileName += "/"; markFileName += cmake::GetCMakeFilesDirectory(); markFileName += "/progress.marks"; @@ -395,7 +395,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() { lg = static_cast<cmLocalUnixMakefileGenerator3 *>(this->LocalGenerators[i]); - tmpStr = lg->GetMakefile()->GetCurrentBinaryDirectory(); + tmpStr = lg->GetCurrentBinaryDirectory(); tmpStr += cmake::GetCMakeFilesDirectory(); tmpStr += "/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << @@ -454,7 +454,7 @@ cmGlobalUnixMakefileGenerator3 bool check_relink) { // Get the relative path to the subdirectory from the top. - std::string makeTarget = lg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string makeTarget = lg->GetCurrentBinaryDirectory(); makeTarget += "/"; makeTarget += pass; @@ -495,7 +495,7 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the directory-level // rules of the subdirectories. std::vector<cmState::Snapshot> children - = lg->GetMakefile()->GetStateSnapshot().GetChildren(); + = lg->GetStateSnapshot().GetChildren(); for(std::vector<cmState::Snapshot>::const_iterator ci = children.begin(); ci != children.end(); ++ci) { @@ -534,7 +534,7 @@ cmGlobalUnixMakefileGenerator3 } // Begin the directory-level rules section. - std::string dir = lg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string dir = lg->GetCurrentBinaryDirectory(); dir = lg->Convert(dir, cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKERULE); lg->WriteDivider(ruleFileStream); @@ -784,7 +784,7 @@ cmGlobalUnixMakefileGenerator3 depends.clear(); cmLocalUnixMakefileGenerator3::EchoProgress progress; - progress.Dir = lg->GetMakefile()->GetHomeOutputDirectory(); + progress.Dir = lg->GetBinaryDirectory(); progress.Dir += cmake::GetCMakeFilesDirectory(); { std::ostringstream progressArg; @@ -937,7 +937,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() cmLocalGenerator* tlg = gt->GetLocalGenerator(); if(gt->GetType() == cmTarget::INTERFACE_LIBRARY - || gt->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + || gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { continue; } diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index 14de698..d5e9417 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -260,7 +260,7 @@ void cmGlobalVisualStudio6Generator } std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory(); fname += "/"; - fname += root->GetMakefile()->GetProjectName(); + fname += root->GetProjectName(); fname += ".dsw"; cmsys::ofstream fout(fname.c_str()); if(!fout) diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 05da022..f4166b9 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -362,10 +362,10 @@ void cmGlobalVisualStudio7Generator { return; } - this->CurrentProject = root->GetMakefile()->GetProjectName(); - std::string fname = root->GetMakefile()->GetCurrentBinaryDirectory(); + this->CurrentProject = root->GetProjectName(); + std::string fname = root->GetCurrentBinaryDirectory(); fname += "/"; - fname += root->GetMakefile()->GetProjectName(); + fname += root->GetProjectName(); fname += ".sln"; cmGeneratedFileStream fout(fname.c_str()); fout.SetCopyIfDifferent(true); @@ -468,8 +468,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( target->GetProperty("GENERATOR_FILE_NAME"); if(vcprojName) { - cmMakefile* tmf = target->GetMakefile(); - std::string dir = tmf->GetCurrentBinaryDirectory(); + cmLocalGenerator* lg = + root->GetGlobalGenerator()->GetGeneratorTarget(target) + ->GetLocalGenerator(); + std::string dir = lg->GetCurrentBinaryDirectory(); dir = root->Convert(dir.c_str(), cmLocalGenerator::START_OUTPUT); if(dir == ".") diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index ab9d7e7..0bdb008 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -312,10 +312,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); std::string argH = "-H"; - argH += mf->GetHomeDirectory(); + argH += lg->GetSourceDirectory(); commandLine.push_back(argH); std::string argB = "-B"; - argB += mf->GetHomeOutputDirectory(); + argB += lg->GetBinaryDirectory(); commandLine.push_back(argB); commandLine.push_back("--check-stamp-list"); commandLine.push_back(stampList.c_str()); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index d45aa27..6a25ed0 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -250,7 +250,7 @@ cmGlobalVisualStudioGenerator { topLevelSlnName = mf->GetCurrentBinaryDirectory(); topLevelSlnName += "/"; - topLevelSlnName += mf->GetProjectName(); + topLevelSlnName += this->LocalGenerators[0]->GetProjectName(); topLevelSlnName += ".sln"; } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0370d74..2d9a14b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -410,15 +410,17 @@ void cmGlobalXCodeGenerator::Generate() //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root) { - this->CurrentProject = root->GetMakefile()->GetProjectName(); + this->CurrentProject = root->GetProjectName(); this->SetCurrentLocalGenerator(root); - cmSystemTools::SplitPath(this->CurrentMakefile->GetCurrentSourceDirectory(), - this->ProjectSourceDirectoryComponents); - cmSystemTools::SplitPath(this->CurrentMakefile->GetCurrentBinaryDirectory(), - this->ProjectOutputDirectoryComponents); + cmSystemTools::SplitPath( + this->CurrentLocalGenerator->GetCurrentSourceDirectory(), + this->ProjectSourceDirectoryComponents); + cmSystemTools::SplitPath( + this->CurrentLocalGenerator->GetCurrentBinaryDirectory(), + this->ProjectOutputDirectoryComponents); this->CurrentXCodeHackMakefile = - root->GetMakefile()->GetCurrentBinaryDirectory(); + root->GetCurrentBinaryDirectory(); this->CurrentXCodeHackMakefile += "/CMakeScripts"; cmSystemTools::MakeDirectory(this->CurrentXCodeHackMakefile.c_str()); this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make"; @@ -460,13 +462,13 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, mf->AddGeneratorTarget(allbuild, allBuildGt); // Refer to the main build configuration file for easy editing. - std::string listfile = mf->GetCurrentSourceDirectory(); + std::string listfile = root->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; allBuildGt->AddSource(listfile.c_str()); // Add XCODE depend helper - std::string dir = mf->GetCurrentBinaryDirectory(); + std::string dir = root->GetCurrentBinaryDirectory(); cmCustomCommandLine makeHelper; if(this->XcodeVersion < 50) { @@ -556,7 +558,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmGeneratorTarget* targetGT = this->GetGeneratorTarget(&target); // Refer to the build configuration file for easy editing. - listfile = lg->GetMakefile()->GetCurrentSourceDirectory(); + listfile = lg->GetCurrentSourceDirectory(); listfile += "/"; listfile += "CMakeLists.txt"; targetGT->AddSource(listfile.c_str()); @@ -568,7 +570,6 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, void cmGlobalXCodeGenerator::CreateReRunCMakeFile( cmLocalGenerator* root, std::vector<cmLocalGenerator*> const& gens) { - cmMakefile* mf = root->GetMakefile(); std::vector<std::string> lfiles; for(std::vector<cmLocalGenerator*>::const_iterator gi = gens.begin(); gi != gens.end(); ++gi) @@ -582,7 +583,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( std::vector<std::string>::iterator new_end = std::unique(lfiles.begin(), lfiles.end()); lfiles.erase(new_end, lfiles.end()); - this->CurrentReRunCMakeMakefile = mf->GetCurrentBinaryDirectory(); + this->CurrentReRunCMakeMakefile = root->GetCurrentBinaryDirectory(); this->CurrentReRunCMakeMakefile += "/CMakeScripts"; cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str()); this->CurrentReRunCMakeMakefile += "/ReRunCMake.make"; @@ -590,7 +591,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( (this->CurrentReRunCMakeMakefile.c_str()); makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n"; - std::string checkCache = mf->GetHomeOutputDirectory(); + std::string checkCache = root->GetBinaryDirectory(); checkCache += "/"; checkCache += cmake::GetCMakeFilesDirectoryPostSlash(); checkCache += "cmake.check_cache"; @@ -604,9 +605,9 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str()) << " -H" << this->ConvertToRelativeForMake( - mf->GetHomeDirectory()) + root->GetSourceDirectory()) << " -B" << this->ConvertToRelativeForMake( - mf->GetHomeOutputDirectory()) << "\n"; + root->GetBinaryDirectory()) << "\n"; } //---------------------------------------------------------------------------- @@ -1033,7 +1034,7 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) this->CurrentLocalGenerator = gen; this->CurrentMakefile = gen->GetMakefile(); std::string outdir = - cmSystemTools::CollapseFullPath(this->CurrentMakefile-> + cmSystemTools::CollapseFullPath(this->CurrentLocalGenerator-> GetCurrentBinaryDirectory()); cmSystemTools::SplitPath(outdir.c_str(), this->CurrentOutputDirectoryComponents); @@ -1389,7 +1390,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) // linker language. This should convince Xcode to choose the proper // language. cmMakefile* mf = cmtarget.GetMakefile(); - std::string fname = mf->GetCurrentBinaryDirectory(); + std::string fname = gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(); fname += cmake::GetCMakeFilesDirectory(); fname += "/"; fname += cmtarget.GetName(); @@ -1618,7 +1619,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, const & commands, const char* name) { - std::string dir = this->CurrentMakefile->GetCurrentBinaryDirectory(); + std::string dir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); dir += "/CMakeScripts"; cmSystemTools::MakeDirectory(dir.c_str()); std::string makefile = dir; @@ -1639,7 +1640,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, currentConfig->c_str()); } - std::string cdir = this->CurrentMakefile->GetCurrentBinaryDirectory(); + std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); cdir = this->ConvertToRelativeForXCode(cdir.c_str()); std::string makecmd = "make -C "; makecmd += cdir; @@ -1967,7 +1968,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } // Set attributes to specify the proper name for the target. - std::string pndir = this->CurrentMakefile->GetCurrentBinaryDirectory(); + std::string pndir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory(); if(target.GetType() == cmTarget::STATIC_LIBRARY || target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY || @@ -3342,7 +3343,7 @@ bool cmGlobalXCodeGenerator this->RootObject->SetComment("Project object"); std::string project_id = "PROJECT_"; - project_id += root->GetMakefile()->GetProjectName(); + project_id += root->GetProjectName(); this->RootObject->SetId(this->GetOrCreateId( project_id.c_str(), this->RootObject->GetId()).c_str()); @@ -3372,7 +3373,7 @@ bool cmGlobalXCodeGenerator // Point Xcode at the top of the source tree. { std::string pdir = - this->RelativeToBinary(root->GetMakefile()->GetCurrentSourceDirectory()); + this->RelativeToBinary(root->GetCurrentSourceDirectory()); this->RootObject->AddAttribute("projectDirPath", this->CreateString(pdir.c_str())); this->RootObject->AddAttribute("projectRoot", this->CreateString("")); @@ -3484,7 +3485,7 @@ bool cmGlobalXCodeGenerator } } - std::string symroot = root->GetMakefile()->GetCurrentBinaryDirectory(); + std::string symroot = root->GetCurrentBinaryDirectory(); symroot += "/build"; buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot.c_str())); @@ -3727,9 +3728,9 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, { return; } - std::string xcodeDir = root->GetMakefile()->GetCurrentBinaryDirectory(); + std::string xcodeDir = root->GetCurrentBinaryDirectory(); xcodeDir += "/"; - xcodeDir += root->GetMakefile()->GetProjectName(); + xcodeDir += root->GetProjectName(); xcodeDir += ".xcode"; if(this->XcodeVersion > 20) { @@ -3749,7 +3750,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, // Since this call may have created new cache entries, save the cache: // root->GetMakefile()->GetCMakeInstance()->SaveCache( - root->GetMakefile()->GetHomeOutputDirectory()); + root->GetBinaryDirectory()); } //---------------------------------------------------------------------------- diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 97b9405..f7c9cc2 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -64,7 +64,7 @@ void cmInstallExportGenerator::ComputeTempDir() // Choose a temporary directory in which to generate the import // files to be installed. this->TempDir = - this->LocalGenerator->GetMakefile()->GetCurrentBinaryDirectory(); + this->LocalGenerator->GetCurrentBinaryDirectory(); this->TempDir += cmake::GetCMakeFilesDirectory(); this->TempDir += "/Export"; if(this->Destination.empty()) diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 383ee00..2ea36fb 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -823,7 +823,7 @@ cmInstallTargetGenerator::AddStripRule(std::ostream& os, // Don't handle OSX Bundles. if(this->Target->Target->GetMakefile()->IsOn("APPLE") && - this->Target->Target->GetPropertyAsBool("MACOSX_BUNDLE")) + this->Target->GetPropertyAsBool("MACOSX_BUNDLE")) { return; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 06eb004..f19d551 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2431,6 +2431,11 @@ const char* cmLocalGenerator::GetFeature(const std::string& feature, return 0; } +std::string cmLocalGenerator::GetProjectName() const +{ + return this->StateSnapshot.GetProjectName(); +} + //---------------------------------------------------------------------------- std::string cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg, @@ -2863,6 +2868,26 @@ cmake* cmLocalGenerator::GetCMakeInstance() const return this->GlobalGenerator->GetCMakeInstance(); } +const char* cmLocalGenerator::GetSourceDirectory() const +{ + return this->GetCMakeInstance()->GetHomeDirectory(); +} + +const char* cmLocalGenerator::GetBinaryDirectory() const +{ + return this->GetCMakeInstance()->GetHomeOutputDirectory(); +} + +const char* cmLocalGenerator::GetCurrentBinaryDirectory() const +{ + return this->StateSnapshot.GetDirectory().GetCurrentBinary(); +} + +const char* cmLocalGenerator::GetCurrentSourceDirectory() const +{ + return this->StateSnapshot.GetDirectory().GetCurrentSource(); +} + //---------------------------------------------------------------------------- std::string cmLocalGenerator::GetTargetDirectory(cmTarget const&) const diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index d9623cb..758709a 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -182,12 +182,14 @@ public: const std::string& config, const std::string& lang); + std::string GetProjectName() const; + /** Compute the language used to compile the given source file. */ std::string GetSourceFileLanguage(const cmSourceFile& source); // Fill the vector with the target names for the object files, // preprocessed files and assembly files. - virtual void GetIndividualFileTargets(std::vector<std::string>&) {} + void GetIndividualFileTargets(std::vector<std::string>&) {} // Create a struct to hold the varibles passed into // ExpandRuleVariables @@ -253,6 +255,12 @@ public: cmake* GetCMakeInstance() const; + const char* GetSourceDirectory() const; + const char* GetBinaryDirectory() const; + + const char* GetCurrentBinaryDirectory() const; + const char* GetCurrentSourceDirectory() const; + /** * Generate a Mac OS X application bundle Info.plist file. */ diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index c46adc1..6319f0e 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -183,7 +183,7 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); os - << "# Project: " << this->GetMakefile()->GetProjectName() << std::endl + << "# Project: " << this->GetProjectName() << std::endl << "# Configuration: " << this->ConfigName << std::endl ; cmGlobalNinjaGenerator::WriteDivider(os); @@ -363,7 +363,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines( if (ccg.GetNumberOfCommands() > 0) { std::string wd = ccg.GetWorkingDirectory(); if (wd.empty()) - wd = this->GetMakefile()->GetCurrentBinaryDirectory(); + wd = this->GetCurrentBinaryDirectory(); std::ostringstream cdCmd; #ifdef _WIN32 diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index b131a63..bf5afc1 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -399,7 +399,7 @@ cmLocalUnixMakefileGenerator3 ); } this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); // Write the rule to the makefile. @@ -449,7 +449,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall (makefile2.c_str(),localName)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", localName, depends, commands, true); @@ -478,7 +478,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall (makefileName.c_str(), makeTargetName)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "fast build rule for target.", localName, depends, commands, true); @@ -496,7 +496,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall (makefile2.c_str(), makeTargetName)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Manual pre-install relink rule for target.", @@ -750,13 +750,13 @@ cmLocalUnixMakefileGenerator3 makefileStream << "# The top-level source directory on which CMake was run.\n" << "CMAKE_SOURCE_DIR = " - << this->Convert(this->Makefile->GetHomeDirectory(), FULL, SHELL) + << this->Convert(this->GetSourceDirectory(), FULL, SHELL) << "\n" << "\n"; makefileStream << "# The top-level build directory on which CMake was run.\n" << "CMAKE_BINARY_DIR = " - << this->Convert(this->Makefile->GetHomeOutputDirectory(), FULL, SHELL) + << this->Convert(this->GetBinaryDirectory(), FULL, SHELL) << "\n" << "\n"; } @@ -889,7 +889,7 @@ void cmLocalUnixMakefileGenerator3 if(!this->GetMakefile()->IsRootMakefile()) { this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); } this->WriteMakeRule(makefileStream, @@ -1838,7 +1838,7 @@ void cmLocalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); - std::string progressDir = this->Makefile->GetHomeOutputDirectory(); + std::string progressDir = this->GetBinaryDirectory(); progressDir += cmake::GetCMakeFilesDirectory(); { std::ostringstream progCmd; @@ -1862,7 +1862,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); { std::ostringstream progCmd; @@ -1884,7 +1884,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "The main clean target", "clean", depends, commands, true); @@ -1914,7 +1914,7 @@ void cmLocalUnixMakefileGenerator3 commands.push_back (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget)); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "Prepare targets for installation.", "preinstall", depends, commands, true); @@ -1935,7 +1935,7 @@ void cmLocalUnixMakefileGenerator3 runRule += " 1"; commands.push_back(runRule); this->CreateCDCommand(commands, - this->Makefile->GetHomeOutputDirectory(), + this->GetBinaryDirectory(), cmLocalGenerator::START_OUTPUT); this->WriteMakeRule(ruleFileStream, "clear depends", "depend", diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 862ab2d..6ecd9a8 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -111,14 +111,14 @@ void cmLocalVisualStudio6Generator::Generate() void cmLocalVisualStudio6Generator::OutputDSPFile() { // If not an in source build, then create the output directory - if(strcmp(this->Makefile->GetCurrentBinaryDirectory(), - this->Makefile->GetHomeDirectory()) != 0) + if(strcmp(this->GetCurrentBinaryDirectory(), + this->GetSourceDirectory()) != 0) { if(!cmSystemTools::MakeDirectory - (this->Makefile->GetCurrentBinaryDirectory())) + (this->GetCurrentBinaryDirectory())) { cmSystemTools::Error("Error creating directory ", - this->Makefile->GetCurrentBinaryDirectory()); + this->GetCurrentBinaryDirectory()); } } @@ -163,7 +163,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile() std::string::size_type pos = l->first.rfind('/'); if(pos != std::string::npos) { - std::string dir = this->Makefile->GetCurrentBinaryDirectory(); + std::string dir = this->GetCurrentBinaryDirectory(); dir += "/"; dir += l->first.substr(0, pos); if(!cmSystemTools::MakeDirectory(dir.c_str())) @@ -189,7 +189,7 @@ void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname, // create the dsp.cmake file std::string fname; - fname = this->Makefile->GetCurrentBinaryDirectory(); + fname = this->GetCurrentBinaryDirectory(); fname += "/"; fname += pname; fname += ".dsp"; @@ -215,7 +215,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) dspname += ".dsp.cmake"; cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); - std::string makefileIn = this->Makefile->GetCurrentSourceDirectory(); + std::string makefileIn = this->GetCurrentSourceDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; if(!cmSystemTools::FileExists(makefileIn.c_str())) @@ -226,10 +226,10 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt) comment += makefileIn; std::string args; args = "-H"; - args += this->Makefile->GetHomeDirectory(); + args += this->GetSourceDirectory(); commandLine.push_back(args); args = "-B"; - args += this->Makefile->GetHomeOutputDirectory(); + args += this->GetBinaryDirectory(); commandLine.push_back(args); std::vector<std::string> const& listFiles = this->Makefile->GetListFiles(); @@ -578,9 +578,9 @@ cmLocalVisualStudio6Generator const cmCustomCommand& origCommand) { // Create a fake output that forces the rule to run. - char* output = new char[(strlen(this->Makefile->GetCurrentBinaryDirectory()) + char* output = new char[(strlen(this->GetCurrentBinaryDirectory()) + target.GetName().size() + 30)]; - sprintf(output,"%s/%s_force_%i", this->Makefile->GetCurrentBinaryDirectory(), + sprintf(output,"%s/%s_force_%i", this->GetCurrentBinaryDirectory(), target.GetName().c_str(), count); const char* comment = origCommand.GetComment(); if(!comment && origCommand.GetOutputs().empty()) @@ -1968,7 +1968,7 @@ cmLocalVisualStudio6Generator // files directory for any configuration. This is used to construct // object file names that do not produce paths that are too long. std::string dir_max; - dir_max += this->Makefile->GetCurrentBinaryDirectory(); + dir_max += this->GetCurrentBinaryDirectory(); dir_max += "/"; dir_max += config_max; dir_max += "/"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index e3c28ee..82b18c6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -140,7 +140,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() cmCustomCommandLines force_commands; force_commands.push_back(force_command); std::string no_main_dependency = ""; - std::string force = this->Makefile->GetCurrentBinaryDirectory(); + std::string force = this->GetCurrentBinaryDirectory(); force += cmake::GetCMakeFilesDirectory(); force += "/"; force += tgt.GetName(); @@ -164,14 +164,14 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() void cmLocalVisualStudio7Generator::WriteProjectFiles() { // If not an in source build, then create the output directory - if(strcmp(this->Makefile->GetCurrentBinaryDirectory(), - this->Makefile->GetHomeDirectory()) != 0) + if(strcmp(this->GetCurrentBinaryDirectory(), + this->GetSourceDirectory()) != 0) { if(!cmSystemTools::MakeDirectory - (this->Makefile->GetCurrentBinaryDirectory())) + (this->GetCurrentBinaryDirectory())) { cmSystemTools::Error("Error creating directory ", - this->Makefile->GetCurrentBinaryDirectory()); + this->GetCurrentBinaryDirectory()); } } @@ -200,7 +200,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() { // Touch a timestamp file used to determine when the project file is // out of date. - std::string stampName = this->Makefile->GetCurrentBinaryDirectory(); + std::string stampName = this->GetCurrentBinaryDirectory(); stampName += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(stampName.c_str()); stampName += "/"; @@ -247,7 +247,7 @@ void cmLocalVisualStudio7Generator target.SetProperty("GENERATOR_FILE_NAME",lname.c_str()); // create the dsp.cmake file std::string fname; - fname = this->Makefile->GetCurrentBinaryDirectory(); + fname = this->GetCurrentBinaryDirectory(); fname += "/"; fname += lname; if(this->FortranProject) @@ -276,13 +276,13 @@ void cmLocalVisualStudio7Generator //---------------------------------------------------------------------------- cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() { - std::string stampName = this->Makefile->GetCurrentBinaryDirectory(); + std::string stampName = this->GetCurrentBinaryDirectory(); stampName += "/"; stampName += cmake::GetCMakeFilesDirectoryPostSlash(); stampName += "generate.stamp"; cmCustomCommandLine commandLine; commandLine.push_back(cmSystemTools::GetCMakeCommand()); - std::string makefileIn = this->Makefile->GetCurrentSourceDirectory(); + std::string makefileIn = this->GetCurrentSourceDirectory(); makefileIn += "/"; makefileIn += "CMakeLists.txt"; makefileIn = cmSystemTools::CollapseFullPath(makefileIn.c_str()); @@ -294,10 +294,10 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule() comment += makefileIn; std::string args; args = "-H"; - args += this->Makefile->GetHomeDirectory(); + args += this->GetSourceDirectory(); commandLine.push_back(args); args = "-B"; - args += this->Makefile->GetHomeOutputDirectory(); + args += this->GetBinaryDirectory(); commandLine.push_back(args); commandLine.push_back("--check-stamp-file"); std::string stampFilename = this->Convert(stampName.c_str(), FULL, @@ -1723,7 +1723,7 @@ cmLocalVisualStudio7Generator // files directory for any configuration. This is used to construct // object file names that do not produce paths that are too long. std::string dir_max; - dir_max += this->Makefile->GetCurrentBinaryDirectory(); + dir_max += this->GetCurrentBinaryDirectory(); dir_max += "/"; dir_max += this->GetTargetDirectory(target); dir_max += "/"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c060505..73d3522 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -161,9 +161,6 @@ cmMakefile::~cmMakefile() cmDeleteAll(this->FinalPassCommands); cmDeleteAll(this->FunctionBlockers); cmDeleteAll(this->EvaluationFiles); - this->EvaluationFiles.clear(); - - this->FunctionBlockers.clear(); } //---------------------------------------------------------------------------- @@ -1529,7 +1526,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->SetProjectName(parent->GetProjectName()); + this->StateSnapshot.SetProjectName(parent->StateSnapshot.GetProjectName()); // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -1908,13 +1905,13 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, nvalue += files[cc]; } - this->GetState()->AddCacheEntry(name, nvalue.c_str(), doc, type); + this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type); val = this->GetState()->GetInitializedCacheValue(name); haveVal = true; } } - this->GetState()->AddCacheEntry(name, haveVal ? val.c_str() : 0, + this->GetCMakeInstance()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, type); // if there was a definition then remove it this->StateSnapshot.RemoveDefinition(name); @@ -2030,11 +2027,6 @@ void cmMakefile::SetProjectName(std::string const& p) this->StateSnapshot.SetProjectName(p); } -std::string cmMakefile::GetProjectName() const -{ - return this->StateSnapshot.GetProjectName(); -} - void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 459d34c..0a8dcd5 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -274,11 +274,6 @@ public: */ void SetProjectName(std::string const& name); - /** - * Get the name of the project for this build. - */ - std::string GetProjectName() const; - /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector<std::string>& configs, bool single = true) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6eafeae..f17f66d 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -419,7 +419,7 @@ void cmMakefileTargetGenerator this->WriteObjectBuildFile(obj, lang, source, depends); // The object file should be checked for dependency integrity. - std::string objFullPath = this->Makefile->GetCurrentBinaryDirectory(); + std::string objFullPath = this->LocalGenerator->GetCurrentBinaryDirectory(); objFullPath += "/"; objFullPath += obj; objFullPath = @@ -643,7 +643,8 @@ cmMakefileTargetGenerator this->LocalGenerator->ExpandRuleVariables(compileCommand, vars); std::string workingDirectory = this->LocalGenerator->Convert( - this->Makefile->GetCurrentBinaryDirectory(), cmLocalGenerator::FULL); + this->LocalGenerator->GetCurrentBinaryDirectory(), + cmLocalGenerator::FULL); compileCommand.replace(compileCommand.find(langFlags), langFlags.size(), this->GetFlags(lang)); std::string langDefines = std::string("$(") + lang + "_DEFINES)"; @@ -699,7 +700,7 @@ cmMakefileTargetGenerator // Change the command working directory to the local build tree. this->LocalGenerator->CreateCDCommand (compileCommands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); commands.insert(commands.end(), compileCommands.begin(), compileCommands.end()); @@ -772,7 +773,7 @@ cmMakefileTargetGenerator this->LocalGenerator->CreateCDCommand (preprocessCommands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); commands.insert(commands.end(), preprocessCommands.begin(), @@ -829,7 +830,7 @@ cmMakefileTargetGenerator this->LocalGenerator->CreateCDCommand (assemblyCommands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); commands.insert(commands.end(), assemblyCommands.begin(), @@ -930,7 +931,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules() *this->Target); this->LocalGenerator->CreateCDCommand (commands, - this->Makefile->GetCurrentBinaryDirectory(), + this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::HOME_OUTPUT); // Write the rule. @@ -1096,7 +1097,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // translation table for the dependency scanning process. depCmd << "cd " << (this->LocalGenerator->Convert( - this->Makefile->GetHomeOutputDirectory(), + this->LocalGenerator->GetBinaryDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL)) << " && "; #endif @@ -1111,16 +1112,16 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() // the state of our local generator sufficiently for its needs. depCmd << "$(CMAKE_COMMAND) -E cmake_depends \"" << this->GlobalGenerator->GetName() << "\" " - << this->Convert(this->Makefile->GetHomeDirectory(), + << this->Convert(this->LocalGenerator->GetSourceDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->Makefile->GetCurrentSourceDirectory(), + << this->Convert(this->LocalGenerator->GetCurrentSourceDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->Makefile->GetHomeOutputDirectory(), + << this->Convert(this->LocalGenerator->GetBinaryDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " - << this->Convert(this->Makefile->GetCurrentBinaryDirectory(), + << this->Convert(this->LocalGenerator->GetCurrentBinaryDirectory(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL) << " " << this->Convert(this->InfoFileNameFull, @@ -1243,7 +1244,7 @@ void cmMakefileTargetGenerator ::MakeEchoProgress(cmLocalUnixMakefileGenerator3::EchoProgress& progress) const { - progress.Dir = this->Makefile->GetHomeOutputDirectory(); + progress.Dir = this->LocalGenerator->GetBinaryDirectory(); progress.Dir += cmake::GetCMakeFilesDirectory(); std::ostringstream progressArg; progressArg << "$(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")"; diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx index 10d30f3..8d0e2b3 100644 --- a/Source/cmMarkAsAdvancedCommand.cxx +++ b/Source/cmMarkAsAdvancedCommand.cxx @@ -39,7 +39,8 @@ bool cmMarkAsAdvancedCommand cmState* state = this->Makefile->GetState(); if (!state->GetCacheEntryValue(variable)) { - state->AddCacheEntry(variable, 0, 0, cmState::UNINITIALIZED); + this->Makefile->GetCMakeInstance()->AddCacheEntry( + variable, 0, 0, cmState::UNINITIALIZED); overwrite = true; } if (!state->GetCacheEntryValue(variable)) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index f8743d9..2a6c414 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -666,8 +666,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (!preLinkCmdLines.empty()) { const std::string homeOutDir = localGen.ConvertToOutputFormat( - mf->GetHomeOutputDirectory(), - cmLocalGenerator::SHELL); + localGen.GetBinaryDirectory(), + cmLocalGenerator::SHELL); preLinkCmdLines.push_back("cd " + homeOutDir); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c2daa63..dcd7bd8 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -45,9 +45,8 @@ cmNinjaTargetGenerator::New(cmGeneratorTarget* target) // We only want to process global targets that live in the home // (i.e. top-level) directory. CMake creates copies of these targets // in every directory, which we don't need. - cmMakefile *mf = target->Target->GetMakefile(); - if (strcmp(mf->GetCurrentSourceDirectory(), - mf->GetHomeDirectory()) == 0) + if (strcmp(target->GetLocalGenerator()->GetCurrentSourceDirectory(), + target->GetLocalGenerator()->GetSourceDirectory()) == 0) return new cmNinjaUtilityTargetGenerator(target); // else fallthrough } diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index df43c61..9feb7ac 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -103,13 +103,13 @@ void cmNinjaUtilityTargetGenerator::Generate() command, "$(CMAKE_SOURCE_DIR)", this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTarget()->GetMakefile()->GetHomeDirectory(), + this->GetLocalGenerator()->GetSourceDirectory(), cmLocalGenerator::SHELL).c_str()); cmSystemTools::ReplaceString( command, "$(CMAKE_BINARY_DIR)", this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTarget()->GetMakefile()->GetHomeOutputDirectory(), + this->GetLocalGenerator()->GetBinaryDirectory(), cmLocalGenerator::SHELL).c_str()); cmSystemTools::ReplaceString(command, "$(ARGS)", ""); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index db7519b..72c7330 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -82,9 +82,8 @@ struct cmState::BuildsystemDirectoryStateType std::vector<cmState::Snapshot> Children; }; -cmState::cmState(cmake* cm) - : CMakeInstance(cm), - IsInTryCompile(false), +cmState::cmState() + : IsInTryCompile(false), WindowsShell(false), WindowsVSIDE(false), WatcomWMake(false), @@ -92,10 +91,12 @@ cmState::cmState(cmake* cm) NMake(false), MSYSShell(false) { + this->CacheManager = new cmCacheManager; } cmState::~cmState() { + delete this->CacheManager; cmDeleteAll(this->Commands); } @@ -147,12 +148,30 @@ bool cmState::IsCacheEntryType(std::string const& key) return false; } +bool cmState::LoadCache(const std::string& path, bool internal, + std::set<std::string>& excludes, + std::set<std::string>& includes) +{ + return this->CacheManager->LoadCache(path, internal, + excludes, includes); +} + +bool cmState::SaveCache(const std::string& path) +{ + return this->CacheManager->SaveCache(path); +} + +bool cmState::DeleteCache(const std::string& path) +{ + return this->CacheManager->DeleteCache(path); +} + std::vector<std::string> cmState::GetCacheEntryKeys() const { std::vector<std::string> definitions; - definitions.reserve(this->CMakeInstance->GetCacheManager()->GetSize()); + definitions.reserve(this->CacheManager->GetSize()); cmCacheManager::CacheIterator cit = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(); + this->CacheManager->GetCacheIterator(); for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() ) { definitions.push_back(cit.GetName()); @@ -162,7 +181,7 @@ std::vector<std::string> cmState::GetCacheEntryKeys() const const char* cmState::GetCacheEntryValue(std::string const& key) const { - cmCacheManager::CacheEntry* e = this->CMakeInstance->GetCacheManager() + cmCacheManager::CacheEntry* e = this->CacheManager ->GetCacheEntry(key); if (!e) { @@ -174,21 +193,21 @@ const char* cmState::GetCacheEntryValue(std::string const& key) const const char* cmState::GetInitializedCacheValue(std::string const& key) const { - return this->CMakeInstance->GetCacheManager()->GetInitializedCacheValue(key); + return this->CacheManager->GetInitializedCacheValue(key); } cmState::CacheEntryType cmState::GetCacheEntryType(std::string const& key) const { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); return it.GetType(); } void cmState::SetCacheEntryValue(std::string const& key, std::string const& value) { - this->CMakeInstance->GetCacheManager()->SetCacheEntryValue(key, value); + this->CacheManager->SetCacheEntryValue(key, value); } void cmState::SetCacheEntryProperty(std::string const& key, @@ -196,7 +215,7 @@ void cmState::SetCacheEntryProperty(std::string const& key, std::string const& value) { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); it.SetProperty(propertyName, value.c_str()); } @@ -205,14 +224,14 @@ void cmState::SetCacheEntryBoolProperty(std::string const& key, bool value) { cmCacheManager::CacheIterator it = - this->CMakeInstance->GetCacheManager()->GetCacheIterator(key.c_str()); + this->CacheManager->GetCacheIterator(key.c_str()); it.SetProperty(propertyName, value); } const char* cmState::GetCacheEntryProperty(std::string const& key, std::string const& propertyName) { - cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager() + cmCacheManager::CacheIterator it = this->CacheManager ->GetCacheIterator(key.c_str()); if (!it.PropertyExists(propertyName)) { @@ -224,7 +243,7 @@ const char* cmState::GetCacheEntryProperty(std::string const& key, bool cmState::GetCacheEntryPropertyAsBool(std::string const& key, std::string const& propertyName) { - return this->CMakeInstance->GetCacheManager() + return this->CacheManager ->GetCacheIterator(key.c_str()).GetPropertyAsBool(propertyName); } @@ -232,13 +251,13 @@ void cmState::AddCacheEntry(const std::string& key, const char* value, const char* helpString, cmState::CacheEntryType type) { - this->CMakeInstance->GetCacheManager()->AddCacheEntry(key, value, + this->CacheManager->AddCacheEntry(key, value, helpString, type); } void cmState::RemoveCacheEntry(std::string const& key) { - this->CMakeInstance->GetCacheManager()->RemoveCacheEntry(key); + this->CacheManager->RemoveCacheEntry(key); } void cmState::AppendCacheEntryProperty(const std::string& key, @@ -246,7 +265,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key, const std::string& value, bool asString) { - this->CMakeInstance->GetCacheManager() + this->CacheManager ->GetCacheIterator(key.c_str()).AppendProperty(property, value.c_str(), asString); @@ -255,7 +274,7 @@ void cmState::AppendCacheEntryProperty(const std::string& key, void cmState::RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName) { - this->CMakeInstance->GetCacheManager() + this->CacheManager ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0); } @@ -659,6 +678,16 @@ bool cmState::UseMSYSShell() const return this->MSYSShell; } +unsigned int cmState::GetCacheMajorVersion() const +{ + return this->CacheManager->GetCacheMajorVersion(); +} + +unsigned int cmState::GetCacheMinorVersion() const +{ + return this->CacheManager->GetCacheMinorVersion(); +} + const char* cmState::GetBinaryDirectory() const { return this->BinaryDirectory.c_str(); @@ -1741,3 +1770,87 @@ bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) { return lhs.Position != rhs.Position; } + +static bool ParseEntryWithoutType(const std::string& entry, + std::string& var, + std::string& value) +{ + // input line is: key=value + static cmsys::RegularExpression reg( + "^([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + // input line is: "key"=value + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\"=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + bool flag = false; + if(regQuoted.find(entry)) + { + var = regQuoted.match(1); + value = regQuoted.match(2); + flag = true; + } + else if (reg.find(entry)) + { + var = reg.match(1); + value = reg.match(2); + flag = true; + } + + // if value is enclosed in single quotes ('foo') then remove them + // it is used to enclose trailing space or tab + if (flag && + value.size() >= 2 && + value[0] == '\'' && + value[value.size() - 1] == '\'') + { + value = value.substr(1, + value.size() - 2); + } + + return flag; +} + +bool cmState::ParseCacheEntry(const std::string& entry, + std::string& var, + std::string& value, + CacheEntryType& type) +{ + // input line is: key:type=value + static cmsys::RegularExpression reg( + "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + // input line is: "key":type=value + static cmsys::RegularExpression regQuoted( + "^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$"); + bool flag = false; + if(regQuoted.find(entry)) + { + var = regQuoted.match(1); + type = cmState::StringToCacheEntryType(regQuoted.match(2).c_str()); + value = regQuoted.match(3); + flag = true; + } + else if (reg.find(entry)) + { + var = reg.match(1); + type = cmState::StringToCacheEntryType(reg.match(2).c_str()); + value = reg.match(3); + flag = true; + } + + // if value is enclosed in single quotes ('foo') then remove them + // it is used to enclose trailing space or tab + if (flag && + value.size() >= 2 && + value[0] == '\'' && + value[value.size() - 1] == '\'') + { + value = value.substr(1, + value.size() - 2); + } + + if (!flag) + { + return ParseEntryWithoutType(entry, var, value); + } + + return flag; +} diff --git a/Source/cmState.h b/Source/cmState.h index 1ffc4bf..2f66f7f 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -23,6 +23,7 @@ class cmake; class cmCommand; class cmDefinitions; class cmListFileBacktrace; +class cmCacheManager; class cmState { @@ -32,7 +33,7 @@ class cmState typedef cmLinkedTree<SnapshotDataType>::iterator PositionType; friend class Snapshot; public: - cmState(cmake* cm); + cmState(); ~cmState(); enum SnapshotType @@ -208,6 +209,14 @@ public: static const char* CacheEntryTypeToString(CacheEntryType); static bool IsCacheEntryType(std::string const& key); + bool LoadCache(const std::string& path, bool internal, + std::set<std::string>& excludes, + std::set<std::string>& includes); + + bool SaveCache(const std::string& path) ; + + bool DeleteCache(const std::string& path); + std::vector<std::string> GetCacheEntryKeys() const; const char* GetCacheEntryValue(std::string const& key) const; const char* GetInitializedCacheValue(std::string const& key) const; @@ -215,8 +224,6 @@ public: void SetCacheEntryValue(std::string const& key, std::string const& value); void SetCacheValue(std::string const& key, std::string const& value); - void AddCacheEntry(const std::string& key, const char* value, - const char* helpString, CacheEntryType type); void RemoveCacheEntry(std::string const& key); void SetCacheEntryProperty(std::string const& key, @@ -236,6 +243,12 @@ public: void RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName); + ///! 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); + Snapshot Reset(); // Define a property void DefineProperty(const std::string& name, cmProperty::ScopeType scope, @@ -296,12 +309,19 @@ public: void SetMSYSShell(bool mSYSShell); bool UseMSYSShell() const; + unsigned int GetCacheMajorVersion() const; + unsigned int GetCacheMinorVersion() const; + private: + friend class cmake; + void AddCacheEntry(const std::string& key, const char* value, + const char* helpString, CacheEntryType type); + std::map<cmProperty::ScopeType, cmPropertyDefinitionMap> PropertyDefinitions; std::vector<std::string> EnabledLanguages; std::map<std::string, cmCommand*> Commands; cmPropertyMap GlobalProperties; - cmake* CMakeInstance; + cmCacheManager* CacheManager; cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory; diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx index 486328f..3f1e333 100644 --- a/Source/cmUtilitySourceCommand.cxx +++ b/Source/cmUtilitySourceCommand.cxx @@ -11,8 +11,6 @@ ============================================================================*/ #include "cmUtilitySourceCommand.h" -#include "cmCacheManager.h" - // cmUtilitySourceCommand bool cmUtilitySourceCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) @@ -54,13 +52,13 @@ bool cmUtilitySourceCommand } else { - cmCacheManager *manager = - this->Makefile->GetCMakeInstance()->GetCacheManager(); + cmState *state = + this->Makefile->GetState(); haveCacheValue = (cacheValue && (strstr(cacheValue, "(IntDir)") == 0 || (intDir && strcmp(intDir, "$(IntDir)") == 0)) && - (manager->GetCacheMajorVersion() != 0 && - manager->GetCacheMinorVersion() != 0 )); + (state->GetCacheMajorVersion() != 0 && + state->GetCacheMinorVersion() != 0 )); } if(haveCacheValue) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a4b0bc3..e1b9223 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -195,7 +195,7 @@ cmVisualStudio10TargetGenerator(cmTarget* target, this->BuildFileStream = 0; this->IsMissingFiles = false; this->DefaultArtifactDir = - this->Makefile->GetCurrentBinaryDirectory() + std::string("/") + + this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/") + this->LocalGenerator->GetTargetDirectory(*this->Target); } @@ -297,8 +297,7 @@ void cmVisualStudio10TargetGenerator::Generate() return; } } - cmMakefile* mf = this->Target->GetMakefile(); - std::string path = mf->GetCurrentBinaryDirectory(); + std::string path = this->LocalGenerator->GetCurrentBinaryDirectory(); path += "/"; path += this->Name; path += ".vcxproj"; @@ -951,7 +950,7 @@ cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path, { return forceRelative ? cmSystemTools::RelativePath( - this->Makefile->GetCurrentBinaryDirectory(), path.c_str()) + this->LocalGenerator->GetCurrentBinaryDirectory(), path.c_str()) : path.c_str(); } @@ -990,7 +989,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->AddMissingSourceGroups(groupsUsed, sourceGroups); // Write out group file - std::string path = this->Makefile->GetCurrentBinaryDirectory(); + std::string path = this->LocalGenerator->GetCurrentBinaryDirectory(); path += "/"; path += this->Name; path += ".vcxproj.filters"; @@ -1448,7 +1447,7 @@ void cmVisualStudio10TargetGenerator::WriteSource( std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true); size_t const maxLen = 250; if(sf->GetCustomCommand() || - ((strlen(this->Makefile->GetCurrentBinaryDirectory()) + 1 + + ((strlen(this->LocalGenerator->GetCurrentBinaryDirectory()) + 1 + sourceRel.length()) <= maxLen)) { forceRelative = true; @@ -2244,7 +2243,7 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions( { // Look through the sources for AndroidManifest.xml and use // its location as the root source directory. - std::string rootDir = this->Makefile->GetCurrentSourceDirectory(); + std::string rootDir = this->LocalGenerator->GetCurrentSourceDirectory(); { std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources, ""); @@ -3314,7 +3313,8 @@ void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80() // For WP80, the manifest needs to be in the same folder as the project // this can cause an overwrite problem if projects aren't organized in // folders - std::string manifestFile = this->Makefile->GetCurrentBinaryDirectory() + + std::string manifestFile = + this->LocalGenerator->GetCurrentBinaryDirectory() + std::string("/WMAppManifest.xml"); std::string artifactDir = this->LocalGenerator->GetTargetDirectory(*this->Target); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index fececfd..6846f1b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -10,7 +10,6 @@ See the License for more information. ============================================================================*/ #include "cmake.h" -#include "cmCacheManager.h" #include "cmMakefile.h" #include "cmLocalGenerator.h" #include "cmExternalMakefileProjectGenerator.h" @@ -135,7 +134,7 @@ cmake::cmake() this->ClearBuildSystem = false; this->FileComparison = new cmFileTimeComparison; - this->State = new cmState(this); + this->State = new cmState; this->CurrentSnapshot = this->State->CreateBaseSnapshot(); #ifdef __APPLE__ @@ -151,7 +150,6 @@ cmake::cmake() #endif this->Verbose = false; - this->CacheManager = new cmCacheManager(this); this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; @@ -171,7 +169,6 @@ cmake::cmake() cmake::~cmake() { - delete this->CacheManager; delete this->State; if (this->GlobalGenerator) { @@ -216,7 +213,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } std::string var, value; cmState::CacheEntryType type = cmState::UNINITIALIZED; - if(cmCacheManager::ParseEntry(entry, var, value, type)) + 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 @@ -232,7 +229,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } } - this->State->AddCacheEntry(var, value.c_str(), + this->AddCacheEntry(var, value.c_str(), "No help, variable specified on the command line.", type); if(this->WarnUnusedCli) @@ -848,14 +845,14 @@ void cmake::SetDirectoriesFromFile(const char* arg) int cmake::AddCMakePaths() { // Save the value in the cache - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), "Path to CMake executable.", cmState::INTERNAL); #ifdef CMAKE_BUILD_WITH_CMAKE - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), "Path to ctest program executable.", cmState::INTERNAL); - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_CPACK_COMMAND", cmSystemTools::GetCPackCommand().c_str(), "Path to cpack program executable.", cmState::INTERNAL); #endif @@ -869,7 +866,7 @@ int cmake::AddCMakePaths() cmSystemTools::GetCMakeRoot().c_str()); return 0; } - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_ROOT", cmSystemTools::GetCMakeRoot().c_str(), "Path to CMake installation.", cmState::INTERNAL); @@ -1086,10 +1083,10 @@ int cmake::DoPreConfigureChecks() } // do a sanity check on some values - if(this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) + if(this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY")) { std::string cacheStart = - this->CacheManager->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); + this->State->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); cacheStart += "/CMakeLists.txt"; std::string currentStart = this->GetHomeDirectory(); currentStart += "/CMakeLists.txt"; @@ -1146,12 +1143,12 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) save.value = *i; warning << *i << "\n"; const char* existingValue = - this->CacheManager->GetCacheEntryValue(save.key); + this->State->GetCacheEntryValue(save.key); if(existingValue) { - save.type = this->CacheManager->GetCacheEntryType(save.key); + save.type = this->State->GetCacheEntryType(save.key); if(const char* help = - this->CacheManager->GetCacheEntryProperty(save.key, "HELPSTRING")) + this->State->GetCacheEntryProperty(save.key, "HELPSTRING")) { save.help = help; } @@ -1160,7 +1157,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var) } // remove the cache - this->CacheManager->DeleteCache(this->GetHomeOutputDirectory()); + this->DeleteCache(this->GetHomeOutputDirectory()); // load the empty cache this->LoadCache(); // restore the changed compilers @@ -1186,7 +1183,7 @@ int cmake::Configure() { if(this->SuppressDevWarnings) { - this->CacheManager-> + this-> AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "TRUE", "Suppress Warnings that are meant for" " the author of the CMakeLists.txt files.", @@ -1194,7 +1191,7 @@ int cmake::Configure() } else { - this->CacheManager-> + this-> AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "Suppress Warnings that are meant for" " the author of the CMakeLists.txt files.", @@ -1229,7 +1226,7 @@ int cmake::ActualConfigure() } if ( !res ) { - this->CacheManager->AddCacheEntry + this->AddCacheEntry ("CMAKE_HOME_DIRECTORY", this->GetHomeDirectory(), "Source directory with the top level CMakeLists.txt file for this " @@ -1241,9 +1238,9 @@ int cmake::ActualConfigure() if(!this->GlobalGenerator) { const char* genName = - this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR"); + this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); const char* extraGenName = - this->CacheManager->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); + this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); if(genName) { std::string fullName = cmExternalMakefileProjectGenerator:: @@ -1321,7 +1318,7 @@ int cmake::ActualConfigure() } } - const char* genName = this->CacheManager + const char* genName = this->State ->GetInitializedCacheValue("CMAKE_GENERATOR"); if(genName) { @@ -1338,20 +1335,20 @@ int cmake::ActualConfigure() return -2; } } - if(!this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR")) + if(!this->State->GetInitializedCacheValue("CMAKE_GENERATOR")) { - this->CacheManager->AddCacheEntry("CMAKE_GENERATOR", + this->AddCacheEntry("CMAKE_GENERATOR", this->GlobalGenerator->GetName().c_str(), "Name of generator.", cmState::INTERNAL); - this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR", + this->AddCacheEntry("CMAKE_EXTRA_GENERATOR", this->GlobalGenerator->GetExtraGeneratorName().c_str(), "Name of external makefile project generator.", cmState::INTERNAL); } if(const char* platformName = - this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) + this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) { if(this->GeneratorPlatform.empty()) { @@ -1372,14 +1369,14 @@ int cmake::ActualConfigure() } else { - this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", + this->AddCacheEntry("CMAKE_GENERATOR_PLATFORM", this->GeneratorPlatform.c_str(), "Name of generator platform.", cmState::INTERNAL); } if(const char* tsName = - this->CacheManager->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) + this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) { if(this->GeneratorToolset.empty()) { @@ -1400,7 +1397,7 @@ int cmake::ActualConfigure() } else { - this->CacheManager->AddCacheEntry("CMAKE_GENERATOR_TOOLSET", + this->AddCacheEntry("CMAKE_GENERATOR_TOOLSET", this->GeneratorToolset.c_str(), "Name of generator toolset.", cmState::INTERNAL); @@ -1434,7 +1431,7 @@ int cmake::ActualConfigure() { if(!this->State->GetInitializedCacheValue("LIBRARY_OUTPUT_PATH")) { - this->State->AddCacheEntry + this->AddCacheEntry ("LIBRARY_OUTPUT_PATH", "", "Single output directory for building all libraries.", cmState::PATH); @@ -1442,7 +1439,7 @@ int cmake::ActualConfigure() if(!this->State ->GetInitializedCacheValue("EXECUTABLE_OUTPUT_PATH")) { - this->State->AddCacheEntry + this->AddCacheEntry ("EXECUTABLE_OUTPUT_PATH", "", "Single output directory for building all executables.", cmState::PATH); @@ -1462,7 +1459,7 @@ int cmake::ActualConfigure() // only save the cache if there were no fatal errors if ( this->GetWorkingMode() == NORMAL_MODE ) { - this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); + this->SaveCache(this->GetHomeOutputDirectory()); } if(cmSystemTools::GetErrorOccuredFlag()) { @@ -1632,7 +1629,7 @@ int cmake::Generate() // for the Visual Studio and Xcode generators.) if ( this->GetWorkingMode() == NORMAL_MODE ) { - this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); + this->SaveCache(this->GetHomeOutputDirectory()); } return 0; } @@ -1641,14 +1638,15 @@ void cmake::AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type) { - this->CacheManager->AddCacheEntry(key, value, + this->State->AddCacheEntry(key, value, helpString, cmState::CacheEntryType(type)); + this->UnwatchUnusedCli(key); } const char* cmake::GetCacheDefinition(const std::string& name) const { - return this->CacheManager->GetInitializedCacheValue(name); + return this->State->GetInitializedCacheValue(name); } void cmake::AddDefaultCommands() @@ -1721,7 +1719,7 @@ bool cmake::ParseCacheEntry(const std::string& entry, std::string& value, cmState::CacheEntryType& type) { - return cmCacheManager::ParseEntry(entry, var, value, type); + return cmState::ParseCacheEntry(entry, var, value, type); } int cmake::LoadCache() @@ -1752,24 +1750,43 @@ int cmake::LoadCache() bool cmake::LoadCache(const std::string& path) { - return this->CacheManager->LoadCache(path); + std::set<std::string> emptySet; + return this->LoadCache(path, true, emptySet, emptySet); } bool cmake::LoadCache(const std::string& path, bool internal, std::set<std::string>& excludes, std::set<std::string>& includes) { - return this->CacheManager->LoadCache(path, internal, excludes, includes); + bool result = this->State->LoadCache(path, internal, excludes, includes); + static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION", + "CMAKE_CACHE_MINOR_VERSION"}; + for (const char* const* nameIt = cmArrayBegin(entries); + nameIt != cmArrayEnd(entries); ++nameIt) + { + this->UnwatchUnusedCli(*nameIt); + } + return result; } bool cmake::SaveCache(const std::string& path) { - return this->CacheManager->SaveCache(path); + bool result = this->State->SaveCache(path); + static const char* entries[] = {"CMAKE_CACHE_MAJOR_VERSION", + "CMAKE_CACHE_MINOR_VERSION", + "CMAKE_CACHE_PATCH_VERSION", + "CMAKE_CACHEFILE_DIR"}; + for (const char* const* nameIt = cmArrayBegin(entries); + nameIt != cmArrayEnd(entries); ++nameIt) + { + this->UnwatchUnusedCli(*nameIt); + } + return result; } bool cmake::DeleteCache(const std::string& path) { - return this->CacheManager->DeleteCache(path); + return this->State->DeleteCache(path); } void cmake::SetProgressCallback(ProgressCallbackType f, void *cd) @@ -1834,7 +1851,7 @@ void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: const char* tablepath = - this->CacheManager + this->State ->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if(tablepath) diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 84010d8..ce7f563 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -342,11 +342,6 @@ ENDIF() # capabilities and parent project's request. Enforce 0/1 as only # possible values for configuration into Configure.hxx. -IF(UNIX) - KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM - "Checking whether struct stat has st_mtim member" DIRECT) -ENDIF() - # Check existence and uniqueness of long long and __int64. KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG "Checking whether C++ compiler has 'long long'" DIRECT) @@ -511,12 +506,18 @@ IF(KWSYS_USE_SystemTools) "Checking whether CXX compiler has utimes" DIRECT) KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT "Checking whether CXX compiler has utimensat" DIRECT) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIM + "Checking whether CXX compiler struct stat has st_mtim member" DIRECT) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC + "Checking whether CXX compiler struct stat has st_mtimespec member" DIRECT) SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV} KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV} KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H} KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES} KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT} + KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM} + KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC} ) ENDIF() diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 3faf862..ff8e49d 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -18,9 +18,6 @@ /* Whether wstring is available. */ #define @KWSYS_NAMESPACE@_STL_HAS_WSTRING @KWSYS_STL_HAS_WSTRING@ -/* Whether struct stat has the st_mtim member for high resolution times. */ -#define @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM @KWSYS_STAT_HAS_ST_MTIM@ - /* If building a C++ file in kwsys itself, give the source file access to the macros without a configured namespace. */ #if defined(KWSYS_NAMESPACE) @@ -28,7 +25,6 @@ # define kwsys @KWSYS_NAMESPACE@ # endif # define KWSYS_NAME_IS_KWSYS @KWSYS_NAMESPACE@_NAME_IS_KWSYS -# define KWSYS_STAT_HAS_ST_MTIM @KWSYS_NAMESPACE@_STAT_HAS_ST_MTIM # define KWSYS_STL_HAS_WSTRING @KWSYS_NAMESPACE@_STL_HAS_WSTRING #endif diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 262af27..da34eb9 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1366,15 +1366,18 @@ bool SystemTools::Touch(const std::string& filename, bool create) struct timeval mtime; gettimeofday(&mtime, 0); # if KWSYS_CXX_HAS_UTIMES - struct timeval times[2] = - { -# if KWSYS_STAT_HAS_ST_MTIM - {st.st_atim.tv_sec, st.st_atim.tv_nsec/1000}, /* tv_sec, tv_usec */ + struct timeval atime; +# if KWSYS_CXX_STAT_HAS_ST_MTIM + atime.tv_sec = st.st_atim.tv_sec; + atime.tv_usec = st.st_atim.tv_nsec/1000; +# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC + atime.tv_sec = st.st_atimespec.tv_sec; + atime.tv_usec = st.st_atimespec.tv_nsec/1000; # else - {st.st_atime, 0}, + atime.tv_sec = st.st_atime; + atime.tv_usec = 0; # endif - mtime - }; + struct timeval times[2] = { atime, mtime }; if(utimes(filename.c_str(), times) < 0) { return false; @@ -1408,7 +1411,7 @@ bool SystemTools::FileTimeCompare(const std::string& f1, { return false; } -# if KWSYS_STAT_HAS_ST_MTIM +# if KWSYS_CXX_STAT_HAS_ST_MTIM // Compare using nanosecond resolution. if(s1.st_mtim.tv_sec < s2.st_mtim.tv_sec) { @@ -1426,6 +1429,24 @@ bool SystemTools::FileTimeCompare(const std::string& f1, { *result = 1; } +# elif KWSYS_CXX_STAT_HAS_ST_MTIMESPEC + // Compare using nanosecond resolution. + if(s1.st_mtimespec.tv_sec < s2.st_mtimespec.tv_sec) + { + *result = -1; + } + else if(s1.st_mtimespec.tv_sec > s2.st_mtimespec.tv_sec) + { + *result = 1; + } + else if(s1.st_mtimespec.tv_nsec < s2.st_mtimespec.tv_nsec) + { + *result = -1; + } + else if(s1.st_mtimespec.tv_nsec > s2.st_mtimespec.tv_nsec) + { + *result = 1; + } # else // Compare using 1 second resolution. if(s1.st_mtime < s2.st_mtime) diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx index 94579b3..9626937 100644 --- a/Source/kwsys/kwsysPlatformTestsCXX.cxx +++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx @@ -32,7 +32,7 @@ int main() } #endif -#ifdef TEST_KWSYS_STAT_HAS_ST_MTIM +#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIM #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> @@ -45,6 +45,19 @@ int main() } #endif +#ifdef TEST_KWSYS_CXX_STAT_HAS_ST_MTIMESPEC +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +int main() +{ + struct stat stat1; + (void)stat1.st_mtimespec.tv_sec; + (void)stat1.st_mtimespec.tv_nsec; + return 0; +} +#endif + #ifdef TEST_KWSYS_CXX_SAME_LONG_AND___INT64 void function(long**) {} int main() diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index ffee035..c538280 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -25,8 +25,7 @@ if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES) ) add_executable(WriteCompilerDetectionHeader "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") - if((UNIX OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") + if(UNIX OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU") include(CheckCXXSourceCompiles) check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n" file_include_works @@ -493,7 +493,7 @@ cmake_kwsys_config_replace_string () s/@KWSYS_LFS_REQUESTED@/${KWSYS_LFS_REQUESTED}/g; s/@KWSYS_NAME_IS_KWSYS@/${KWSYS_NAME_IS_KWSYS}/g; s/@KWSYS_STL_HAS_WSTRING@/${KWSYS_STL_HAS_WSTRING}/g; - s/@KWSYS_STAT_HAS_ST_MTIM@/${KWSYS_STAT_HAS_ST_MTIM}/g;}" >> "${OUTFILE}${_tmp}" + }" >> "${OUTFILE}${_tmp}" if [ -f "${OUTFILE}${_tmp}" ]; then if "${_diff}" "${OUTFILE}" "${OUTFILE}${_tmp}" > /dev/null 2> /dev/null ; then #echo "Files are the same" @@ -1173,7 +1173,6 @@ KWSYS_NAME_IS_KWSYS=0 KWSYS_BUILD_SHARED=0 KWSYS_LFS_AVAILABLE=0 KWSYS_LFS_REQUESTED=0 -KWSYS_STAT_HAS_ST_MTIM=0 KWSYS_STL_HAS_WSTRING=0 KWSYS_CXX_HAS_SETENV=0 KWSYS_CXX_HAS_UNSETENV=0 @@ -1217,15 +1216,6 @@ else echo "${cmake_cxx_compiler} does not have stl wstring" fi -if cmake_try_run "${cmake_cxx_compiler}" \ - "${cmake_cxx_flags} -DTEST_KWSYS_STAT_HAS_ST_MTIM" \ - "${cmake_source_dir}/Source/kwsys/kwsysPlatformTestsCXX.cxx" >> cmake_bootstrap.log 2>&1; then - KWSYS_STAT_HAS_ST_MTIM=1 - echo "${cmake_cxx_compiler} has struct stat with st_mtim member" -else - echo "${cmake_cxx_compiler} does not have struct stat with st_mtim member" -fi - # Just to be safe, let us store compiler and flags to the header file cmake_bootstrap_version='$Revision$' |