diff options
37 files changed, 705 insertions, 106 deletions
diff --git a/Help/release/dev/ExternalProject-USES_TERMINAL.rst b/Help/release/dev/ExternalProject-USES_TERMINAL.rst new file mode 100644 index 0000000..415540d --- /dev/null +++ b/Help/release/dev/ExternalProject-USES_TERMINAL.rst @@ -0,0 +1,7 @@ +ExternalProject-USES_TERMINAL +----------------------------- + +* The :module:`ExternalProject` module learned new ``USES_TERMINAL`` + arguments for giving steps exclusive terminal access. Especially + useful with the :generator:`Ninja` generator to monitor CMake + superbuild progress and prevent CPU oversubscription. diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index eee1841..f6844be 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -175,6 +175,23 @@ Create custom targets to build projects in external trees ``LOG_INSTALL 1`` Wrap install in script to log output + Steps can be given direct access to the terminal if possible. With + the :generator:`Ninja` generator, this places the steps in the + ``console`` :prop_gbl:`pool <JOB_POOLS>`. Options are: + + ``USES_TERMINAL_DOWNLOAD 1`` + Give download terminal access. + ``USES_TERMINAL_UPDATE 1`` + Give update terminal access. + ``USES_TERMINAL_CONFIGURE 1`` + Give configure terminal access. + ``USES_TERMINAL_BUILD 1`` + Give build terminal access. + ``USES_TERMINAL_TEST 1`` + Give test terminal access. + ``USES_TERMINAL_INSTALL 1`` + Give install terminal access. + Other options are: ``STEP_TARGETS <step-target>...`` @@ -256,6 +273,8 @@ Create custom targets to build projects in external trees Working directory for command ``LOG 1`` Wrap step in script to log output + ``USES_TERMINAL 1`` + Give the step direct access to the terminal if possible. The command line, comment, working directory, and byproducts of every standard and custom step are processed to replace tokens ``<SOURCE_DIR>``, @@ -1463,6 +1482,14 @@ function(ExternalProject_Add_Step name step) get_property(comment TARGET ${name} PROPERTY _EP_${step}_COMMENT) endif() + # Uses terminal? + get_property(uses_terminal TARGET ${name} PROPERTY _EP_${step}_USES_TERMINAL) + if(uses_terminal) + set(uses_terminal USES_TERMINAL) + else() + set(uses_terminal "") + endif() + # Run every time? get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS) if(always) @@ -1505,6 +1532,7 @@ function(ExternalProject_Add_Step name step) DEPENDS ${depends} WORKING_DIRECTORY ${work_dir} VERBATIM + ${uses_terminal} ) set_property(TARGET ${name} APPEND PROPERTY _EP_STEPS ${step}) @@ -1890,6 +1918,14 @@ function(_ep_add_download_command name) set(log "") endif() + get_property(uses_terminal TARGET ${name} PROPERTY + _EP_USES_TERMINAL_DOWNLOAD) + if(uses_terminal) + set(uses_terminal USES_TERMINAL 1) + else() + set(uses_terminal "") + endif() + ExternalProject_Add_Step(${name} download COMMENT ${comment} COMMAND ${cmd} @@ -1897,6 +1933,7 @@ function(_ep_add_download_command name) DEPENDS ${depends} DEPENDEES mkdir ${log} + ${uses_terminal} ) endfunction() @@ -2001,6 +2038,14 @@ Update to Mercurial >= 2.1.1. set(log "") endif() + get_property(uses_terminal TARGET ${name} PROPERTY + _EP_USES_TERMINAL_UPDATE) + if(uses_terminal) + set(uses_terminal USES_TERMINAL 1) + else() + set(uses_terminal "") + endif() + ExternalProject_Add_Step(${name} update COMMENT ${comment} COMMAND ${cmd} @@ -2009,6 +2054,7 @@ Update to Mercurial >= 2.1.1. WORKING_DIRECTORY ${work_dir} DEPENDEES download ${log} + ${uses_terminal} ) if(always AND update_disconnected) @@ -2021,6 +2067,7 @@ Update to Mercurial >= 2.1.1. WORKING_DIRECTORY ${work_dir} DEPENDEES download ${log} + ${uses_terminal} ) set_property(SOURCE ${skip-update_stamp_file} PROPERTY SYMBOLIC 1) endif() @@ -2149,6 +2196,14 @@ function(_ep_add_configure_command name) set(log "") endif() + get_property(uses_terminal TARGET ${name} PROPERTY + _EP_USES_TERMINAL_CONFIGURE) + if(uses_terminal) + set(uses_terminal USES_TERMINAL 1) + else() + set(uses_terminal "") + endif() + get_property(update_disconnected_set TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED SET) if(update_disconnected_set) get_property(update_disconnected TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED) @@ -2167,6 +2222,7 @@ function(_ep_add_configure_command name) DEPENDEES ${update_dep} patch DEPENDS ${file_deps} ${log} + ${uses_terminal} ) endfunction() @@ -2188,6 +2244,14 @@ function(_ep_add_build_command name) set(log "") endif() + get_property(uses_terminal TARGET ${name} PROPERTY + _EP_USES_TERMINAL_BUILD) + if(uses_terminal) + set(uses_terminal USES_TERMINAL 1) + else() + set(uses_terminal "") + endif() + get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS) if(build_always) set(always 1) @@ -2204,6 +2268,7 @@ function(_ep_add_build_command name) DEPENDEES configure ALWAYS ${always} ${log} + ${uses_terminal} ) endfunction() @@ -2225,11 +2290,20 @@ function(_ep_add_install_command name) set(log "") endif() + get_property(uses_terminal TARGET ${name} PROPERTY + _EP_USES_TERMINAL_INSTALL) + if(uses_terminal) + set(uses_terminal USES_TERMINAL 1) + else() + set(uses_terminal "") + endif() + ExternalProject_Add_Step(${name} install COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES build ${log} + ${uses_terminal} ) endfunction() @@ -2277,6 +2351,14 @@ function(_ep_add_test_command name) set(log "") endif() + get_property(uses_terminal TARGET ${name} PROPERTY + _EP_USES_TERMINAL_TEST) + if(uses_terminal) + set(uses_terminal USES_TERMINAL 1) + else() + set(uses_terminal "") + endif() + ExternalProject_Add_Step(${name} test COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} @@ -2284,6 +2366,7 @@ function(_ep_add_test_command name) ${dependers_args} ${exclude_args} ${log} + ${uses_terminal} ) endif() endfunction() diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index cc875ad..b80d3ce 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -53,6 +53,15 @@ include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake) # Search for the python framework on Apple. CMAKE_FIND_FRAMEWORKS(Python) +# Save CMAKE_FIND_FRAMEWORK +if(DEFINED CMAKE_FIND_FRAMEWORK) + set(_PythonLibs_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) +else() + unset(_PythonLibs_CMAKE_FIND_FRAMEWORK) +endif() +# To avoid picking up the system Python.h pre-maturely. +set(CMAKE_FIND_FRAMEWORK LAST) + set(_PYTHON1_VERSIONS 1.6 1.5) set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) set(_PYTHON3_VERSIONS 3.4 3.3 3.2 3.1 3.0) @@ -111,14 +120,22 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) ) endif() + set(PYTHON_FRAMEWORK_LIBRARIES) + if(Python_FRAMEWORKS AND NOT PYTHON_LIBRARY) + foreach(dir ${Python_FRAMEWORKS}) + list(APPEND PYTHON_FRAMEWORK_LIBRARIES + ${dir}/Versions/${_CURRENT_VERSION}/lib) + endforeach() + endif() find_library(PYTHON_LIBRARY NAMES - python${_CURRENT_VERSION_NO_DOTS} - python${_CURRENT_VERSION}mu - python${_CURRENT_VERSION}m - python${_CURRENT_VERSION}u - python${_CURRENT_VERSION} + python${_CURRENT_VERSION_NO_DOTS} + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} PATHS + ${PYTHON_FRAMEWORK_LIBRARIES} [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs # Avoid finding the .dll in the PATH. We want the .lib. @@ -143,8 +160,8 @@ foreach(_CURRENT_VERSION ${_Python_VERSIONS}) set(PYTHON_FRAMEWORK_INCLUDES) if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR) foreach(dir ${Python_FRAMEWORKS}) - set(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES} - ${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION}) + list(APPEND PYTHON_FRAMEWORK_INCLUDES + ${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION}) endforeach() endif() @@ -201,6 +218,14 @@ SELECT_LIBRARY_CONFIGURATIONS(PYTHON) # for historical reasons. unset(PYTHON_FOUND) +# Restore CMAKE_FIND_FRAMEWORK +if(DEFINED _PythonLibs_CMAKE_FIND_FRAMEWORK) + set(CMAKE_FIND_FRAMEWORK ${_PythonLibs_CMAKE_FIND_FRAMEWORK}) + unset(_PythonLibs_CMAKE_FIND_FRAMEWORK) +else() + unset(CMAKE_FIND_FRAMEWORK) +endif() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index fd23b92..d573101 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 3) -set(CMake_VERSION_PATCH 20150706) +set(CMake_VERSION_PATCH 20150707) #set(CMake_VERSION_RC 1) diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index e141b60..6dbb245 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -920,7 +920,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, char* data; int length; - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, + cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Each symbol represents " << tick_len << " bytes of output." << std::endl << (this->UseCTestLaunch? "" : @@ -968,7 +968,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, this->ProcessBuffer(0, 0, tick, tick_len, ofs, &this->BuildProcessingQueue); this->ProcessBuffer(0, 0, tick, tick_len, ofs, &this->BuildProcessingErrorQueue); - cmCTestOptionalLog(this->CTest, OUTPUT, " Size of output: " + cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size of output: " << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl, this->Quiet); @@ -1175,12 +1175,12 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, while ( this->BuildOutputLogSize > (tick * tick_len) ) { tick ++; - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, this->LastTickChar, - this->Quiet); + cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, + this->LastTickChar, this->Quiet); tickDisplayed = true; if ( tick % tick_line_len == 0 && tick > 0 ) { - cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " Size: " + cmCTestOptionalLog(this->CTest, HANDLER_PROGRESS_OUTPUT, " Size: " << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl << " ", this->Quiet); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 5887ba8..5676dda 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1220,7 +1220,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, char* data; int length; - cmCTestLog(this, HANDLER_OUTPUT, + cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Each . represents " << tick_len << " bytes of output" << std::endl << " " << std::flush); while(cmsysProcess_WaitForData(cp, &data, &length, 0)) @@ -1236,10 +1236,10 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, while ( output.size() > (tick * tick_len) ) { tick ++; - cmCTestLog(this, HANDLER_OUTPUT, "." << std::flush); + cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, "." << std::flush); if ( tick % tick_line_len == 0 && tick > 0 ) { - cmCTestLog(this, HANDLER_OUTPUT, + cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size: " << int((double(output.size()) / 1024.0) + 1) << "K" << std::endl @@ -1252,7 +1252,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string& output, ofs << cmCTestLogWrite(data, length); } } - cmCTestLog(this, OUTPUT, " Size of output: " + cmCTestLog(this, HANDLER_PROGRESS_OUTPUT, " Size of output: " << int(double(output.size()) / 1024.0) << "K" << std::endl); cmsysProcess_WaitForExit(cp, 0); @@ -3101,6 +3101,7 @@ static const char* cmCTestStringLogType[] = "DEBUG", "OUTPUT", "HANDLER_OUTPUT", + "HANDLER_PROGRESS_OUTPUT", "HANDLER_VERBOSE_OUTPUT", "WARNING", "ERROR_MESSAGE", @@ -3139,6 +3140,11 @@ void cmCTest::Log(int logType, const char* file, int line, const char* msg, { return; } + if ( logType == cmCTest::HANDLER_PROGRESS_OUTPUT && + ( this->Debug || this->ExtraVerbose ) ) + { + return; + } if ( this->OutputLogFile ) { bool display = true; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 47245ae..73c2807 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -382,6 +382,7 @@ public: DEBUG = 0, OUTPUT, HANDLER_OUTPUT, + HANDLER_PROGRESS_OUTPUT, HANDLER_VERBOSE_OUTPUT, WARNING, ERROR_MESSAGE, diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index f12116e..1b2586c 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -143,7 +143,7 @@ cmDependsFortran std::vector<std::string> definitions; cmMakefile* mf = this->LocalGenerator->GetMakefile(); if(const char* c_defines = - mf->GetDefinition("CMAKE_TARGET_DEFINITIONS")) + mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran")) { cmSystemTools::ExpandListArgument(c_defines, definitions); } diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index b3576c3..78853ce 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -95,6 +95,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass } cmMakefile::FunctionPushPop functionScope(this->Makefile, + this->FilePath, this->Policies); // set the value of argc diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index d2339c4..df00b30 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -87,6 +87,24 @@ public: return this->Tree->GetPointer(this->Position - 1); } + ReferenceType operator*() const + { + assert(this->Tree); + assert(this->Tree->UpPositions.size() == this->Tree->Data.size()); + assert(this->Position <= this->Tree->Data.size()); + assert(this->Position > 0); + return this->Tree->GetReference(this->Position - 1); + } + + ReferenceType operator*() + { + assert(this->Tree); + assert(this->Tree->UpPositions.size() == this->Tree->Data.size()); + assert(this->Position <= this->Tree->Data.size()); + assert(this->Position > 0); + return this->Tree->GetReference(this->Position - 1); + } + bool operator==(iterator other) const { assert(this->Tree); diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 006ca4c..1097dc2 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -251,7 +251,6 @@ bool cmListFileParser::ParseFunction(const char* name, long line) { // Inintialize a new function call. this->Function = cmListFileFunction(); - this->Function.FilePath = this->FileName; this->Function.Name = name; this->Function.Line = line; @@ -399,40 +398,50 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token, } } -void cmListFileBacktrace::Append(cmListFileContext const& context) -{ - this->push_back(context); -} - void cmListFileBacktrace::PrintTitle(std::ostream& out) { - if (this->empty()) + if (!this->Snapshot.IsValid()) { return; } - cmOutputConverter converter(this->Snapshot); - cmListFileContext lfc = this->front(); + cmListFileContext lfc = + cmListFileContext::FromCommandContext( + this->Context, this->Snapshot.GetExecutionListFile()); lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME); out << (lfc.Line ? " at " : " in ") << lfc; } void cmListFileBacktrace::PrintCallStack(std::ostream& out) { - if (size() <= 1) + if (!this->Snapshot.IsValid()) + { + return; + } + cmState::Snapshot parent = this->Snapshot.GetCallStackParent(); + if (!parent.IsValid() || parent.GetExecutionListFile().empty()) { return; } cmOutputConverter converter(this->Snapshot); - const_iterator i = this->begin() + 1; + std::string commandName = this->Snapshot.GetEntryPointCommand(); + long commandLine = this->Snapshot.GetEntryPointLine(); + out << "Call Stack (most recent call first):\n"; - while(i != this->end()) + while(parent.IsValid()) { - cmListFileContext lfc = *i; - lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME); + cmListFileContext lfc; + lfc.Name = commandName; + lfc.Line = commandLine; + + lfc.FilePath = converter.Convert(parent.GetExecutionListFile(), + cmOutputConverter::HOME); out << " " << lfc << "\n"; - ++i; + + commandName = parent.GetEntryPointCommand(); + commandLine = parent.GetEntryPointLine(); + parent = parent.GetCallStackParent(); } } diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index f5859ec..aa8a34c 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -25,6 +25,13 @@ class cmMakefile; +struct cmCommandContext +{ + std::string Name; + long Line; + cmCommandContext(): Name(), Line(0) {} +}; + struct cmListFileArgument { enum Delimiter @@ -57,6 +64,16 @@ struct cmListFileContext std::string FilePath; long Line; cmListFileContext(): Name(), FilePath(), Line(0) {} + + static cmListFileContext FromCommandContext(cmCommandContext const& lfcc, + std::string const& fileName) + { + cmListFileContext lfc; + lfc.FilePath = fileName; + lfc.Line = lfcc.Line; + lfc.Name = lfcc.Name; + return lfc; + } }; std::ostream& operator<<(std::ostream&, cmListFileContext const&); @@ -64,24 +81,24 @@ bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs); bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs); bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs); -struct cmListFileFunction: public cmListFileContext +struct cmListFileFunction: public cmCommandContext { std::vector<cmListFileArgument> Arguments; }; -class cmListFileBacktrace: private std::vector<cmListFileContext> +class cmListFileBacktrace { public: - cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot()) - : Snapshot(snapshot) + cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(), + cmCommandContext const& cc = cmCommandContext()) + : Context(cc), Snapshot(snapshot) { } - void Append(cmListFileContext const& context); - void PrintTitle(std::ostream& out); void PrintCallStack(std::ostream& out); private: + cmCommandContext Context; cmState::Snapshot Snapshot; }; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 0b945b2..6d3054a 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -97,6 +97,7 @@ bool cmMacroHelperCommand::InvokeInitialPass } cmMakefile::MacroPushPop macroScope(this->Makefile, + this->FilePath, this->Policies); // set the value of argc @@ -131,7 +132,6 @@ bool cmMacroHelperCommand::InvokeInitialPass newLFF.Arguments.clear(); newLFF.Arguments.reserve(this->Functions[c].Arguments.size()); newLFF.Name = this->Functions[c].Name; - newLFF.FilePath = this->Functions[c].FilePath; newLFF.Line = this->Functions[c].Line; // for each argument of the current function diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index cdcf88c..94c77e1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -247,11 +247,11 @@ void cmMakefile::IssueMessage(cmake::MessageType t, std::string const& text) const { // Collect context information. - if(!this->CallStack.empty()) + if(!this->ExecutionStatusStack.empty()) { if((t == cmake::FATAL_ERROR) || (t == cmake::INTERNAL_ERROR)) { - this->CallStack.back().Status->SetNestedError(true); + this->ExecutionStatusStack.back()->SetNestedError(true); } this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace()); } @@ -275,33 +275,29 @@ void cmMakefile::IssueMessage(cmake::MessageType t, //---------------------------------------------------------------------------- cmListFileBacktrace cmMakefile::GetBacktrace() const { - cmListFileBacktrace backtrace(this->StateSnapshot); - for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin(); - i != this->CallStack.rend(); ++i) + cmListFileBacktrace backtrace; + if (!this->ContextStack.empty()) { - backtrace.Append(*i->Context); + backtrace = cmListFileBacktrace(this->StateSnapshot, + *this->ContextStack.back()); } return backtrace; } //---------------------------------------------------------------------------- cmListFileBacktrace -cmMakefile::GetBacktrace(cmListFileContext const& lfc) const +cmMakefile::GetBacktrace(cmCommandContext const& cc) const { - cmListFileBacktrace backtrace(this->StateSnapshot); - backtrace.Append(lfc); - for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin(); - i != this->CallStack.rend(); ++i) - { - backtrace.Append(*i->Context); - } - return backtrace; + cmState::Snapshot snp = this->StateSnapshot; + return cmListFileBacktrace(snp, cc); } //---------------------------------------------------------------------------- cmListFileContext cmMakefile::GetExecutionContext() const { - return *this->CallStack.back().Context; + return cmListFileContext::FromCommandContext( + *this->ContextStack.back(), + this->StateSnapshot.GetExecutionListFile()); } //---------------------------------------------------------------------------- @@ -461,11 +457,22 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, this->Makefile->PushPolicyBarrier(); this->Makefile->ListFileStack.push_back(filenametoread); this->Makefile->PushFunctionBlockerBarrier(); + + this->Makefile->StateSnapshot = + this->Makefile->GetState()->CreateCallStackSnapshot( + this->Makefile->StateSnapshot, + this->Makefile->ContextStack.back()->Name, + this->Makefile->ContextStack.back()->Line, + filenametoread); } //---------------------------------------------------------------------------- cmMakefile::IncludeScope::~IncludeScope() { + this->Makefile->StateSnapshot = + this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); + assert(this->Makefile->StateSnapshot.IsValid()); + this->Makefile->PopFunctionBlockerBarrier(this->ReportError); // Enforce matching policy scopes inside the included file. this->Makefile->PopPolicyBarrier(this->ReportError); @@ -534,6 +541,25 @@ void cmMakefile::IncludeScope::EnforceCMP0011() } } +class cmParseFileScope +{ +public: + cmParseFileScope(cmMakefile* mf) + : Makefile(mf) + { + this->Makefile->ContextStack.push_back(&this->Context); + } + + ~cmParseFileScope() + { + this->Makefile->ContextStack.pop_back(); + } + +private: + cmMakefile* Makefile; + cmCommandContext Context; +}; + bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope) { this->AddDefinition("CMAKE_PARENT_LIST_FILE", @@ -545,10 +571,14 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope) IncludeScope incScope(this, filenametoread, noPolicyScope); cmListFile listFile; + { + cmParseFileScope pfs(this); if (!listFile.ParseFile(filenametoread.c_str(), false, this)) { return false; } + } + this->ReadListFile(listFile, filenametoread); if(cmSystemTools::GetFatalErrorOccured()) { @@ -565,11 +595,27 @@ public: { this->Makefile->ListFileStack.push_back(filenametoread); this->Makefile->PushPolicyBarrier(); + + long line = 0; + std::string name; + if (!this->Makefile->ContextStack.empty()) + { + line = this->Makefile->ContextStack.back()->Line; + name = this->Makefile->ContextStack.back()->Name; + } + this->Makefile->StateSnapshot = + this->Makefile->GetState()->CreateInlineListFileSnapshot( + this->Makefile->StateSnapshot, name, line, filenametoread); + assert(this->Makefile->StateSnapshot.IsValid()); this->Makefile->PushFunctionBlockerBarrier(); } ~ListFileScope() { + this->Makefile->StateSnapshot = + this->Makefile->GetState()->Pop(this->Makefile->StateSnapshot); + assert(this->Makefile->StateSnapshot.IsValid()); + this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopPolicyBarrier(this->ReportError); this->Makefile->ListFileStack.pop_back(); @@ -590,10 +636,13 @@ bool cmMakefile::ReadListFile(const char* filename) ListFileScope scope(this, filenametoread); cmListFile listFile; + { + cmParseFileScope pfs(this); if (!listFile.ParseFile(filenametoread.c_str(), false, this)) { return false; } + } this->ReadListFile(listFile, filenametoread); if(cmSystemTools::GetFatalErrorOccured()) @@ -1571,8 +1620,16 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) this->ImportedTargets = parent->ImportedTargets; } -void cmMakefile::PushFunctionScope(const cmPolicies::PolicyMap& pm) +void cmMakefile::PushFunctionScope(std::string const& fileName, + const cmPolicies::PolicyMap& pm) { + this->StateSnapshot = + this->GetState()->CreateFunctionCallSnapshot( + this->StateSnapshot, + this->ContextStack.back()->Name, this->ContextStack.back()->Line, + fileName); + assert(this->StateSnapshot.IsValid()); + this->Internal->PushDefinitions(); this->PushLoopBlockBarrier(); @@ -1592,6 +1649,9 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopPolicyBarrier(reportError); this->PopPolicy(); + this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); + this->PopFunctionBlockerBarrier(reportError); #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1605,8 +1665,16 @@ void cmMakefile::PopFunctionScope(bool reportError) this->Internal->PopDefinitions(); } -void cmMakefile::PushMacroScope(const cmPolicies::PolicyMap& pm) +void cmMakefile::PushMacroScope(std::string const& fileName, + const cmPolicies::PolicyMap& pm) { + this->StateSnapshot = + this->GetState()->CreateMacroCallSnapshot( + this->StateSnapshot, + this->ContextStack.back()->Name, this->ContextStack.back()->Line, + fileName); + assert(this->StateSnapshot.IsValid()); + this->PushFunctionBlockerBarrier(); this->PushPolicy(true, pm); @@ -1618,6 +1686,9 @@ void cmMakefile::PopMacroScope(bool reportError) this->PopPolicyBarrier(reportError); this->PopPolicy(); + this->StateSnapshot = this->GetState()->Pop(this->StateSnapshot); + assert(this->StateSnapshot.IsValid()); + this->PopFunctionBlockerBarrier(reportError); } @@ -1635,6 +1706,7 @@ public: std::string currentStart = this->Makefile->StateSnapshot.GetCurrentSourceDirectory(); currentStart += "/CMakeLists.txt"; + this->Makefile->StateSnapshot.SetListFile(currentStart); this->Makefile->ListFileStack.push_back(currentStart); this->Makefile->PushPolicyBarrier(); this->Makefile->PushFunctionBlockerBarrier(); @@ -1686,11 +1758,14 @@ void cmMakefile::Configure() this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str()); cmListFile listFile; + { + cmParseFileScope pfs(this); if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), this)) { this->SetConfigured(); return; } + } this->ReadListFile(listFile, currentStart); if(cmSystemTools::GetFatalErrorOccured()) { @@ -1778,7 +1853,9 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, } cmState::Snapshot newSnapshot = this->GetState() - ->CreateBuildsystemDirectorySnapshot(this->StateSnapshot); + ->CreateBuildsystemDirectorySnapshot(this->StateSnapshot, + this->ContextStack.back()->Name, + this->ContextStack.back()->Line); // create a new local generator and set its parent cmLocalGenerator *lg2 = this->GetGlobalGenerator() @@ -1996,7 +2073,7 @@ void cmMakefile::LogUnused(const char* reason, { std::string path; cmListFileContext lfc; - if (!this->CallStack.empty()) + if (!this->ExecutionStatusStack.empty()) { lfc = this->GetExecutionContext(); path = lfc.FilePath; @@ -3360,11 +3437,12 @@ bool cmMakefile::IsLoopBlock() const std::string cmMakefile::GetExecutionFilePath() const { - if (this->CallStack.empty()) + if (this->ContextStack.empty()) { return std::string(); } - return this->CallStack.back().Context->FilePath; + assert(this->StateSnapshot.IsValid()); + return this->StateSnapshot.GetExecutionListFile(); } //---------------------------------------------------------------------------- @@ -3455,7 +3533,7 @@ bool cmMakefile::ExpandArguments( //---------------------------------------------------------------------------- void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb) { - if(!this->CallStack.empty()) + if(!this->ExecutionStatusStack.empty()) { // Record the context in which the blocker is created. fb->SetStartingContext(this->GetExecutionContext()); @@ -3488,11 +3566,13 @@ cmMakefile::RemoveFunctionBlocker(cmFunctionBlocker* fb, if(!(*pos)->ShouldRemove(lff, *this)) { cmListFileContext const& lfc = fb->GetStartingContext(); + cmListFileContext closingContext = + cmListFileContext::FromCommandContext(lff, lfc.FilePath); std::ostringstream e; e << "A logical block opening on the line\n" << " " << lfc << "\n" << "closes on the line\n" - << " " << lff << "\n" + << " " << closingContext << "\n" << "with mis-matching arguments."; this->IssueMessage(cmake::AUTHOR_WARNING, e.str()); } @@ -5476,10 +5556,11 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf, + const std::string& fileName, cmPolicies::PolicyMap const& pm) : Makefile(mf), ReportError(true) { - this->Makefile->PushFunctionScope(pm); + this->Makefile->PushFunctionScope(fileName, pm); } cmMakefile::FunctionPushPop::~FunctionPushPop() @@ -5489,10 +5570,11 @@ cmMakefile::FunctionPushPop::~FunctionPushPop() cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf, + const std::string& fileName, const cmPolicies::PolicyMap& pm) : Makefile(mf), ReportError(true) { - this->Makefile->PushMacroScope(pm); + this->Makefile->PushMacroScope(fileName, pm); } cmMakefile::MacroPushPop::~MacroPushPop() @@ -5500,14 +5582,15 @@ cmMakefile::MacroPushPop::~MacroPushPop() this->Makefile->PopMacroScope(this->ReportError); } -cmMakefileCall::cmMakefileCall(cmMakefile* mf, const cmListFileContext& lfc, +cmMakefileCall::cmMakefileCall(cmMakefile* mf, const cmCommandContext& lfc, cmExecutionStatus& status): Makefile(mf) { - cmMakefile::CallStackEntry entry = {&lfc, &status}; - this->Makefile->CallStack.push_back(entry); + this->Makefile->ContextStack.push_back(&lfc); + this->Makefile->ExecutionStatusStack.push_back(&status); } cmMakefileCall::~cmMakefileCall() { - this->Makefile->CallStack.pop_back(); + this->Makefile->ExecutionStatusStack.pop_back(); + this->Makefile->ContextStack.pop_back(); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index aa70c72..82a2279 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -547,7 +547,7 @@ public: * Get the current context backtrace. */ cmListFileBacktrace GetBacktrace() const; - cmListFileBacktrace GetBacktrace(cmListFileContext const& lfc) const; + cmListFileBacktrace GetBacktrace(cmCommandContext const& lfc) const; cmListFileContext GetExecutionContext() const; /** @@ -720,7 +720,7 @@ public: class FunctionPushPop { public: - FunctionPushPop(cmMakefile* mf, + FunctionPushPop(cmMakefile* mf, std::string const& fileName, cmPolicies::PolicyMap const& pm); ~FunctionPushPop(); @@ -733,8 +733,8 @@ public: class MacroPushPop { public: - MacroPushPop(cmMakefile* mf, - cmPolicies::PolicyMap const& pm); + MacroPushPop(cmMakefile* mf, std::string const& fileName, + cmPolicies::PolicyMap const& pm); ~MacroPushPop(); void Quiet() { this->ReportError = false; } @@ -743,9 +743,11 @@ public: bool ReportError; }; - void PushFunctionScope(cmPolicies::PolicyMap const& pm); + void PushFunctionScope(std::string const& fileName, + cmPolicies::PolicyMap const& pm); void PopFunctionScope(bool reportError); - void PushMacroScope(cmPolicies::PolicyMap const& pm); + void PushMacroScope(std::string const& fileName, + cmPolicies::PolicyMap const& pm); void PopMacroScope(bool reportError); void PushScope(); void PopScope(); @@ -935,15 +937,10 @@ private: // stack of list files being read std::vector<std::string> ListFileStack; - // stack of commands being invoked. - struct CallStackEntry - { - cmListFileContext const* Context; - cmExecutionStatus* Status; - }; - typedef std::vector<CallStackEntry> CallStackType; - CallStackType CallStack; + std::vector<cmCommandContext const*> ContextStack; + std::vector<cmExecutionStatus*> ExecutionStatusStack; friend class cmMakefileCall; + friend class cmParseFileScope; std::vector<cmTarget*> ImportedTargetsOwned; TargetMap ImportedTargets; @@ -1058,7 +1055,7 @@ class cmMakefileCall { public: cmMakefileCall(cmMakefile* mf, - cmListFileContext const& lfc, + cmCommandContext const& lfc, cmExecutionStatus& status); ~cmMakefileCall(); private: diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 58500cc..d918f65 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -20,10 +20,14 @@ struct cmState::SnapshotDataType { + cmState::PositionType CallStackParent; cmState::PositionType DirectoryParent; cmState::SnapshotType SnapshotType; + cmLinkedTree<std::string>::iterator ExecutionListFile; cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator BuildSystemDirectory; + std::string EntryPointCommand; + long EntryPointLine; }; struct cmState::BuildsystemDirectoryStateType @@ -226,6 +230,7 @@ cmState::Snapshot cmState::Reset() this->BuildsystemDirectory.Truncate(); PositionType pos = this->SnapshotData.Truncate(); + this->ExecutionListFiles.Truncate(); this->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, @@ -682,22 +687,113 @@ cmState::Snapshot cmState::CreateBaseSnapshot() pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root()); + pos->ExecutionListFile = + this->ExecutionListFiles.Extend(this->ExecutionListFiles.Root()); return cmState::Snapshot(this, pos); } cmState::Snapshot -cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot) +cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine) { assert(originSnapshot.IsValid()); PositionType pos = this->SnapshotData.Extend(originSnapshot.Position); + pos->CallStackParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; pos->SnapshotType = BuildsystemDirectoryType; pos->BuildSystemDirectory = this->BuildsystemDirectory.Extend( originSnapshot.Position->BuildSystemDirectory); + pos->ExecutionListFile = + this->ExecutionListFiles.Extend( + originSnapshot.Position->ExecutionListFile); return cmState::Snapshot(this, pos); } +cmState::Snapshot +cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->CallStackParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; + pos->SnapshotType = FunctionCallType; + pos->ExecutionListFile = this->ExecutionListFiles.Extend( + originSnapshot.Position->ExecutionListFile, fileName); + return cmState::Snapshot(this, pos); +} + + +cmState::Snapshot +cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->CallStackParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; + pos->SnapshotType = MacroCallType; + pos->ExecutionListFile = this->ExecutionListFiles.Extend( + originSnapshot.Position->ExecutionListFile, fileName); + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot +cmState::CreateCallStackSnapshot(cmState::Snapshot originSnapshot, + const std::string& entryPointCommand, + long entryPointLine, + const std::string& fileName) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->CallStackParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; + pos->SnapshotType = CallStackType; + pos->ExecutionListFile = this->ExecutionListFiles.Extend( + originSnapshot.Position->ExecutionListFile, fileName); + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot +cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, + const std::string& entryPointCommand, + long entryPointLine, + const std::string& fileName) +{ + PositionType pos = this->SnapshotData.Extend(originSnapshot.Position, + *originSnapshot.Position); + pos->CallStackParent = originSnapshot.Position; + pos->EntryPointLine = entryPointLine; + pos->EntryPointCommand = entryPointCommand; + pos->SnapshotType = InlineListFileType; + pos->ExecutionListFile = this->ExecutionListFiles.Extend( + originSnapshot.Position->ExecutionListFile, fileName); + return cmState::Snapshot(this, pos); +} + +cmState::Snapshot cmState::Pop(cmState::Snapshot originSnapshot) +{ + PositionType pos = originSnapshot.Position; + PositionType prevPos = pos; + ++prevPos; + if (prevPos == this->SnapshotData.Root()) + { + return Snapshot(this, prevPos); + } + return Snapshot(this, originSnapshot.Position->CallStackParent); +} + cmState::Snapshot::Snapshot(cmState* state, PositionType position) : State(state), Position(position) @@ -742,6 +838,11 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir) this->ComputeRelativePathTopBinary(); } +void cmState::Snapshot::SetListFile(const std::string& listfile) +{ + *this->Position->ExecutionListFile = listfile; +} + std::vector<std::string> const& cmState::Snapshot::GetCurrentSourceDirectoryComponents() const { @@ -776,6 +877,21 @@ void cmState::Snapshot::SetRelativePathTopBinary(const char* dir) this->Position->BuildSystemDirectory->RelativePathTopBinary = dir; } +std::string cmState::Snapshot::GetExecutionListFile() const +{ + return *this->Position->ExecutionListFile; +} + +std::string cmState::Snapshot::GetEntryPointCommand() const +{ + return this->Position->EntryPointCommand; +} + +long cmState::Snapshot::GetEntryPointLine() const +{ + return this->Position->EntryPointLine; +} + bool cmState::Snapshot::IsValid() const { return this->State && this->Position.IsValid() @@ -799,6 +915,28 @@ cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const return snapshot; } +cmState::Snapshot cmState::Snapshot::GetCallStackParent() const +{ + assert(this->State); + assert(this->Position != this->State->SnapshotData.Root()); + + Snapshot snapshot; + if (this->Position->SnapshotType == cmState::BuildsystemDirectoryType) + { + return snapshot; + } + + PositionType parentPos = this->Position; + ++parentPos; + if (parentPos == this->State->SnapshotData.Root()) + { + return snapshot; + } + + snapshot = Snapshot(this->State, parentPos); + return snapshot; +} + cmState* cmState::Snapshot::GetState() const { return this->State; diff --git a/Source/cmState.h b/Source/cmState.h index 9c7574f..473a194 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -31,7 +31,11 @@ public: enum SnapshotType { - BuildsystemDirectoryType + BuildsystemDirectoryType, + FunctionCallType, + MacroCallType, + CallStackType, + InlineListFileType }; class Snapshot { @@ -43,6 +47,8 @@ public: const char* GetCurrentBinaryDirectory() const; void SetCurrentBinaryDirectory(std::string const& dir); + void SetListFile(std::string const& listfile); + std::vector<std::string> const& GetCurrentSourceDirectoryComponents() const; std::vector<std::string> const& @@ -53,8 +59,13 @@ public: void SetRelativePathTopSource(const char* dir); void SetRelativePathTopBinary(const char* dir); + std::string GetExecutionListFile() const; + std::string GetEntryPointCommand() const; + long GetEntryPointLine() const; + bool IsValid() const; Snapshot GetBuildsystemDirectoryParent() const; + Snapshot GetCallStackParent() const; cmState* GetState() const; @@ -69,7 +80,27 @@ public: }; Snapshot CreateBaseSnapshot(); - Snapshot CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot); + Snapshot + CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine); + Snapshot CreateFunctionCallSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName); + Snapshot CreateMacroCallSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName); + Snapshot CreateCallStackSnapshot(Snapshot originSnapshot, + std::string const& entryPointCommand, + long entryPointLine, + std::string const& fileName); + Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, + const std::string& entryPointCommand, + long entryPointLine, + std::string const& fileName); + Snapshot Pop(Snapshot originSnapshot); enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC, UNINITIALIZED }; @@ -175,6 +206,8 @@ private: struct BuildsystemDirectoryStateType; cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory; + cmLinkedTree<std::string> ExecutionListFiles; + cmLinkedTree<SnapshotDataType> SnapshotData; std::vector<std::string> SourceDirectoryComponents; diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx index 6521c04..98a397c 100644 --- a/Source/cmVariableWatchCommand.cxx +++ b/Source/cmVariableWatchCommand.cxx @@ -63,7 +63,6 @@ static void cmVariableWatchCommandVariableAccessed( cmListFileArgument(stack, cmListFileArgument::Quoted, 9999)); newLFF.Name = data->Command; - newLFF.FilePath = "unknown"; newLFF.Line = 9999; cmExecutionStatus status; if(!makefile->ExecuteCommand(newLFF,status)) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 8700c94..753ce27 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -168,7 +168,7 @@ if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) add_definitions(-DFOO -DBAR=1) include_directories(${testf_SOURCE_DIR}/include) - add_executable(test_preprocess test_preprocess.F90) + add_executable(test_preprocess test_preprocess.F90 test_preprocess_module.F90) set(TEST_MODULE_DEPENDS 1) endif() diff --git a/Tests/Fortran/test_preprocess.F90 b/Tests/Fortran/test_preprocess.F90 index e4f1fbe..3a09976 100644 --- a/Tests/Fortran/test_preprocess.F90 +++ b/Tests/Fortran/test_preprocess.F90 @@ -46,6 +46,8 @@ PROGRAM PPTEST #endif ! 0 ; <empty> +USE PPAvailable + #include "test_preprocess.h" END PROGRAM diff --git a/Tests/Fortran/test_preprocess_module.F90 b/Tests/Fortran/test_preprocess_module.F90 new file mode 100644 index 0000000..5849b62 --- /dev/null +++ b/Tests/Fortran/test_preprocess_module.F90 @@ -0,0 +1,5 @@ +#ifdef FOO +MODULE PPAvailable +! no conent +END MODULE +#endif diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake index e038409..47d6129 100644 --- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake @@ -11,3 +11,4 @@ run_cmake(Add_StepDependencies) run_cmake(Add_StepDependencies_iface) run_cmake(Add_StepDependencies_iface_step) run_cmake(Add_StepDependencies_no_target) +run_cmake(UsesTerminal) diff --git a/Tests/RunCMake/ExternalProject/UsesTerminal-check.cmake b/Tests/RunCMake/ExternalProject/UsesTerminal-check.cmake new file mode 100644 index 0000000..201d822 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/UsesTerminal-check.cmake @@ -0,0 +1,97 @@ +cmake_minimum_required(VERSION 3.3) + +# If we are using the Ninja generator, we can check and verify that the +# USES_TERMINAL option actually works by examining the Ninja build file. +# This is the only way, since CMake doesn't offer a way to examine the +# options on a custom command after it has been added. Furthermore, +# there isn't an easy way to test for this by actually running Ninja. +# +# Other generators don't currently support USES_TERMINAL at this time. +# This file can be improved to support them if they do. Until then, we +# simply assume success for new generator types. +# +# For Ninja, there is a complication. If the Ninja generator detects a +# version of Ninja < 1.5, it won't actually emit the console pool command, +# because those Ninja versions don't yet support the console pool. In +# that case, we also have to assume success. + +# Check Ninja build output to verify whether or not a target step is in the +# console pool. +macro(CheckNinjaStep _target _step _require) + if("${_build}" MATCHES +" DESC = Performing ${_step} step for '${_target}' + pool = console" + ) + if(NOT ${_require}) + set(RunCMake_TEST_FAILED "${_target} ${_step} step is in console pool") + return() + endif() + else() + if(${_require}) + set(RunCMake_TEST_FAILED "${_target} ${_step} step not in console pool") + return() + endif() + endif() +endmacro() + +# Check Ninja build output to verify whether each target step is in the +# console pool. +macro(CheckNinjaTarget _target + _download _update _configure _build _test _install + ) + CheckNinjaStep(${_target} download ${_download}) + CheckNinjaStep(${_target} update ${_update}) + CheckNinjaStep(${_target} configure ${_configure}) + CheckNinjaStep(${_target} build ${_build}) + CheckNinjaStep(${_target} test ${_test}) + CheckNinjaStep(${_target} install ${_install}) +endmacro() + +# Load build/make file, depending on generator +if(RunCMake_GENERATOR STREQUAL Ninja) + # Check the Ninja version. If < 1.5, console pool isn't supported and + # so the generator would not emit console pool usage. That would cause + # this test to fail. + execute_process(COMMAND ${RunCMake_MAKE_PROGRAM} --version + RESULT_VARIABLE _version_result + OUTPUT_VARIABLE _version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(_version_result OR _version VERSION_EQUAL "0") + set(RunCMake_TEST_FAILED "Failed to get Ninja version") + return() + endif() + if(_version VERSION_LESS "1.5") + return() # console pool not supported on Ninja < 1.5 + endif() + + # Read the Ninja build file + set(_build_file "${RunCMake_TEST_BINARY_DIR}/build.ninja") + + if(NOT EXISTS "${_build_file}") + set(RunCMake_TEST_FAILED "Ninja build file not created") + return() + endif() + + file(READ "${_build_file}" _build) + + set(_target_check_macro CheckNinjaTarget) +elseif((RunCMake_GENERATOR STREQUAL "") OR NOT DEFINED RunCMake_GENERATOR) + # protection in case somebody renamed RunCMake_GENERATOR + set(RunCMake_TEST_FAILED "Unknown generator") + return() +else() + # We don't yet know how to test USES_TERMINAL on this generator. + return() +endif() + +# Actual tests: +CheckNinjaTarget(TerminalTest1 + true true true true true true ) +CheckNinjaTarget(TerminalTest2 + true false true false true false) +CheckNinjaTarget(TerminalTest3 + false true false true false true ) +CheckNinjaTarget(TerminalTest4 + false false false false false false) diff --git a/Tests/RunCMake/ExternalProject/UsesTerminal.cmake b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake new file mode 100644 index 0000000..cd87403 --- /dev/null +++ b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake @@ -0,0 +1,45 @@ +if(NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE Debug) +endif() +include(ExternalProject) + +# Test various combinations of USES_TERMINAL with ExternalProject_Add. + +macro(DoTerminalTest _target) + ExternalProject_Add(${_target} + DOWNLOAD_COMMAND "${CMAKE_COMMAND}" -E echo "download" + UPDATE_COMMAND "${CMAKE_COMMAND}" -E echo "update" + CONFIGURE_COMMAND "${CMAKE_COMMAND}" -E echo "configure" + BUILD_COMMAND "${CMAKE_COMMAND}" -E echo "build" + TEST_COMMAND "${CMAKE_COMMAND}" -E echo "test" + INSTALL_COMMAND "${CMAKE_COMMAND}" -E echo "install" + ${ARGN} + ) +endmacro() + +# USES_TERMINAL on all steps +DoTerminalTest(TerminalTest1 + USES_TERMINAL_DOWNLOAD 1 + USES_TERMINAL_UPDATE 1 + USES_TERMINAL_CONFIGURE 1 + USES_TERMINAL_BUILD 1 + USES_TERMINAL_TEST 1 + USES_TERMINAL_INSTALL 1 + ) + +# USES_TERMINAL on every other step, starting with download +DoTerminalTest(TerminalTest2 + USES_TERMINAL_DOWNLOAD 1 + USES_TERMINAL_CONFIGURE 1 + USES_TERMINAL_TEST 1 + ) + +# USES_TERMINAL on every other step, starting with update +DoTerminalTest(TerminalTest3 + USES_TERMINAL_UPDATE 1 + USES_TERMINAL_BUILD 1 + USES_TERMINAL_INSTALL 1 + ) + +# USES_TERMINAL on no step +DoTerminalTest(TerminalTest4) diff --git a/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt index b3f1e47..a845ffb 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-16-BE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-16-BE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-16-BE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt index c08c902..cc4244b 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-16-LE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-16-LE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-16-LE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt index 5dde4e3..5f851bf 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-32-BE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-32-BE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-32-BE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt b/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt index eb054ec..d8fafd0 100644 --- a/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt +++ b/Tests/RunCMake/Syntax/BOM-UTF-32-LE-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BOM-UTF-32-LE.cmake: File .*/Tests/RunCMake/Syntax/BOM-UTF-32-LE.cmake starts with a Byte-Order-Mark that is not UTF-8. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt index afd91f9..a288280 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace0-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace0.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace0.cmake:1:27 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt index 826e511..391e11b 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace1-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace1.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace1.cmake:1:24 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt index 23ecdcd..acaf7fe 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace2-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace2.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace2.cmake:1:44 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt index 906d6fc..f12b2e5 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace3-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace3.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace3.cmake:1:45 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt index a461e93..7157763 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace4-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace4.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace4.cmake:1:44 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt b/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt index ff8bf1c..c13969d 100644 --- a/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt +++ b/Tests/RunCMake/Syntax/BracketNoSpace5-stderr.txt @@ -1,6 +1,8 @@ -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in BracketNoSpace5.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/BracketNoSpace5.cmake:1:45 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt index 7ecfe11..37c5d6e 100644 --- a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt +++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt @@ -1,9 +1,11 @@ -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in ParenInENV.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error at ParenInENV.cmake:2 \(message\): diff --git a/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt b/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt index 64ef8b1..45b2e6a 100644 --- a/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt +++ b/Tests/RunCMake/Syntax/ParenNoSpace1-stderr.txt @@ -1,22 +1,28 @@ -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in ParenNoSpace1.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:1:26 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in ParenNoSpace1.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:2:26 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. -CMake Error at CMakeLists.txt:3 \(include\): +CMake Error in ParenNoSpace1.cmake: Syntax Error in cmake code at .*/Tests/RunCMake/Syntax/ParenNoSpace1.cmake:3:29 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt b/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt index 89c2d2a..a4ec6e7 100644 --- a/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt +++ b/Tests/RunCMake/Syntax/StringNoSpace-stderr.txt @@ -1,17 +1,21 @@ -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in StringNoSpace.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/StringNoSpace.cmake:2:28 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. -CMake Warning \(dev\) at CMakeLists.txt:3 \(include\): +CMake Warning \(dev\) in StringNoSpace.cmake: Syntax Warning in cmake code at .*/Tests/RunCMake/Syntax/StringNoSpace.cmake:2:31 Argument not separated from preceding token by whitespace. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) This warning is for project developers. Use -Wno-dev to suppress it. \[1 \${var} \\n 4\] |