diff options
-rw-r--r-- | Help/release/dev/FindSubversion-wc-info-error.rst | 6 | ||||
-rw-r--r-- | Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake | 1 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 5 | ||||
-rw-r--r-- | Modules/FindSubversion.cmake | 33 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmDefinitions.cxx | 6 | ||||
-rw-r--r-- | Source/cmDefinitions.h | 4 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 17 | ||||
-rw-r--r-- | Source/cmOptionCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmState.cxx | 4 | ||||
-rw-r--r-- | Source/cmStateSnapshot.cxx | 7 | ||||
-rw-r--r-- | Source/cmStateSnapshot.h | 2 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt | 7 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt | 7 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/ExternalProject/RunCMakeTest.cmake | 2 |
19 files changed, 102 insertions, 32 deletions
diff --git a/Help/release/dev/FindSubversion-wc-info-error.rst b/Help/release/dev/FindSubversion-wc-info-error.rst new file mode 100644 index 0000000..eaf6bfe --- /dev/null +++ b/Help/release/dev/FindSubversion-wc-info-error.rst @@ -0,0 +1,6 @@ +FindSubversion-wc-info-error +---------------------------- + +* The :module:`FindSubversion` module ``Subversion_WC_INFO`` command + gained an ``IGNORE_SVN_FAILURE`` option to suppress failures, + e.g. when the source tree is not under Subversion control. diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake index 55e0373..11f4a29 100644 --- a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -27,6 +27,7 @@ macro(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines set(_compilerExecutable "${CMAKE_C_COMPILER}") set(_arg1 "${CMAKE_C_COMPILER_ARG1}") endif () + separate_arguments(_arg1 NATIVE_COMMAND "${_arg1}") execute_process(COMMAND ${_compilerExecutable} ${_arg1} ${_stdver} ${_stdlib} -v -E -x ${_lang} -dD dummy WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles ERROR_VARIABLE _gccOutput diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0c5b33f..f987d2d 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -934,6 +934,11 @@ function(_ep_parse_arguments f name ns args) # We loop through ARGN and consider the namespace starting with an # upper-case letter followed by at least two more upper-case letters, # numbers or underscores to be keywords. + + if(NOT DEFINED _ExternalProject_SELF) + message(FATAL_ERROR "error: ExternalProject module must be explicitly included before using ${f} function") + endif() + set(key) foreach(arg IN LISTS args) diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 537d3b2..e18ae88 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -19,17 +19,21 @@ # # # The minimum required version of Subversion can be specified using the -# standard syntax, e.g. find_package(Subversion 1.4) +# standard syntax, e.g. ``find_package(Subversion 1.4)``. # # If the command line client executable is found two macros are defined: # # :: # -# Subversion_WC_INFO(<dir> <var-prefix>) +# Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE]) # Subversion_WC_LOG(<dir> <var-prefix>) # -# Subversion_WC_INFO extracts information of a subversion working copy -# at a given location. This macro defines the following variables: +# ``Subversion_WC_INFO`` extracts information of a subversion working copy at a +# given location. This macro defines the following variables if running +# Subversion's ``info`` command on ``<dir>`` succeeds; otherwise a +# ``SEND_ERROR`` message is generated. The error can be ignored by providing the +# ``IGNORE_SVN_FAILURE`` option, which causes these variables to remain +# undefined. # # :: # @@ -41,9 +45,8 @@ # <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit # <var-prefix>_WC_INFO - output of command `svn info <dir>' # -# Subversion_WC_LOG retrieves the log message of the base revision of a -# subversion working copy at a given location. This macro defines the -# variable: +# ``Subversion_WC_LOG`` retrieves the log message of the base revision of a +# subversion working copy at a given location. This macro defines the variable: # # :: # @@ -84,6 +87,14 @@ if(Subversion_SVN_EXECUTABLE) "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") macro(Subversion_WC_INFO dir prefix) + + cmake_parse_arguments( + "Subversion_WC_INFO" + "IGNORE_SVN_FAILURE" + "" "" + ${ARGN} + ) + # the subversion commands should be executed with the C locale, otherwise # the message (which are parsed) may be translated, Alex set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") @@ -95,10 +106,7 @@ if(Subversion_SVN_EXECUTABLE) RESULT_VARIABLE Subversion_svn_info_result OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT ${Subversion_svn_info_result} EQUAL 0) - message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") - else() - + if(${Subversion_svn_info_result} EQUAL 0) string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}") string(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*" @@ -111,7 +119,8 @@ if(Subversion_SVN_EXECUTABLE) "\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}") string(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*" "\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}") - + elseif(NOT Subversion_WC_INFO_IGNORE_SVN_FAILURE) + message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") endif() # restore the previous LC_ALL diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3bd0714..83b75fb 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 12) -set(CMake_VERSION_PATCH 20180906) +set(CMake_VERSION_PATCH 20180910) #set(CMake_VERSION_RC 1) diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index e766854..5fafaf9 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -30,11 +30,11 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key, return begin->Map.insert(MapType::value_type(key, def)).first->second; } -const char* cmDefinitions::Get(const std::string& key, StackIter begin, - StackIter end) +const std::string* cmDefinitions::Get(const std::string& key, StackIter begin, + StackIter end) { Def const& def = cmDefinitions::GetInternal(key, begin, end, false); - return def.Exists ? def.c_str() : nullptr; + return def.Exists ? &def : nullptr; } void cmDefinitions::Raise(const std::string& key, StackIter begin, diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 528b157..4ab5be6 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -23,8 +23,8 @@ class cmDefinitions typedef cmLinkedTree<cmDefinitions>::iterator StackIter; public: - static const char* Get(const std::string& key, StackIter begin, - StackIter end); + static const std::string* Get(const std::string& key, StackIter begin, + StackIter end); static void Raise(const std::string& key, StackIter begin, StackIter end); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 11019d7..5498ad2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2368,8 +2368,10 @@ std::string cmMakefile::GetRequiredDefinition(const std::string& name) const bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const char* def = this->StateSnapshot.GetDefinition(name); - if (!def) { + const char* def; + if (const std::string* d = this->StateSnapshot.GetDefinition(name)) { + def = d->c_str(); + } else { def = this->GetState()->GetInitializedCacheValue(name); } #ifdef CMAKE_BUILD_WITH_CMAKE @@ -2385,8 +2387,10 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const char* cmMakefile::GetDefinition(const std::string& name) const { - const char* def = this->StateSnapshot.GetDefinition(name); - if (!def) { + const char* def; + if (const std::string* d = this->StateSnapshot.GetDefinition(name)) { + def = d->c_str(); + } else { def = this->GetState()->GetInitializedCacheValue(name); } #ifdef CMAKE_BUILD_WITH_CMAKE @@ -2402,8 +2406,9 @@ const char* cmMakefile::GetDefinition(const std::string& name) const // A callback was executed and may have caused re-allocation of the // variable storage. Look it up again for now. // FIXME: Refactor variable storage to avoid this problem. - def = this->StateSnapshot.GetDefinition(name); - if (!def) { + if (const std::string* d = this->StateSnapshot.GetDefinition(name)) { + def = d->c_str(); + } else { def = this->GetState()->GetInitializedCacheValue(name); } } diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index 816f06c..006211d 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -31,7 +31,7 @@ bool cmOptionCommand::InitialPass(std::vector<std::string> const& args, bool checkAndWarn = false; { auto status = this->Makefile->GetPolicyStatus(cmPolicies::CMP0077); - const char* existsBeforeSet = + const auto* existsBeforeSet = this->Makefile->GetStateSnapshot().GetDefinition(args[0]); switch (status) { case cmPolicies::WARN: @@ -72,7 +72,7 @@ bool cmOptionCommand::InitialPass(std::vector<std::string> const& args, args[1].c_str(), cmStateEnums::BOOL); if (checkAndWarn) { - const char* existsAfterSet = + const auto* existsAfterSet = this->Makefile->GetStateSnapshot().GetDefinition(args[0]); if (!existsAfterSet) { std::ostringstream w; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 6c27a7d..e01bf71 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -299,9 +299,9 @@ cmStateSnapshot cmState::Reset() { std::string srcDir = - cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root); + *cmDefinitions::Get("CMAKE_SOURCE_DIR", pos->Vars, pos->Root); std::string binDir = - cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root); + *cmDefinitions::Get("CMAKE_BINARY_DIR", pos->Vars, pos->Root); this->VarTree.Clear(); pos->Vars = this->VarTree.Push(this->VarTree.Root()); pos->Parent = this->VarTree.Root(); diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index ec428a6..0379e7e 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -204,7 +204,8 @@ bool cmStateSnapshot::HasDefinedPolicyCMP0011() return !this->Position->Policies->IsEmpty(); } -const char* cmStateSnapshot::GetDefinition(std::string const& name) const +std::string const* cmStateSnapshot::GetDefinition( + std::string const& name) const { assert(this->Position->Vars.IsValid()); return cmDefinitions::Get(name, this->Position->Vars, this->Position->Root); @@ -426,8 +427,8 @@ std::string cmStateSnapshot::GetProjectName() const void cmStateSnapshot::InitializeFromParent_ForSubdirsCommand() { - std::string currentSrcDir = this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR"); - std::string currentBinDir = this->GetDefinition("CMAKE_CURRENT_BINARY_DIR"); + std::string currentSrcDir = *this->GetDefinition("CMAKE_CURRENT_SOURCE_DIR"); + std::string currentBinDir = *this->GetDefinition("CMAKE_CURRENT_BINARY_DIR"); this->InitializeFromParent(); this->SetDefinition("CMAKE_SOURCE_DIR", this->State->GetSourceDirectory()); this->SetDefinition("CMAKE_BINARY_DIR", this->State->GetBinaryDirectory()); diff --git a/Source/cmStateSnapshot.h b/Source/cmStateSnapshot.h index af5653b..014c62e 100644 --- a/Source/cmStateSnapshot.h +++ b/Source/cmStateSnapshot.h @@ -22,7 +22,7 @@ public: cmStateSnapshot(cmState* state = nullptr); cmStateSnapshot(cmState* state, cmStateDetail::PositionType position); - const char* GetDefinition(std::string const& name) const; + std::string const* GetDefinition(std::string const& name) const; bool IsInitialized(std::string const& name) const; void SetDefinition(std::string const& name, std::string const& value); void RemoveDefinition(std::string const& name); diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt new file mode 100644 index 0000000..ff3e5c1 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + error: ExternalProject module must be explicitly included before using + ExternalProject_Add function +Call Stack \(most recent call first\): + .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_parse_arguments\) + IncludeScope-Add.cmake:[0-9]+ \(ExternalProject_Add\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake b/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake new file mode 100644 index 0000000..1061ffd --- /dev/null +++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add.cmake @@ -0,0 +1,12 @@ +function(IncludeScope_IncludeOnly) + include(ExternalProject) +endfunction() + +IncludeScope_IncludeOnly() + +ExternalProject_Add(MyProj + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" +) diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt new file mode 100644 index 0000000..cbad4be --- /dev/null +++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Modules/ExternalProject.cmake:[0-9]+ \(message\): + error: ExternalProject module must be explicitly included before using + ExternalProject_Add_Step function +Call Stack \(most recent call first\): + .*/Modules/ExternalProject.cmake:[0-9]+ \(_ep_parse_arguments\) + IncludeScope-Add_Step.cmake:[0-9]+ \(ExternalProject_Add_Step\) + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake new file mode 100644 index 0000000..2a820f8 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/IncludeScope-Add_Step.cmake @@ -0,0 +1,13 @@ +function(IncludeScope_DefineProj) + include(ExternalProject) + ExternalProject_Add(MyProj + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) +endfunction() + +IncludeScope_DefineProj() + +ExternalProject_Add_Step(MyProj extraStep COMMENT "Foo") diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index 09607f6..bf11381 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) +run_cmake(IncludeScope-Add) +run_cmake(IncludeScope-Add_Step) run_cmake(NoOptions) run_cmake(SourceEmpty) run_cmake(SourceMissing) |