diff options
86 files changed, 935 insertions, 805 deletions
diff --git a/Help/command/if.rst b/Help/command/if.rst index a682c83..a48a0fa 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -23,7 +23,7 @@ Otherwise, optional ``elseif`` blocks are processed in the same way. Finally, if no ``condition`` is true, ``commands`` in the optional ``else`` block are executed. -Per legacy, the :command:`else` and :command:`elseif` commands admit +Per legacy, the :command:`else` and :command:`endif` commands admit an optional ``<condition>`` argument. If used, it must be a verbatim repeat of the argument of the opening diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake index b3c96ee..d34154c 100644 --- a/Modules/Compiler/Cray-C.cmake +++ b/Modules/Compiler/Cray-C.cmake @@ -8,13 +8,13 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) - set(CMAKE_C90_STANDARD_COMPILE_OPTION "-h noc99,conform") - set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-h noc99,gnu") - set(CMAKE_C99_STANDARD_COMPILE_OPTION "-h c99,conform") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-h c99,gnu") + set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform) + set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu) + set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform) + set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-h std=c11,conform") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-h std=c11,gnu") + set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform) + set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu) endif () endif () diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake index bbb5718..85a3167 100644 --- a/Modules/Compiler/Cray-CXX.cmake +++ b/Modules/Compiler/Cray-CXX.cmake @@ -8,15 +8,15 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-h conform") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-h gnu") + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -h conform) + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -h gnu) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-h std=c++11") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-h std=c++11,gnu") + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11) + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6) - set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-h std=c++14") - set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-h std=c++14,gnu") + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14) + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu) endif () endif () diff --git a/Modules/Compiler/Flang-Fortran.cmake b/Modules/Compiler/Flang-Fortran.cmake index d522739..f0e61d8 100644 --- a/Modules/Compiler/Flang-Fortran.cmake +++ b/Modules/Compiler/Flang-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/Clang) __compiler_clang(Fortran) +set(CMAKE_Fortran_SUBMODULE_SEP "-") +set(CMAKE_Fortran_SUBMODULE_EXT ".mod") + set(CMAKE_Fortran_PREPROCESS_SOURCE "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake index c333d50..6413769 100644 --- a/Modules/Compiler/GNU-Fortran.cmake +++ b/Modules/Compiler/GNU-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/GNU) __compiler_gnu(Fortran) +set(CMAKE_Fortran_SUBMODULE_SEP "@") +set(CMAKE_Fortran_SUBMODULE_EXT ".smod") + set(CMAKE_Fortran_PREPROCESS_SOURCE "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>") diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake index a132055..5275ddf 100644 --- a/Modules/Compiler/Intel-Fortran.cmake +++ b/Modules/Compiler/Intel-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/Intel) __compiler_intel(Fortran) +set(CMAKE_Fortran_SUBMODULE_SEP "@") +set(CMAKE_Fortran_SUBMODULE_EXT ".smod") + set(CMAKE_Fortran_MODDIR_FLAG "-module ") set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake index a183c33..3daf798 100644 --- a/Modules/Compiler/PGI-Fortran.cmake +++ b/Modules/Compiler/PGI-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/PGI) __compiler_pgi(Fortran) +set(CMAKE_Fortran_SUBMODULE_SEP "-") +set(CMAKE_Fortran_SUBMODULE_EXT ".mod") + set(CMAKE_Fortran_PREPROCESS_SOURCE "<CMAKE_Fortran_COMPILER> -Mpreprocess <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index 6bab6f6..c4fb097 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/XL) __compiler_xl(Fortran) +set(CMAKE_Fortran_SUBMODULE_SEP "_") +set(CMAKE_Fortran_SUBMODULE_EXT ".smod") + set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>] set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm] diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index 1a2af16..47c0e79 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -18,7 +18,7 @@ Result variables This module will set the following variables in your project: -``LIBXML2_FOUND`` +``LibXml2_FOUND`` true if libxml2 headers and libraries were found ``LIBXML2_INCLUDE_DIR`` the directory containing LibXml2 headers diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 8544653..3547642 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -725,7 +725,7 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve file(REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp") set(index -1) - string(FIND ${_matlab_version_from_cmd} "ans" index) + string(FIND "${_matlab_version_from_cmd}" "ans" index) if(index EQUAL -1) if(MATLAB_FIND_DEBUG) @@ -735,7 +735,7 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve else() set(matlab_list_of_all_versions_tmp) - string(SUBSTRING ${_matlab_version_from_cmd} ${index} -1 substring_ans) + string(SUBSTRING "${_matlab_version_from_cmd}" ${index} -1 substring_ans) string( REGEX MATCHALL "ans[\r\n\t ]*=[\r\n\t ]*'?([0-9]+(\\.[0-9]+)?)" matlab_versions_regex diff --git a/Modules/FindOctave.cmake b/Modules/FindOctave.cmake index 8ae6a47..8110ff1 100644 --- a/Modules/FindOctave.cmake +++ b/Modules/FindOctave.cmake @@ -15,7 +15,10 @@ This module defines the following :prop_tgt:`IMPORTED` targets: ``Octave::Interpreter`` Octave interpreter (the main program) ``Octave::Octave`` - include directories and libraries + include directories and the octave library +``Octave::Octinterp`` + include directories and the octinterp library including the dependency on + Octave::Octave If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed. @@ -144,6 +147,15 @@ if(Octave_Development_FOUND) ) endif() + if(NOT TARGET Octave::Octinterp) + add_library(Octave::Octinterp UNKNOWN IMPORTED) + set_target_properties(Octave::Octinterp PROPERTIES + IMPORTED_LOCATION ${Octave_INTERP_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${Octave_INCLUDE_DIR}) + target_link_libraries(Octave::Octinterp INTERFACE + Octave::Octave) + endif() + endif() diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index a73ffba..5590433 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -214,7 +214,7 @@ include(Platform/UnixPaths) if(_CMAKE_OSX_SYSROOT_PATH AND EXISTS ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_CMAKE_OSX_SYSROOT_PATH}/usr) foreach(lang C CXX) - list(APPEND CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) + list(APPEND _CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES_INIT ${_CMAKE_OSX_SYSROOT_PATH}/usr/include) endforeach() endif() list(APPEND CMAKE_SYSTEM_PREFIX_PATH diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index 4ae4514..46c24bb 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -63,11 +63,6 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64 ) -# Platform-wide directories to avoid adding via -I<dir>. -list(APPEND CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES - /usr/include - ) - # Default per-language values. These may be later replaced after # parsing the implicit directory information from compiler output. set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 6c6b3a0..e69ceb9 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 14) -set(CMake_VERSION_PATCH 20190211) +set(CMake_VERSION_PATCH 20190215) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index b4c05ab..fc34ef8 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -43,7 +43,8 @@ cmCPackGenerator::~cmCPackGenerator() this->MakefileMap = nullptr; } -void cmCPackGenerator::DisplayVerboseOutput(const char* msg, float progress) +void cmCPackGenerator::DisplayVerboseOutput(const std::string& msg, + float progress) { (void)progress; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "" << msg << std::endl); @@ -387,8 +388,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } /* If it is not a symlink then do a plain copy */ else if (!(cmSystemTools::CopyFileIfDifferent(inFile, filePath) && - cmSystemTools::CopyFileTime(inFile.c_str(), - filePath.c_str()))) { + cmSystemTools::CopyFileTime(inFile, filePath))) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " << inFile << " -> " << filePath << std::endl); @@ -689,7 +689,7 @@ int cmCPackGenerator::InstallCMakeProject( cm.SetHomeOutputDirectory(""); cm.GetCurrentSnapshot().SetDefaultDefinitions(); cm.AddCMakePaths(); - cm.SetProgressCallback([this](const char* msg, float prog) { + cm.SetProgressCallback([this](const std::string& msg, float prog) { this->DisplayVerboseOutput(msg, prog); }); cm.SetTrace(this->Trace); diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 4755f94..9e4bf43 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -96,7 +96,7 @@ public: void SetLogger(cmCPackLog* log) { this->Logger = log; } //! Display verbose information via logger - void DisplayVerboseOutput(const char* msg, float progress); + void DisplayVerboseOutput(const std::string& msg, float progress); bool ReadListFile(const char* moduleName); diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 0413422..da9575b 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -90,7 +90,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, return 1; } -static void cpackProgressCallback(const char* message, float /*unused*/) +static void cpackProgressCallback(const std::string& message, float /*unused*/) { std::cout << "-- " << message << std::endl; } diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 3856569..696b52f 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -126,10 +126,11 @@ public: cmSystemTools::SetStdoutCallback([&s](std::string const& m) { s += m; }); cmSystemTools::SetStderrCallback([&s](std::string const& m) { s += m; }); - this->CM.SetProgressCallback([&s](const char* msg, float /*unused*/) { - s += msg; - s += "\n"; - }); + this->CM.SetProgressCallback( + [&s](const std::string& msg, float /*unused*/) { + s += msg; + s += "\n"; + }); } ~cmCTestBuildAndTestCaptureRAII() diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 3b93422..10928e0 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -223,7 +223,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file, checkDir = fBinDir; } std::string ndc = cmSystemTools::FileExistsInParentDirectories( - ".NoDartCoverage", fFile.c_str(), checkDir.c_str()); + ".NoDartCoverage", fFile, checkDir); if (!ndc.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of " << file @@ -254,8 +254,8 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(std::string const& file, return true; } - ndc = cmSystemTools::FileExistsInParentDirectories( - ".NoDartCoverage", fFile.c_str(), checkDir.c_str()); + ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage", fFile, + checkDir); if (!ndc.empty()) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc << " so skip coverage of: " << file @@ -1058,8 +1058,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( this->Quiet); std::vector<std::string> lines; - - cmSystemTools::Split(output.c_str(), lines); + cmsys::SystemTools::Split(output, lines); for (std::string const& line : lines) { std::string sourceFile; @@ -1435,8 +1434,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage( this->Quiet); std::vector<std::string> lines; - - cmSystemTools::Split(output.c_str(), lines); + cmsys::SystemTools::Split(output, lines); for (std::string const& line : lines) { std::string sourceFile; diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 8ba59d3..954f5bb 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -725,7 +725,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput( cmsys::RegularExpression leakWarning("(Direct|Indirect) leak of .*"); int defects = 0; std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); std::ostringstream ostr; log.clear(); for (std::string const& l : lines) { @@ -755,7 +755,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput( const std::string& str, std::string& log, std::vector<int>& results) { std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); std::ostringstream ostr; log.clear(); @@ -798,7 +798,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( const std::string& str, std::string& log, std::vector<int>& results) { std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); bool unlimitedOutput = false; if (str.find("CTEST_FULL_OUTPUT") != std::string::npos || this->CustomMaximumFailedTestOutputSize == 0) { @@ -937,7 +937,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput( log.clear(); auto sttime = std::chrono::steady_clock::now(); std::vector<std::string> lines; - cmSystemTools::Split(str.c_str(), lines); + cmsys::SystemTools::Split(str, lines); cmCTestOptionalLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl, this->Quiet); std::vector<std::string>::size_type cc; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 5183c6f..41d02c5 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -9,8 +9,6 @@ #include "cmSystemTools.h" #include "cmWorkingDirectory.h" -#include "cm_zlib.h" -#include "cmsys/Base64.h" #include "cmsys/RegularExpression.hxx" #include <chrono> #include <cmAlgorithms.h> @@ -32,9 +30,6 @@ cmCTestRunTest::cmCTestRunTest(cmCTestMultiProcessHandler& multiHandler) this->TestResult.Status = cmCTestTestHandler::NOT_RUN; this->TestResult.TestCount = 0; this->TestResult.Properties = nullptr; - this->ProcessOutput.clear(); - this->CompressedOutput.clear(); - this->CompressionRatio = 2; this->NumberOfRunsLeft = 1; // default to 1 run of the test this->RunUntilFail = false; // default to run the test once this->RunAgain = false; // default to not having to run again @@ -69,73 +64,8 @@ void cmCTestRunTest::CheckOutput(std::string const& line) } } -// Streamed compression of test output. The compressed data -// is appended to this->CompressedOutput -void cmCTestRunTest::CompressOutput() -{ - int ret; - z_stream strm; - - unsigned char* in = reinterpret_cast<unsigned char*>( - const_cast<char*>(this->ProcessOutput.c_str())); - // zlib makes the guarantee that this is the maximum output size - int outSize = static_cast<int>( - static_cast<double>(this->ProcessOutput.size()) * 1.001 + 13.0); - unsigned char* out = new unsigned char[outSize]; - - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - ret = deflateInit(&strm, -1); // default compression level - if (ret != Z_OK) { - delete[] out; - return; - } - - strm.avail_in = static_cast<uInt>(this->ProcessOutput.size()); - strm.next_in = in; - strm.avail_out = outSize; - strm.next_out = out; - ret = deflate(&strm, Z_FINISH); - - if (ret != Z_STREAM_END) { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Error during output compression. Sending uncompressed output." - << std::endl); - delete[] out; - return; - } - - (void)deflateEnd(&strm); - - unsigned char* encoded_buffer = - new unsigned char[static_cast<int>(outSize * 1.5)]; - - size_t rlen = cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1); - - this->CompressedOutput.clear(); - for (size_t i = 0; i < rlen; i++) { - this->CompressedOutput += encoded_buffer[i]; - } - - if (strm.total_in) { - this->CompressionRatio = - static_cast<double>(strm.total_out) / static_cast<double>(strm.total_in); - } - - delete[] encoded_buffer; - delete[] out; -} - bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { - if ((!this->TestHandler->MemCheck && - this->CTest->ShouldCompressTestOutput()) || - (this->TestHandler->MemCheck && - this->CTest->ShouldCompressTestOutput())) { - this->CompressOutput(); - } - this->WriteLogOutputTop(completed, total); std::string reason; bool passed = true; @@ -336,10 +266,18 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // if the test actually started and ran // record the results in TestResult if (started) { - bool compress = !this->TestHandler->MemCheck && - this->CompressionRatio < 1 && this->CTest->ShouldCompressTestOutput(); + std::string compressedOutput; + if (!this->TestHandler->MemCheck && + this->CTest->ShouldCompressTestOutput()) { + std::string str = this->ProcessOutput; + if (this->CTest->CompressString(str)) { + compressedOutput = std::move(str); + } + } + bool compress = !compressedOutput.empty() && + compressedOutput.length() < this->ProcessOutput.length(); this->TestResult.Output = - compress ? this->CompressedOutput : this->ProcessOutput; + compress ? compressedOutput : this->ProcessOutput; this->TestResult.CompressOutput = compress; this->TestResult.ReturnValue = this->TestProcess->GetExitValue(); if (!skipped) { diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index 918d5fa..38cc417 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -58,9 +58,6 @@ public: // Read and store output. Returns true if it must be called again. void CheckOutput(std::string const& line); - // Compresses the output, writing to CompressedOutput - void CompressOutput(); - // launch the test process, return whether it started correctly bool StartTest(size_t completed, size_t total); // capture and report the test results @@ -105,8 +102,6 @@ private: cmCTest* CTest; std::unique_ptr<cmProcess> TestProcess; std::string ProcessOutput; - std::string CompressedOutput; - double CompressionRatio; // The test results cmCTestTestHandler::cmCTestTestResult TestResult; cmCTestMultiProcessHandler& MultiTestHandler; diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 2cbdc4e..a714abe 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -288,11 +288,12 @@ void cmCTestScriptHandler::CreateCMake() this->ParentMakefile->GetRecursionDepth()); } - this->CMake->SetProgressCallback([this](const char* m, float /*unused*/) { - if (m && *m) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, "-- " << m << std::endl); - } - }); + this->CMake->SetProgressCallback( + [this](const std::string& m, float /*unused*/) { + if (!m.empty()) { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "-- " << m << std::endl); + } + }); this->AddCTestCommand("ctest_build", new cmCTestBuildCommand); this->AddCTestCommand("ctest_configure", new cmCTestConfigureCommand); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 076ee3d..906dd02 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -79,18 +79,11 @@ cmCursesMainForm::~cmCursesMainForm() // See if a cache entry is in the list of entries in the ui. bool cmCursesMainForm::LookForCacheEntry(const std::string& key) { - if (!this->Entries) { - return false; - } - - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - if (key == (*it)->Key) { - return true; - } - } - - return false; + return this->Entries && + std::any_of(this->Entries->begin(), this->Entries->end(), + [&key](cmCursesCacheEntryComposite* entry) { + return key == entry->Key; + }); } // Create new cmCursesCacheEntryComposite entries from the cache @@ -185,13 +178,12 @@ void cmCursesMainForm::RePost() } else { // If normal mode, count only non-advanced entries this->NumberOfVisibleEntries = 0; - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { + for (cmCursesCacheEntryComposite* entry : *this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - (*it)->GetValue(), "ADVANCED"); + entry->GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -212,27 +204,26 @@ void cmCursesMainForm::RePost() // Assign fields int j = 0; - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { + for (cmCursesCacheEntryComposite* entry : *this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - (*it)->GetValue(), "ADVANCED"); + entry->GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } - this->Fields[3 * j] = (*it)->Label->Field; - this->Fields[3 * j + 1] = (*it)->IsNewLabel->Field; - this->Fields[3 * j + 2] = (*it)->Entry->Field; + this->Fields[3 * j] = entry->Label->Field; + this->Fields[3 * j + 1] = entry->IsNewLabel->Field; + this->Fields[3 * j + 2] = entry->Entry->Field; j++; } // if no cache entries there should still be one dummy field if (j == 0) { - it = this->Entries->begin(); - this->Fields[0] = (*it)->Label->Field; - this->Fields[1] = (*it)->IsNewLabel->Field; - this->Fields[2] = (*it)->Entry->Field; + const auto& front = *this->Entries->front(); + this->Fields[0] = front.Label->Field; + this->Fields[1] = front.IsNewLabel->Field; + this->Fields[2] = front.Entry->Field; this->NumberOfVisibleEntries = 1; } // Has to be null terminated. @@ -273,13 +264,12 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) } else { // If normal, display only non-advanced entries this->NumberOfVisibleEntries = 0; - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { + for (cmCursesCacheEntryComposite* entry : *this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - (*it)->GetValue(), "ADVANCED"); + entry->GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -292,13 +282,12 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) if (height > 0) { bool isNewPage; int i = 0; - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { + for (cmCursesCacheEntryComposite* entry : *this->Entries) { const char* existingValue = - this->CMakeInstance->GetState()->GetCacheEntryValue((*it)->GetValue()); + this->CMakeInstance->GetState()->GetCacheEntryValue(entry->GetValue()); bool advanced = this->CMakeInstance->GetState()->GetCacheEntryPropertyAsBool( - (*it)->GetValue(), "ADVANCED"); + entry->GetValue(), "ADVANCED"); if (!existingValue || (!this->AdvancedMode && advanced)) { continue; } @@ -309,10 +298,10 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) if (isNewPage) { this->NumberOfPages++; } - (*it)->Label->Move(left, top + row - 1, isNewPage); - (*it)->IsNewLabel->Move(left + 32, top + row - 1, false); - (*it)->Entry->Move(left + 33, top + row - 1, false); - (*it)->Entry->SetPage(this->NumberOfPages); + entry->Label->Move(left, top + row - 1, isNewPage); + entry->IsNewLabel->Move(left + 32, top + row - 1, false); + entry->Entry->Move(left + 33, top + row - 1, false); + entry->Entry->SetPage(this->NumberOfPages); i++; } } @@ -501,14 +490,14 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) pos_form_cursor(this->Form); } -void cmCursesMainForm::UpdateProgress(const char* msg, float prog) +void cmCursesMainForm::UpdateProgress(const std::string& msg, float prog) { char tmp[1024]; const char* cmsg = tmp; if (prog >= 0) { - sprintf(tmp, "%s %i%%", msg, static_cast<int>(100 * prog)); + sprintf(tmp, "%s %i%%", msg.c_str(), static_cast<int>(100 * prog)); } else { - cmsg = msg; + cmsg = msg.c_str(); } this->UpdateStatusBar(cmsg); this->PrintKeys(1); @@ -528,7 +517,9 @@ int cmCursesMainForm::Configure(int noconfigure) touchwin(stdscr); refresh(); this->CMakeInstance->SetProgressCallback( - [this](const char* msg, float prog) { this->UpdateProgress(msg, prog); }); + [this](const std::string& msg, float prog) { + this->UpdateProgress(msg, prog); + }); // always save the current gui values to disk this->FillCacheManagerFromUI(); @@ -598,7 +589,9 @@ int cmCursesMainForm::Generate() touchwin(stdscr); refresh(); this->CMakeInstance->SetProgressCallback( - [this](const char* msg, float prog) { this->UpdateProgress(msg, prog); }); + [this](const std::string& msg, float prog) { + this->UpdateProgress(msg, prog); + }); // Get rid of previous errors this->Errors = std::vector<std::string>(); @@ -654,28 +647,29 @@ void cmCursesMainForm::RemoveEntry(const char* value) return; } - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - const char* val = (*it)->GetValue(); - if (val && !strcmp(value, val)) { - this->CMakeInstance->UnwatchUnusedCli(value); - this->Entries->erase(it); - break; - } + auto removeIt = + std::find_if(this->Entries->begin(), this->Entries->end(), + [value](cmCursesCacheEntryComposite* entry) -> bool { + const char* val = entry->GetValue(); + return val != nullptr && !strcmp(value, val); + }); + + if (removeIt != this->Entries->end()) { + this->CMakeInstance->UnwatchUnusedCli(value); + this->Entries->erase(removeIt); } } // copy from the list box to the cache manager void cmCursesMainForm::FillCacheManagerFromUI() { - size_t size = this->Entries->size(); - for (size_t i = 0; i < size; i++) { - std::string cacheKey = (*this->Entries)[i]->Key; + for (cmCursesCacheEntryComposite* entry : *this->Entries) { + const std::string& cacheKey = entry->Key; const char* existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey); if (existingValue) { std::string oldValue = existingValue; - std::string newValue = (*this->Entries)[i]->Entry->GetValue(); + std::string newValue = entry->GetValue(); std::string fixedOldValue; std::string fixedNewValue; cmStateEnums::CacheEntryType t = @@ -971,17 +965,14 @@ void cmCursesMainForm::HandleInput() if (nextCur) { // make the next or prev. current field after deletion - nextCur = nullptr; - std::vector<cmCursesCacheEntryComposite*>::iterator it; - for (it = this->Entries->begin(); it != this->Entries->end(); - ++it) { - if (nextVal == (*it)->Key) { - nextCur = (*it)->Entry->Field; - } - } - - if (nextCur) { - set_current_field(this->Form, nextCur); + auto nextEntryIt = + std::find_if(this->Entries->begin(), this->Entries->end(), + [&nextVal](cmCursesCacheEntryComposite* entry) { + return nextVal == entry->Key; + }); + + if (nextEntryIt != this->Entries->end()) { + set_current_field(this->Form, (*nextEntryIt)->Entry->Field); } } } diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index c09ce2a..d379975 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -102,7 +102,7 @@ public: /** * Progress callback */ - void UpdateProgress(const char* msg, float prog); + void UpdateProgress(const std::string& msg, float prog); protected: // Copy the cache values from the user interface to the actual diff --git a/Source/LexerParser/cmListFileLexer.c b/Source/LexerParser/cmListFileLexer.c index c726415..15dcda0 100644 --- a/Source/LexerParser/cmListFileLexer.c +++ b/Source/LexerParser/cmListFileLexer.c @@ -766,7 +766,7 @@ Modify cmListFileLexer.c: /* IWYU pragma: no_forward_declare yyguts_t */ -#ifdef WIN32 +#ifdef _WIN32 #include "cmsys/Encoding.h" #endif diff --git a/Source/LexerParser/cmListFileLexer.in.l b/Source/LexerParser/cmListFileLexer.in.l index 6a6fb5f..fdf14d2 100644 --- a/Source/LexerParser/cmListFileLexer.in.l +++ b/Source/LexerParser/cmListFileLexer.in.l @@ -18,7 +18,7 @@ Modify cmListFileLexer.c: /* IWYU pragma: no_forward_declare yyguts_t */ -#ifdef WIN32 +#ifdef _WIN32 #include "cmsys/Encoding.h" #endif diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index c90c142..f357f90 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -37,7 +37,7 @@ QCMake::QCMake(QObject* p) this->CMakeInstance->SetCMakeEditCommand( cmSystemTools::GetCMakeGUICommand()); this->CMakeInstance->SetProgressCallback( - [this](const char* msg, float percent) { + [this](const std::string& msg, float percent) { this->progressCallback(msg, percent); }); @@ -346,12 +346,12 @@ bool QCMake::interruptCallback() #endif } -void QCMake::progressCallback(const char* msg, float percent) +void QCMake::progressCallback(const std::string& msg, float percent) { if (percent >= 0) { - emit this->progressChanged(QString::fromLocal8Bit(msg), percent); + emit this->progressChanged(QString::fromStdString(msg), percent); } else { - emit this->outputMessage(QString::fromLocal8Bit(msg)); + emit this->outputMessage(QString::fromStdString(msg)); } QCoreApplication::processEvents(); } diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index 8492606..f2fd6d9 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -168,7 +168,7 @@ protected: cmake* CMakeInstance; bool interruptCallback(); - void progressCallback(const char* msg, float percent); + void progressCallback(std::string const& msg, float percent); void messageCallback(std::string const& msg, const char* title); void stdoutCallback(std::string const& msg); void stderrCallback(std::string const& msg); diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 30328c6..1c4160b 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -348,6 +348,14 @@ std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it) return std::reverse_iterator<Iter>(it); } +inline bool cmHasPrefix(std::string const& str, std::string const& prefix) +{ + if (str.size() < prefix.size()) { + return false; + } + return str.compare(0, prefix.size(), prefix) == 0; +} + inline bool cmHasSuffix(const std::string& str, const std::string& suffix) { if (str.size() < suffix.size()) { diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index bd110ec..eb52895 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -226,7 +226,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, } else if (doing == DoingCMakeFlags) { cmakeFlags.push_back(argv[i]); } else if (doing == DoingCompileDefinitions) { - compileDefs.push_back(argv[i]); + cmSystemTools::ExpandListArgument(argv[i], compileDefs); } else if (doing == DoingLinkOptions) { linkOptions.push_back(argv[i]); } else if (doing == DoingLinkLibraries) { diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index cae3ff6..3f036a9 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -94,6 +94,10 @@ cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg) } this->PPDefinitions.insert(def); } + + this->CompilerId = mf->GetSafeDefinition("CMAKE_Fortran_COMPILER_ID"); + this->SModSep = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP"); + this->SModExt = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT"); } cmDependsFortran::~cmDependsFortran() @@ -116,6 +120,11 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources, return false; } + cmFortranCompiler fc; + fc.Id = this->CompilerId; + fc.SModSep = this->SModSep; + fc.SModExt = this->SModExt; + bool okay = true; for (std::string const& src : sources) { // Get the information object for this source. @@ -123,7 +132,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources, // Create the parser object. The constructor takes info by reference, // so we may look into the resulting objects later. - cmFortranParser parser(this->IncludePath, this->PPDefinitions, info); + cmFortranParser parser(fc, this->IncludePath, this->PPDefinitions, info); // Push on the starting file. cmFortranParser_FilePush(&parser, src.c_str()); diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index bf09904..0485115 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -77,6 +77,10 @@ protected: // The source file from which to start scanning. std::string SourceFile; + std::string CompilerId; + std::string SModSep; + std::string SModExt; + std::set<std::string> PPDefinitions; // Internal implementation details. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index fb3a1bc..aa75a8c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -223,7 +223,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, bool writable = false; // Set permissions to writable - if (cmSystemTools::GetPermissions(fileName.c_str(), mode)) { + if (cmSystemTools::GetPermissions(fileName, mode)) { #if defined(_MSC_VER) || defined(__MINGW32__) writable = (mode & S_IWRITE) != 0; mode_t newMode = mode | S_IWRITE; @@ -232,7 +232,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, mode_t newMode = mode | S_IWUSR | S_IWGRP; #endif if (!writable) { - cmSystemTools::SetPermissions(fileName.c_str(), newMode); + cmSystemTools::SetPermissions(fileName, newMode); } } // If GetPermissions fails, pretend like it is ok. File open will fail if @@ -259,7 +259,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args, } file.close(); if (mode && !writable) { - cmSystemTools::SetPermissions(fileName.c_str(), mode); + cmSystemTools::SetPermissions(fileName, mode); } return true; } @@ -393,7 +393,7 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args) #else std::ostringstream e; e << args[0] << " not available during bootstrap"; - this->SetError(e.str().c_str()); + this->SetError(e.str()); return false; #endif } @@ -523,7 +523,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) maxlen = len; arg_mode = arg_none; } else if (arg_mode == arg_regex) { - if (!regex.compile(args[i].c_str())) { + if (!regex.compile(args[i])) { std::ostringstream e; e << "STRINGS option REGEX value \"" << args[i] << "\" could not be compiled."; @@ -1105,7 +1105,7 @@ protected: MatchProperties Properties; std::string RegexString; MatchRule(std::string const& regex) - : Regex(regex.c_str()) + : Regex(regex) , RegexString(regex) { } @@ -1113,14 +1113,13 @@ protected: std::vector<MatchRule> MatchRules; // Get the properties from rules matching this input file. - MatchProperties CollectMatchProperties(const char* file) + MatchProperties CollectMatchProperties(const std::string& file) { // Match rules are case-insensitive on some platforms. #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__) - std::string lower = cmSystemTools::LowerCase(file); - const char* file_to_match = lower.c_str(); + const std::string file_to_match = cmSystemTools::LowerCase(file); #else - const char* file_to_match = file; + const std::string& file_to_match = file; #endif // Collect properties from all matching rules. @@ -1139,14 +1138,13 @@ protected: return result; } - bool SetPermissions(const char* toFile, mode_t permissions) + bool SetPermissions(const std::string& toFile, mode_t permissions) { if (permissions) { #ifdef WIN32 if (Makefile->IsOn("CMAKE_CROSSCOMPILING")) { // Store the mode in an NTFS alternate stream. - std::string mode_t_adt_filename = - std::string(toFile) + ":cmake_mode_t"; + std::string mode_t_adt_filename = toFile + ":cmake_mode_t"; // Writing to an NTFS alternate stream changes the modification // time, so we need to save and restore its original value. @@ -1189,12 +1187,13 @@ protected: return true; } - bool InstallSymlink(const char* fromFile, const char* toFile); - bool InstallFile(const char* fromFile, const char* toFile, + bool InstallSymlink(const std::string& fromFile, const std::string& toFile); + bool InstallFile(const std::string& fromFile, const std::string& toFile, MatchProperties match_properties); - bool InstallDirectory(const char* source, const char* destination, + bool InstallDirectory(const std::string& source, + const std::string& destination, MatchProperties match_properties); - virtual bool Install(const char* fromFile, const char* toFile); + virtual bool Install(const std::string& fromFile, const std::string& toFile); virtual std::string const& ToName(std::string const& fromName) { return fromName; @@ -1206,8 +1205,8 @@ protected: TypeDir, TypeLink }; - virtual void ReportCopy(const char*, Type, bool) {} - virtual bool ReportMissing(const char* fromFile) + virtual void ReportCopy(const std::string&, Type, bool) {} + virtual bool ReportMissing(const std::string& fromFile) { // The input file does not exist and installation is not optional. std::ostringstream e; @@ -1551,16 +1550,17 @@ bool cmFileCopier::Run(std::vector<std::string> const& args) fromFile += fromName; } - if (!this->Install(fromFile.c_str(), toFile.c_str())) { + if (!this->Install(fromFile, toFile)) { return false; } } return true; } -bool cmFileCopier::Install(const char* fromFile, const char* toFile) +bool cmFileCopier::Install(const std::string& fromFile, + const std::string& toFile) { - if (!*fromFile) { + if (fromFile.empty()) { std::ostringstream e; e << "INSTALL encountered an empty string input file name."; this->FileCommand->SetError(e.str()); @@ -1590,7 +1590,8 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile) return this->ReportMissing(fromFile); } -bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) +bool cmFileCopier::InstallSymlink(const std::string& fromFile, + const std::string& toFile) { // Read the original symlink. std::string symlinkTarget; @@ -1637,7 +1638,8 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile) return true; } -bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile, +bool cmFileCopier::InstallFile(const std::string& fromFile, + const std::string& toFile, MatchProperties match_properties) { // Determine whether we will copy the file. @@ -1690,8 +1692,8 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile, return this->SetPermissions(toFile, permissions); } -bool cmFileCopier::InstallDirectory(const char* source, - const char* destination, +bool cmFileCopier::InstallDirectory(const std::string& source, + const std::string& destination, MatchProperties match_properties) { // Inform the user about this directory installation. @@ -1748,7 +1750,7 @@ bool cmFileCopier::InstallDirectory(const char* source, // Load the directory contents to traverse it recursively. cmsys::Directory dir; - if (source && *source) { + if (!source.empty()) { dir.Load(source); } unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles()); @@ -1761,7 +1763,7 @@ bool cmFileCopier::InstallDirectory(const char* source, std::string toPath = destination; toPath += "/"; toPath += dir.GetFile(fileNum); - if (!this->Install(fromPath.c_str(), toPath.c_str())) { + if (!this->Install(fromPath, toPath)) { return false; } } @@ -1829,26 +1831,26 @@ protected: return this->Rename.empty() ? fromName : this->Rename; } - void ReportCopy(const char* toFile, Type type, bool copy) override + void ReportCopy(const std::string& toFile, Type type, bool copy) override { if (!this->MessageNever && (copy || !this->MessageLazy)) { std::string message = (copy ? "Installing: " : "Up-to-date: "); message += toFile; - this->Makefile->DisplayStatus(message.c_str(), -1); + this->Makefile->DisplayStatus(message, -1); } if (type != TypeDir) { // Add the file to the manifest. this->ManifestAppend(toFile); } } - bool ReportMissing(const char* fromFile) override + bool ReportMissing(const std::string& fromFile) override { return (this->Optional || this->cmFileCopier::ReportMissing(fromFile)); } - bool Install(const char* fromFile, const char* toFile) override + bool Install(const std::string& fromFile, const std::string& toFile) override { // Support installing from empty source to make a directory. - if (this->InstallType == cmInstallType_DIRECTORY && !*fromFile) { + if (this->InstallType == cmInstallType_DIRECTORY && fromFile.empty()) { return this->InstallDirectory(fromFile, toFile, MatchProperties()); } return this->cmFileCopier::Install(fromFile, toFile); @@ -2138,7 +2140,7 @@ bool cmFileCommand::HandleRPathChangeCommand( std::vector<std::string> const& args) { // Evaluate arguments. - const char* file = nullptr; + std::string file; const char* oldRPath = nullptr; const char* newRPath = nullptr; enum Doing @@ -2157,7 +2159,7 @@ bool cmFileCommand::HandleRPathChangeCommand( } else if (args[i] == "FILE") { doing = DoingFile; } else if (doing == DoingFile) { - file = args[i].c_str(); + file = args[i]; doing = DoingNone; } else if (doing == DoingOld) { oldRPath = args[i].c_str(); @@ -2172,7 +2174,7 @@ bool cmFileCommand::HandleRPathChangeCommand( return false; } } - if (!file) { + if (file.empty()) { this->SetError("RPATH_CHANGE not given FILE option."); return false; } @@ -2214,7 +2216,7 @@ bool cmFileCommand::HandleRPathChangeCommand( message += "\" to \""; message += newRPath; message += "\""; - this->Makefile->DisplayStatus(message.c_str(), -1); + this->Makefile->DisplayStatus(message, -1); } if (have_ft) { cmSystemTools::FileTimeSet(file, ft); @@ -2228,7 +2230,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( std::vector<std::string> const& args) { // Evaluate arguments. - const char* file = nullptr; + std::string file; enum Doing { DoingNone, @@ -2239,7 +2241,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( if (args[i] == "FILE") { doing = DoingFile; } else if (doing == DoingFile) { - file = args[i].c_str(); + file = args[i]; doing = DoingNone; } else { std::ostringstream e; @@ -2248,7 +2250,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( return false; } } - if (!file) { + if (file.empty()) { this->SetError("RPATH_REMOVE not given FILE option."); return false; } @@ -2278,7 +2280,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( std::string message = "Removed runtime path from \""; message += file; message += "\""; - this->Makefile->DisplayStatus(message.c_str(), -1); + this->Makefile->DisplayStatus(message, -1); } if (have_ft) { cmSystemTools::FileTimeSet(file, ft); @@ -2292,7 +2294,7 @@ bool cmFileCommand::HandleRPathCheckCommand( std::vector<std::string> const& args) { // Evaluate arguments. - const char* file = nullptr; + std::string file; const char* rpath = nullptr; enum Doing { @@ -2307,7 +2309,7 @@ bool cmFileCommand::HandleRPathCheckCommand( } else if (args[i] == "FILE") { doing = DoingFile; } else if (doing == DoingFile) { - file = args[i].c_str(); + file = args[i]; doing = DoingNone; } else if (doing == DoingRPath) { rpath = args[i].c_str(); @@ -2319,7 +2321,7 @@ bool cmFileCommand::HandleRPathCheckCommand( return false; } } - if (!file) { + if (file.empty()) { this->SetError("RPATH_CHECK not given FILE option."); return false; } @@ -2647,7 +2649,7 @@ int cmFileDownloadProgressCallback(void* clientp, double dltotal, double dlnow, if (helper->UpdatePercentage(dlnow, dltotal, status)) { cmFileCommand* fc = helper->GetFileCommand(); cmMakefile* mf = fc->GetMakefile(); - mf->DisplayStatus(status.c_str(), -1); + mf->DisplayStatus(status, -1); } return 0; @@ -2665,7 +2667,7 @@ int cmFileUploadProgressCallback(void* clientp, double dltotal, double dlnow, if (helper->UpdatePercentage(ulnow, ultotal, status)) { cmFileCommand* fc = helper->GetFileCommand(); cmMakefile* mf = fc->GetMakefile(); - mf->DisplayStatus(status.c_str(), -1); + mf->DisplayStatus(status, -1); } return 0; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 52ff5ea..45b096f 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -911,7 +911,7 @@ bool cmFindPackageCommand::HandlePackageMode() std::ostringstream aw; aw << "Could NOT find " << this->Name << " (missing: " << this->Name << "_DIR)"; - this->Makefile->DisplayStatus(aw.str().c_str(), -1); + this->Makefile->DisplayStatus(aw.str(), -1); } } diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index 8d4c90b..0762340 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -128,15 +128,29 @@ struct cmFortranFile bool LastCharWasNewline; }; +struct cmFortranCompiler +{ + std::string Id; + std::string SModSep; + std::string SModExt; +}; + struct cmFortranParser_s { - cmFortranParser_s(std::vector<std::string> includes, + cmFortranParser_s(cmFortranCompiler fc, std::vector<std::string> includes, std::set<std::string> defines, cmFortranSourceInfo& info); ~cmFortranParser_s(); bool FindIncludeFile(const char* dir, const char* includeName, std::string& fileName); + std::string ModName(std::string const& mod_name) const; + std::string SModName(std::string const& mod_name, + std::string const& sub_name) const; + + // What compiler. + cmFortranCompiler Compiler; + // The include file search path. std::vector<std::string> IncludePath; diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index 45481a4..18e3c10 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -43,10 +43,12 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir, return false; } -cmFortranParser_s::cmFortranParser_s(std::vector<std::string> includes, +cmFortranParser_s::cmFortranParser_s(cmFortranCompiler fc, + std::vector<std::string> includes, std::set<std::string> defines, cmFortranSourceInfo& info) - : IncludePath(std::move(includes)) + : Compiler(std::move(fc)) + , IncludePath(std::move(includes)) , PPDefinitions(std::move(defines)) , Info(info) { @@ -69,6 +71,17 @@ cmFortranParser_s::~cmFortranParser_s() cmFortran_yylex_destroy(this->Scanner); } +std::string cmFortranParser_s::ModName(std::string const& mod_name) const +{ + return mod_name + ".mod"; +} + +std::string cmFortranParser_s::SModName(std::string const& mod_name, + std::string const& sub_name) const +{ + return mod_name + this->Compiler.SModSep + sub_name + this->Compiler.SModExt; +} + bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname) { // Open the new file and push it onto the stack. Save the old @@ -178,7 +191,7 @@ void cmFortranParser_RuleUse(cmFortranParser* parser, const char* module_name) // syntax: "use module_name" // requires: "module_name.mod" std::string const& mod_name = cmSystemTools::LowerCase(module_name); - parser->Info.Requires.insert(mod_name + ".mod"); + parser->Info.Requires.insert(parser->ModName(mod_name)); } void cmFortranParser_RuleLineDirective(cmFortranParser* parser, @@ -242,7 +255,7 @@ void cmFortranParser_RuleModule(cmFortranParser* parser, // syntax: "module module_name" // provides: "module_name.mod" std::string const& mod_name = cmSystemTools::LowerCase(module_name); - parser->Info.Provides.insert(mod_name + ".mod"); + parser->Info.Provides.insert(parser->ModName(mod_name)); } } @@ -265,8 +278,8 @@ void cmFortranParser_RuleSubmodule(cmFortranParser* parser, std::string const& mod_name = cmSystemTools::LowerCase(module_name); std::string const& sub_name = cmSystemTools::LowerCase(submodule_name); - parser->Info.Requires.insert(mod_name + ".mod"); - parser->Info.Provides.insert(mod_name + "@" + sub_name + ".smod"); + parser->Info.Requires.insert(parser->ModName(mod_name)); + parser->Info.Provides.insert(parser->SModName(mod_name, sub_name)); } void cmFortranParser_RuleSubmoduleNested(cmFortranParser* parser, @@ -286,8 +299,8 @@ void cmFortranParser_RuleSubmoduleNested(cmFortranParser* parser, std::string const& sub_name = cmSystemTools::LowerCase(submodule_name); std::string const& nest_name = cmSystemTools::LowerCase(nested_submodule_name); - parser->Info.Requires.insert(mod_name + "@" + sub_name + ".smod"); - parser->Info.Provides.insert(mod_name + "@" + nest_name + ".smod"); + parser->Info.Requires.insert(parser->SModName(mod_name, sub_name)); + parser->Info.Provides.insert(parser->SModName(mod_name, nest_name)); } void cmFortranParser_RuleDefine(cmFortranParser* parser, const char* macro) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 0f26e70..728f2a4 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -157,14 +157,8 @@ bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() { - const cmGeneratorExpressionDAGChecker* top = this; - const cmGeneratorExpressionDAGChecker* parent = this->Parent; - while (parent) { - top = parent; - parent = parent->Parent; - } - - return top->Property == "TARGET_GENEX_EVAL" || top->Property == "GENEX_EVAL"; + return this->Property.find("TARGET_GENEX_EVAL:") == 0 || + this->Property.find("GENEX_EVAL:", 0) == 0; } bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index dcec0a4..49a5fcd 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -402,8 +402,8 @@ protected: { if (context->HeadTarget) { cmGeneratorExpressionDAGChecker dagChecker( - context->Backtrace, context->HeadTarget, genexOperator, content, - dagCheckerParent); + context->Backtrace, context->HeadTarget, + genexOperator + ":" + expression, content, dagCheckerParent); switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 54cfd3a..6f5e9bd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1617,13 +1617,7 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const return ""; } // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; + return this->GetLibraryNames(config).SharedObject; } static bool shouldAddFullLevel(cmGeneratorTarget::BundleDirectoryLevel level) @@ -3394,17 +3388,13 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); // Get the names. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; + cmGeneratorTarget::Names targetNames; if (this->GetType() == cmStateEnums::EXECUTABLE) { - this->GetExecutableNames(name, realName, impName, pdbName, config); + targetNames = this->GetExecutableNames(config); } else if (this->GetType() == cmStateEnums::STATIC_LIBRARY || this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); + targetNames = this->GetLibraryNames(config); } else { return; } @@ -3415,34 +3405,34 @@ void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const // Add each name. std::string f; - if (!name.empty()) { + if (!targetNames.Output.empty()) { f = dir; f += "/"; - f += name; + f += targetNames.Output; gg->AddToManifest(f); } - if (!soName.empty()) { + if (!targetNames.SharedObject.empty()) { f = dir; f += "/"; - f += soName; + f += targetNames.SharedObject; gg->AddToManifest(f); } - if (!realName.empty()) { + if (!targetNames.Real.empty()) { f = dir; f += "/"; - f += realName; + f += targetNames.Real; gg->AddToManifest(f); } - if (!pdbName.empty()) { + if (!targetNames.PDB.empty()) { f = dir; f += "/"; - f += pdbName; + f += targetNames.PDB; gg->AddToManifest(f); } - if (!impName.empty()) { + if (!targetNames.ImportLibrary.empty()) { f = this->GetDirectory(config, cmStateEnums::ImportLibraryArtifact); f += "/"; - f += impName; + f += targetNames.ImportLibrary; gg->AddToManifest(f); } } @@ -3520,29 +3510,17 @@ std::string cmGeneratorTarget::NormalGetRealName( if (this->GetType() == cmStateEnums::EXECUTABLE) { // Compute the real name that will be built. - std::string name; - std::string realName; - std::string impName; - std::string pdbName; - this->GetExecutableNames(name, realName, impName, pdbName, config); - return realName; + return this->GetExecutableNames(config).Real; } // Compute the real name that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return realName; -} - -void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const + return this->GetLibraryNames(config).Real; +} + +cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames( + const std::string& config) const { + cmGeneratorTarget::Names targetNames; + // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. @@ -3550,7 +3528,6 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, std::string msg = "GetLibraryNames called on imported target: "; msg += this->GetName(); this->LocalGenerator->IssueMessage(MessageType::INTERNAL_ERROR, msg); - return; } // Check for library version properties. @@ -3576,50 +3553,51 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string& soName, // Get the components of the library name. std::string prefix; - std::string base; std::string suffix; this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, base, suffix); + prefix, targetNames.Base, suffix); // The library name. - name = prefix + base + suffix; + targetNames.Output = prefix + targetNames.Base + suffix; if (this->IsFrameworkOnApple()) { - realName = prefix; + targetNames.Real = prefix; if (!this->Makefile->PlatformIsAppleEmbedded()) { - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; + targetNames.Real += "Versions/"; + targetNames.Real += this->GetFrameworkVersion(); + targetNames.Real += "/"; } - realName += base; - soName = realName; + targetNames.Real += targetNames.Base; + targetNames.SharedObject = targetNames.Real; } else { // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, name, soversion); + this->ComputeVersionedName(targetNames.SharedObject, prefix, + targetNames.Base, suffix, targetNames.Output, + soversion); // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, name, version); + this->ComputeVersionedName(targetNames.Real, prefix, targetNames.Base, + suffix, targetNames.Output, version); } // The import library name. if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::MODULE_LIBRARY) { - impName = + targetNames.ImportLibrary = this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); - } else { - impName.clear(); } // The program database file name. - pdbName = this->GetPDBName(config); + targetNames.PDB = this->GetPDBName(config); + + return targetNames; } -void cmGeneratorTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const +cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames( + const std::string& config) const { + cmGeneratorTarget::Names targetNames; + // This should not be called for imported targets. // TODO: Split cmTarget into a class hierarchy to get compile-time // enforcement of the limited imported target API. @@ -3644,34 +3622,35 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, // Get the components of the executable name. std::string prefix; - std::string base; std::string suffix; this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, base, suffix); + prefix, targetNames.Base, suffix); // The executable name. - name = prefix + base + suffix; + targetNames.Output = prefix + targetNames.Base + suffix; // The executable's real name on disk. #if defined(__CYGWIN__) - realName = prefix + base; + targetNames.Real = prefix + targetNames.Base; #else - realName = name; + targetNames.Real = targetNames.Output; #endif if (version) { - realName += "-"; - realName += version; + targetNames.Real += "-"; + targetNames.Real += version; } #if defined(__CYGWIN__) - realName += suffix; + targetNames.Real += suffix; #endif // The import library name. - impName = + targetNames.ImportLibrary = this->GetFullNameInternal(config, cmStateEnums::ImportLibraryArtifact); // The program database file name. - pdbName = this->GetPDBName(config); + targetNames.PDB = this->GetPDBName(config); + + return targetNames; } std::string cmGeneratorTarget::GetFullNameInternal( diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 59d38af..bc966e1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -568,19 +568,25 @@ public: void GetAutoUicOptions(std::vector<std::string>& result, const std::string& config) const; + struct Names + { + std::string Base; + std::string Output; + std::string Real; + std::string ImportLibrary; + std::string PDB; + std::string SharedObject; + }; + /** Get the names of the executable needed to generate a build rule that takes into account executable version numbers. This should be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, std::string& pdbName, - const std::string& config) const; + Names GetExecutableNames(const std::string& config) const; /** Get the names of the library needed to generate a build rule that takes into account shared library version numbers. This should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; + Names GetLibraryNames(const std::string& config) const; /** * Compute whether this target must be relinked before installing. diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 08441a8..c63e01a 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -40,12 +40,8 @@ void cmGhsMultiTargetGenerator::Generate() switch (this->GeneratorTarget->GetType()) { case cmStateEnums::EXECUTABLE: { // Get the name of the executable to generate. - std::string targetName; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetExecutableNames( - targetName, this->TargetNameReal, targetNameImport, targetNamePDB, - this->ConfigName); + this->TargetNameReal = + this->GeneratorTarget->GetExecutableNames(this->ConfigName).Real; if (cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()) { this->TagType = GhsMultiGpj::INTERGRITY_APPLICATION; } else { @@ -54,13 +50,8 @@ void cmGhsMultiTargetGenerator::Generate() break; } case cmStateEnums::STATIC_LIBRARY: { - std::string targetName; - std::string targetNameSO; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetLibraryNames( - targetName, targetNameSO, this->TargetNameReal, targetNameImport, - targetNamePDB, this->ConfigName); + this->TargetNameReal = + this->GeneratorTarget->GetLibraryNames(this->ConfigName).Real; this->TagType = GhsMultiGpj::LIBRARY; break; } @@ -71,13 +62,8 @@ void cmGhsMultiTargetGenerator::Generate() return; } case cmStateEnums::OBJECT_LIBRARY: { - std::string targetName; - std::string targetNameSO; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetLibraryNames( - targetName, targetNameSO, this->TargetNameReal, targetNameImport, - targetNamePDB, this->ConfigName); + this->TargetNameReal = + this->GeneratorTarget->GetLibraryNames(this->ConfigName).Real; this->TagType = GhsMultiGpj::SUBPROJECT; break; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8e7ca12..11c382f 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1225,7 +1225,7 @@ void cmGlobalGenerator::Configure() } else { msg << "Configuring done"; } - this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); + this->CMakeInstance->UpdateProgress(msg.str(), -1); } } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index ba1ace6..31bcacf 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1678,6 +1678,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg, return 1; } + cmFortranCompiler fc; std::vector<std::string> includes; { Json::Value tdio; @@ -1699,11 +1700,20 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg, includes.push_back(tdi_include_dir.asString()); } } + + Json::Value const& tdi_compiler_id = tdi["compiler-id"]; + fc.Id = tdi_compiler_id.asString(); + + Json::Value const& tdi_submodule_sep = tdi["submodule-sep"]; + fc.SModSep = tdi_submodule_sep.asString(); + + Json::Value const& tdi_submodule_ext = tdi["submodule-ext"]; + fc.SModExt = tdi_submodule_ext.asString(); } cmFortranSourceInfo info; std::set<std::string> defines; - cmFortranParser parser(includes, defines, info); + cmFortranParser parser(fc, includes, defines, info); if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) { cmSystemTools::Error("-E cmake_ninja_depends failed to open ", arg_pp.c_str()); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 7284f0b..f872de5 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1006,7 +1006,7 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) winSDK_7_1)) { std::ostringstream m; m << "Found Windows SDK v7.1: " << winSDK_7_1; - mf->DisplayStatus(m.str().c_str(), -1); + mf->DisplayStatus(m.str(), -1); this->DefaultPlatformToolset = "Windows7.1SDK"; return true; } else { diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index a0a9558..2d54c33 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -171,7 +171,7 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, std::ostringstream e; e << "Selecting Windows SDK version " << this->WindowsTargetPlatformVersion << " to target Windows " << this->SystemVersion << "."; - mf->DisplayStatus(e.str().c_str(), -1); + mf->DisplayStatus(e.str(), -1); } mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION", this->WindowsTargetPlatformVersion.c_str()); diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 12d9304..913fc4a 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -453,7 +453,8 @@ bool cmGlobalVisualStudioVersionedGenerator::IsWin81SDKInstalled() const "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\" "Windows Kits\\Installed Roots;KitsRoot81", win81Root, cmSystemTools::KeyWOW64_32)) { - return cmSystemTools::FileExists(win81Root + "/um/windows.h", true); + return cmSystemTools::FileExists(win81Root + "/include/um/windows.h", + true); } return false; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 5cee9d3..7053e99 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -123,19 +123,15 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->Target->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, config); + cmGeneratorTarget::Names targetNames = + this->Target->GetExecutableNames(config); if (this->ImportLibrary) { - std::string from1 = fromDirConfig + targetNameImport; - std::string to1 = toDir + targetNameImport; + std::string from1 = fromDirConfig + targetNames.ImportLibrary; + std::string to1 = toDir + targetNames.ImportLibrary; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); std::string targetNameImportLib; - if (this->Target->GetImplibGNUtoMS(config, targetNameImport, + if (this->Target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); filesTo.push_back(toDir + targetNameImportLib); @@ -144,8 +140,8 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( // An import library looks like a static library. type = cmInstallType_STATIC_LIBRARY; } else { - std::string from1 = fromDirConfig + targetName; - std::string to1 = toDir + targetName; + std::string from1 = fromDirConfig + targetNames.Output; + std::string to1 = toDir + targetNames.Output; // Handle OSX Bundles. if (this->Target->IsAppBundleOnApple()) { @@ -170,12 +166,12 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( if (!mf->PlatformIsAppleEmbedded()) { to1 += "Contents/MacOS/"; } - to1 += targetName; + to1 += targetNames.Output; } else { // Tweaks apply to the real file, so list it first. - if (targetNameReal != targetName) { - std::string from2 = fromDirConfig + targetNameReal; - std::string to2 = toDir += targetNameReal; + if (targetNames.Real != targetNames.Output) { + std::string from2 = fromDirConfig + targetNames.Real; + std::string to2 = toDir += targetNames.Real; filesFrom.push_back(std::move(from2)); filesTo.push_back(std::move(to2)); } @@ -185,23 +181,18 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( filesTo.push_back(std::move(to1)); } } else { - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, - targetNameImport, targetNamePDB, config); + cmGeneratorTarget::Names targetNames = + this->Target->GetLibraryNames(config); if (this->ImportLibrary) { // There is a bug in cmInstallCommand if this fails. assert(this->NamelinkMode == NamelinkModeNone); - std::string from1 = fromDirConfig + targetNameImport; - std::string to1 = toDir + targetNameImport; + std::string from1 = fromDirConfig + targetNames.ImportLibrary; + std::string to1 = toDir + targetNames.ImportLibrary; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); std::string targetNameImportLib; - if (this->Target->GetImplibGNUtoMS(config, targetNameImport, + if (this->Target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); filesTo.push_back(toDir + targetNameImportLib); @@ -243,11 +234,11 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( type = cmInstallType_DIRECTORY; literal_args += " USE_SOURCE_PERMISSIONS"; - std::string from1 = fromDirConfig + targetName; + std::string from1 = fromDirConfig + targetNames.Output; from1 = cmSystemTools::GetFilenamePath(from1); // Tweaks apply to the binary inside the bundle. - std::string to1 = toDir + targetNameReal; + std::string to1 = toDir + targetNames.Real; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); @@ -256,10 +247,11 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( type = cmInstallType_DIRECTORY; literal_args += " USE_SOURCE_PERMISSIONS"; - std::string targetNameBase = targetName.substr(0, targetName.find('/')); + std::string targetNameBase = + targetNames.Output.substr(0, targetNames.Output.find('/')); std::string from1 = fromDirConfig + targetNameBase; - std::string to1 = toDir + targetName; + std::string to1 = toDir + targetNames.Output; filesFrom.push_back(std::move(from1)); filesTo.push_back(std::move(to1)); @@ -267,25 +259,26 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( bool haveNamelink = false; // Library link name. - std::string fromName = fromDirConfig + targetName; - std::string toName = toDir + targetName; + std::string fromName = fromDirConfig + targetNames.Output; + std::string toName = toDir + targetNames.Output; // Library interface name. std::string fromSOName; std::string toSOName; - if (targetNameSO != targetName) { + if (targetNames.SharedObject != targetNames.Output) { haveNamelink = true; - fromSOName = fromDirConfig + targetNameSO; - toSOName = toDir + targetNameSO; + fromSOName = fromDirConfig + targetNames.SharedObject; + toSOName = toDir + targetNames.SharedObject; } // Library implementation name. std::string fromRealName; std::string toRealName; - if (targetNameReal != targetName && targetNameReal != targetNameSO) { + if (targetNames.Real != targetNames.Output && + targetNames.Real != targetNames.SharedObject) { haveNamelink = true; - fromRealName = fromDirConfig + targetNameReal; - toRealName = toDir + targetNameReal; + fromRealName = fromDirConfig + targetNames.Real; + toRealName = toDir + targetNames.Real; } // Add the names based on the current namelink mode. @@ -416,48 +409,37 @@ std::string cmInstallTargetGenerator::GetInstallFilename( std::string fname; // Compute the name of the library. if (target->GetType() == cmStateEnums::EXECUTABLE) { - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, targetNameImport, - targetNamePDB, config); + cmGeneratorTarget::Names targetNames = target->GetExecutableNames(config); if (nameType == NameImplib) { // Use the import library name. - if (!target->GetImplibGNUtoMS(config, targetNameImport, fname, + if (!target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { - fname = targetNameImport; + fname = targetNames.ImportLibrary; } } else if (nameType == NameReal) { // Use the canonical name. - fname = targetNameReal; + fname = targetNames.Real; } else { // Use the canonical name. - fname = targetName; + fname = targetNames.Output; } } else { - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, - targetNameImport, targetNamePDB, config); + cmGeneratorTarget::Names targetNames = target->GetLibraryNames(config); if (nameType == NameImplib) { // Use the import library name. - if (!target->GetImplibGNUtoMS(config, targetNameImport, fname, + if (!target->GetImplibGNUtoMS(config, targetNames.ImportLibrary, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { - fname = targetNameImport; + fname = targetNames.ImportLibrary; } } else if (nameType == NameSO) { // Use the soname. - fname = targetNameSO; + fname = targetNames.SharedObject; } else if (nameType == NameReal) { // Use the real name. - fname = targetNameReal; + fname = targetNames.Real; } else { // Use the canonical name. - fname = targetName; + fname = targetNames.Output; } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ba3c574..a2d0efe 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -935,16 +935,11 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( } else { rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); } + cmSystemTools::ConvertToUnixSlashes(rootPath); // Raw list of implicit include directories std::vector<std::string> impDirVec; - // Get platform-wide implicit directories. - if (const char* implicitIncludes = (this->Makefile->GetDefinition( - "CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"))) { - cmSystemTools::ExpandListArgument(implicitIncludes, impDirVec); - } - // Load implicit include directories for this language. std::string key = "CMAKE_"; key += lang; @@ -953,9 +948,28 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( cmSystemTools::ExpandListArgument(value, impDirVec); } + // The Platform/UnixPaths module used to hard-code /usr/include for C, CXX, + // and CUDA in CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES, but those + // variables are now computed. On macOS the /usr/include directory is + // inside the platform SDK so the computed value does not contain it + // directly. In this case adding -I/usr/include can hide SDK headers so we + // must still exclude it. + if ((lang == "C" || lang == "CXX" || lang == "CUDA") && + std::find(impDirVec.begin(), impDirVec.end(), "/usr/include") == + impDirVec.end() && + std::find_if(impDirVec.begin(), impDirVec.end(), + [](std::string const& d) { + return cmHasLiteralSuffix(d, "/usr/include"); + }) != impDirVec.end()) { + impDirVec.emplace_back("/usr/include"); + } + for (std::string const& i : impDirVec) { - std::string imd = rootPath + i; + std::string imd = i; cmSystemTools::ConvertToUnixSlashes(imd); + if (!rootPath.empty() && !cmHasPrefix(imd, rootPath)) { + imd = rootPath + imd; + } if (implicitSet.insert(imd).second) { implicitDirs.emplace_back(std::move(imd)); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index d6f71d3..7eb4a03 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1808,6 +1808,17 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( << "_COMPILER_ID \"" << cid << "\")\n"; } + if (implicitLang.first == "Fortran") { + std::string smodSep = + this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP"); + std::string smodExt = + this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT"); + cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_SEP \"" << smodSep + << "\")\n"; + cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_EXT \"" << smodExt + << "\")\n"; + } + // Build a list of preprocessor definitions for the target. std::set<std::string> defines; this->GetTargetDefines(target, this->ConfigName, implicitLang.first, diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index b809be4..9f18e8f 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1043,13 +1043,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( } case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::MODULE_LIBRARY: { - std::string targetName; - std::string targetNameSO; - std::string targetNameFull; - std::string targetNameImport; - std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameFull, - targetNameImport, targetNamePDB, configName); + cmGeneratorTarget::Names targetNames = + target->GetLibraryNames(configName); // Compute the link library and directory information. cmComputeLinkInformation* pcli = target->GetLinkInformation(configName); @@ -1085,7 +1080,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; temp = target->GetDirectory(configName); temp += "/"; - temp += targetNameFull; + temp += targetNames.Output; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; this->WriteTargetVersionAttribute(fout, target); @@ -1095,7 +1090,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; temp = target->GetPDBDirectory(configName); temp += "/"; - temp += targetNamePDB; + temp += targetNames.PDB; fout << "\t\t\t\tProgramDatabaseFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; if (targetOptions.IsDebug()) { @@ -1118,7 +1113,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( temp = target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; - temp += targetNameImport; + temp += targetNames.ImportLibrary; fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\""; if (this->FortranProject) { @@ -1127,12 +1122,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "/>\n"; } break; case cmStateEnums::EXECUTABLE: { - std::string targetName; - std::string targetNameFull; - std::string targetNameImport; - std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameFull, targetNameImport, - targetNamePDB, configName); + cmGeneratorTarget::Names targetNames = + target->GetExecutableNames(configName); // Compute the link library and directory information. cmComputeLinkInformation* pcli = target->GetLinkInformation(configName); @@ -1170,7 +1161,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; temp = target->GetDirectory(configName); temp += "/"; - temp += targetNameFull; + temp += targetNames.Output; fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; this->WriteTargetVersionAttribute(fout, target); @@ -1180,8 +1171,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( fout << "\"\n"; std::string path = this->ConvertToXMLOutputPathSingle( target->GetPDBDirectory(configName).c_str()); - fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" << targetNamePDB - << "\"\n"; + fout << "\t\t\t\tProgramDatabaseFile=\"" << path << "/" + << targetNames.PDB << "\"\n"; if (targetOptions.IsDebug()) { fout << "\t\t\t\tGenerateDebugInformation=\"true\"\n"; } @@ -1216,7 +1207,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool( temp = target->GetDirectory(configName, cmStateEnums::ImportLibraryArtifact); temp += "/"; - temp += targetNameImport; + temp += targetNames.ImportLibrary; fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n"; break; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f246da2..b0dacf1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3547,7 +3547,7 @@ cmState* cmMakefile::GetState() const return this->GetCMakeInstance()->GetState(); } -void cmMakefile::DisplayStatus(const char* message, float s) const +void cmMakefile::DisplayStatus(const std::string& message, float s) const { cmake* cm = this->GetCMakeInstance(); if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index fce90f2..9f01986 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -639,7 +639,7 @@ public: #endif ///! Display progress or status message. - void DisplayStatus(const char*, float) const; + void DisplayStatus(const std::string&, float) const; /** * Expand the given list file arguments into the full set after diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index e8ae5ae..572270a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -31,9 +31,8 @@ cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator( : cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->GeneratorTarget->GetExecutableNames( - this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, - this->TargetNamePDB, this->ConfigName); + this->TargetNames = + this->GeneratorTarget->GetExecutableNames(this->ConfigName); this->OSXBundleGenerator = new cmOSXBundleGenerator(target, this->ConfigName); @@ -305,18 +304,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::vector<std::string> commands; // Get the name of the executable to generate. - std::string targetName; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetExecutableNames(targetName, targetNameReal, - targetNameImport, targetNamePDB, - this->ConfigName); + cmGeneratorTarget::Names targetNames = + this->GeneratorTarget->GetExecutableNames(this->ConfigName); // Construct the full path version of the names. std::string outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); if (this->GeneratorTarget->IsAppBundleOnApple()) { - this->OSXBundleGenerator->CreateAppBundle(targetName, outpath); + this->OSXBundleGenerator->CreateAppBundle(targetNames.Output, outpath); } outpath += "/"; std::string outpathImp; @@ -326,12 +320,12 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; - if (!targetNameImport.empty()) { + if (!targetNames.ImportLibrary.empty()) { outpathImp = outpath; } } else { cmSystemTools::MakeDirectory(outpath); - if (!targetNameImport.empty()) { + if (!targetNames.ImportLibrary.empty()) { outpathImp = this->GeneratorTarget->GetDirectory( this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp); @@ -348,10 +342,10 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmSystemTools::MakeDirectory(pdbOutputPath); pdbOutputPath += "/"; - std::string targetFullPath = outpath + targetName; - std::string targetFullPathReal = outpath + targetNameReal; - std::string targetFullPathPDB = pdbOutputPath + targetNamePDB; - std::string targetFullPathImport = outpathImp + targetNameImport; + std::string targetFullPath = outpath + targetNames.Output; + std::string targetFullPathReal = outpath + targetNames.Real; + std::string targetFullPathPDB = pdbOutputPath + targetNames.PDB; + std::string targetFullPathImport = outpathImp + targetNames.ImportLibrary; std::string targetOutPathPDB = this->LocalGenerator->ConvertToOutputFormat( targetFullPathPDB, cmOutputConverter::SHELL); // Convert to the output path to use in constructing commands. @@ -468,11 +462,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath + ".manifest")); #endif - if (targetNameReal != targetName) { + if (this->TargetNames.Real != this->TargetNames.Output) { exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathReal)); } - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport)); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 5a1ef4e..ed2fd68 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -32,9 +32,8 @@ cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( { this->CustomCommandDriver = OnDepends; if (this->GeneratorTarget->GetType() != cmStateEnums::INTERFACE_LIBRARY) { - this->GeneratorTarget->GetLibraryNames( - this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, - this->TargetNameImport, this->TargetNamePDB, this->ConfigName); + this->TargetNames = + this->GeneratorTarget->GetLibraryNames(this->ConfigName); } this->OSXBundleGenerator = @@ -489,25 +488,20 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Construct the name of the library. - std::string targetName; - std::string targetNameSO; - std::string targetNameReal; - std::string targetNameImport; - std::string targetNamePDB; - this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, - targetNameReal, targetNameImport, - targetNamePDB, this->ConfigName); + this->GeneratorTarget->GetLibraryNames(this->ConfigName); // Construct the full path version of the names. std::string outpath; std::string outpathImp; if (this->GeneratorTarget->IsFrameworkOnApple()) { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); - this->OSXBundleGenerator->CreateFramework(targetName, outpath); + this->OSXBundleGenerator->CreateFramework(this->TargetNames.Output, + outpath); outpath += "/"; } else if (this->GeneratorTarget->IsCFBundleOnApple()) { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); - this->OSXBundleGenerator->CreateCFBundle(targetName, outpath); + this->OSXBundleGenerator->CreateCFBundle(this->TargetNames.Output, + outpath); outpath += "/"; } else if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); @@ -515,14 +509,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( outpath += "/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); outpath += "/"; - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { outpathImp = outpath; } } else { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); cmSystemTools::MakeDirectory(outpath); outpath += "/"; - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { outpathImp = this->GeneratorTarget->GetDirectory( this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp); @@ -539,11 +533,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( cmSystemTools::MakeDirectory(pdbOutputPath); pdbOutputPath += "/"; - std::string targetFullPath = outpath + targetName; - std::string targetFullPathPDB = pdbOutputPath + targetNamePDB; - std::string targetFullPathSO = outpath + targetNameSO; - std::string targetFullPathReal = outpath + targetNameReal; - std::string targetFullPathImport = outpathImp + targetNameImport; + std::string targetFullPath = outpath + this->TargetNames.Output; + std::string targetFullPathPDB = pdbOutputPath + this->TargetNames.PDB; + std::string targetFullPathSO = outpath + this->TargetNames.SharedObject; + std::string targetFullPathReal = outpath + this->TargetNames.Real; + std::string targetFullPathImport = + outpathImp + this->TargetNames.ImportLibrary; // Construct the output path version of the names for use in command // arguments. @@ -616,15 +611,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( commands1.clear(); } - if (targetName != targetNameReal) { + if (this->TargetNames.Output != this->TargetNames.Real) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPath)); } - if (targetNameSO != targetNameReal && targetNameSO != targetName) { + if (this->TargetNames.SharedObject != this->TargetNames.Real && + this->TargetNames.SharedObject != this->TargetNames.Output) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathSO)); } - if (!targetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath( this->LocalGenerator->GetCurrentBinaryDirectory(), targetFullPathImport)); @@ -820,7 +816,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( vars.ObjectsQuoted = buildObjs.c_str(); if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); - vars.TargetSOName = targetNameSO.c_str(); + vars.TargetSOName = this->TargetNames.SharedObject.c_str(); } vars.LinkFlags = linkFlags.c_str(); @@ -981,10 +977,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Compute the list of outputs. std::vector<std::string> outputs(1, targetFullPathReal); - if (targetNameSO != targetNameReal) { + if (this->TargetNames.SharedObject != this->TargetNames.Real) { outputs.push_back(targetFullPathSO); } - if (targetName != targetNameSO && targetName != targetNameReal) { + if (this->TargetNames.Output != this->TargetNames.SharedObject && + this->TargetNames.Output != this->TargetNames.Real) { outputs.push_back(targetFullPath); } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 529b4db..c053d5b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -12,12 +12,12 @@ #include <vector> #include "cmCommonTargetGenerator.h" +#include "cmGeneratorTarget.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmOSXBundleGenerator.h" class cmCustomCommandGenerator; class cmGeneratedFileStream; -class cmGeneratorTarget; class cmGlobalUnixMakefileGenerator3; class cmLinkLineComputer; class cmOutputConverter; @@ -231,11 +231,7 @@ protected: bool in_help = false); // Target name info. - std::string TargetNameOut; - std::string TargetNameSO; - std::string TargetNameReal; - std::string TargetNameImport; - std::string TargetNamePDB; + cmGeneratorTarget::Names TargetNames; // macOS content info. std::set<std::string> MacContentFolders; diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 95f5fcb..1a21ae4 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -68,7 +68,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args, m->DisplayMessage(type, message, this->Makefile->GetBacktrace()); } else { if (status) { - this->Makefile->DisplayStatus(message.c_str(), -1); + this->Makefile->DisplayStatus(message, -1); } else { cmSystemTools::Message(message); } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index cbc0103..3874f48 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -41,13 +41,10 @@ cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator( { this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmStateEnums::EXECUTABLE) { - this->GetGeneratorTarget()->GetExecutableNames( - this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, - this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); + this->TargetNames = this->GetGeneratorTarget()->GetExecutableNames( + GetLocalGenerator()->GetConfigName()); } else { - this->GetGeneratorTarget()->GetLibraryNames( - this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, - this->TargetNameImport, this->TargetNamePDB, + this->TargetNames = this->GetGeneratorTarget()->GetLibraryNames( GetLocalGenerator()->GetConfigName()); } @@ -395,7 +392,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) /*generator*/ false); } - if (this->TargetNameOut != this->TargetNameReal && + if (this->TargetNames.Output != this->TargetNames.Real && !this->GetGeneratorTarget()->IsFrameworkOnApple()) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( @@ -676,7 +673,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage); - vars["SONAME"] = this->TargetNameSO; + vars["SONAME"] = this->TargetNames.SharedObject; if (targetType == cmStateEnums::SHARED_LIBRARY) { std::string install_dir = this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); @@ -687,7 +684,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement() } } - if (!this->TargetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { const std::string impLibPath = localGen.ConvertToOutputFormat( targetOutputImplib, cmOutputConverter::SHELL); vars["TARGET_IMPLIB"] = impLibPath; @@ -749,24 +746,25 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() if (gt.IsAppBundleOnApple()) { // Create the app bundle std::string outpath = gt.GetDirectory(cfgName); - this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath); + this->OSXBundleGenerator->CreateAppBundle(this->TargetNames.Output, + outpath); // Calculate the output path targetOutput = outpath; targetOutput += "/"; - targetOutput += this->TargetNameOut; + targetOutput += this->TargetNames.Output; targetOutput = this->ConvertToNinjaPath(targetOutput); targetOutputReal = outpath; targetOutputReal += "/"; - targetOutputReal += this->TargetNameReal; + targetOutputReal += this->TargetNames.Real; targetOutputReal = this->ConvertToNinjaPath(targetOutputReal); } else if (gt.IsFrameworkOnApple()) { // Create the library framework. - this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, + this->OSXBundleGenerator->CreateFramework(this->TargetNames.Output, gt.GetDirectory(cfgName)); } else if (gt.IsCFBundleOnApple()) { // Create the core foundation bundle. - this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, + this->OSXBundleGenerator->CreateCFBundle(this->TargetNames.Output, gt.GetDirectory(cfgName)); } @@ -864,7 +862,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); - vars["SONAME"] = this->TargetNameSO; + vars["SONAME"] = this->TargetNames.SharedObject; if (targetType == cmStateEnums::SHARED_LIBRARY) { std::string install_dir = this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); @@ -877,7 +875,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() cmNinjaDeps byproducts; - if (!this->TargetNameImport.empty()) { + if (!this->TargetNames.ImportLibrary.empty()) { const std::string impLibPath = localGen.ConvertToOutputFormat( targetOutputImplib, cmOutputConverter::SHELL); vars["TARGET_IMPLIB"] = impLibPath; @@ -1037,8 +1035,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() emptyDeps, emptyDeps, symlinkVars); } else { cmNinjaDeps symlinks; - std::string const soName = - this->ConvertToNinjaPath(this->GetTargetFilePath(this->TargetNameSO)); + std::string const soName = this->ConvertToNinjaPath( + this->GetTargetFilePath(this->TargetNames.SharedObject)); // If one link has to be created. if (targetOutputReal == soName || targetOutput == soName) { symlinkVars["SONAME"] = soName; @@ -1056,7 +1054,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() } // Add aliases for the file name and the target name. - globalGen.AddTargetAlias(this->TargetNameOut, >); + globalGen.AddTargetAlias(this->TargetNames.Output, >); globalGen.AddTargetAlias(this->GetTargetName(), >); } diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 01cc881..14991a2 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -5,13 +5,12 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmGeneratorTarget.h" #include "cmNinjaTargetGenerator.h" #include <string> #include <vector> -class cmGeneratorTarget; - class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator { public: @@ -40,11 +39,7 @@ private: private: // Target name info. - std::string TargetNameOut; - std::string TargetNameSO; - std::string TargetNameReal; - std::string TargetNameImport; - std::string TargetNamePDB; + cmGeneratorTarget::Names TargetNames; std::string TargetLinkLanguage; std::string DeviceLinkObject; }; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b525dac..998729f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1143,6 +1143,10 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang) mod_dir = this->Makefile->GetCurrentBinaryDirectory(); } tdi["module-dir"] = mod_dir; + tdi["submodule-sep"] = + this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP"); + tdi["submodule-ext"] = + this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT"); } tdi["dir-cur-bld"] = this->Makefile->GetCurrentBinaryDirectory(); diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index 719e6b1..1903fd9 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -103,7 +103,7 @@ void cmServer::ProcessRequest(cmConnection* connection, if (this->Protocol) { this->Protocol->CMakeInstance()->SetProgressCallback( - [&request](const char* msg, float prog) { + [&request](const std::string& msg, float prog) { reportProgress(msg, prog, request); }); this->WriteResponse(connection, this->Protocol->Process(request), @@ -155,7 +155,7 @@ void cmServer::PrintHello(cmConnection* connection) const this->WriteJsonObject(connection, hello, nullptr); } -void cmServer::reportProgress(const char* msg, float progress, +void cmServer::reportProgress(const std::string& msg, float progress, const cmServerRequest& request) { if (progress < 0.0f || progress > 1.0f) { diff --git a/Source/cmServer.h b/Source/cmServer.h index 3edc887..aba4924 100644 --- a/Source/cmServer.h +++ b/Source/cmServer.h @@ -119,7 +119,7 @@ public: void OnConnected(cmConnection* connection) override; private: - static void reportProgress(const char* msg, float progress, + static void reportProgress(const std::string& msg, float progress, const cmServerRequest& request); static void reportMessage(const std::string& msg, const char* title, const cmServerRequest& request); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2d7bce4..a5d191d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -897,7 +897,7 @@ std::string cmSystemTools::PrintSingleCommand( } bool cmSystemTools::DoesFileExistWithExtensions( - const char* name, const std::vector<std::string>& headerExts) + const std::string& name, const std::vector<std::string>& headerExts) { std::string hname; @@ -912,9 +912,9 @@ bool cmSystemTools::DoesFileExistWithExtensions( return false; } -std::string cmSystemTools::FileExistsInParentDirectories(const char* fname, - const char* directory, - const char* toplevel) +std::string cmSystemTools::FileExistsInParentDirectories( + const std::string& fname, const std::string& directory, + const std::string& toplevel) { std::string file = fname; cmSystemTools::ConvertToUnixSlashes(file); @@ -926,7 +926,7 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname, if (cmSystemTools::FileExists(path)) { return path; } - if (dir.size() < strlen(toplevel)) { + if (dir.size() < toplevel.size()) { break; } prevDir = dir; @@ -2081,7 +2081,8 @@ void cmSystemTools::DoNotInheritStdPipes() #endif } -bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile) +bool cmSystemTools::CopyFileTime(const std::string& fromFile, + const std::string& toFile) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle hFrom = CreateFileW( @@ -2102,14 +2103,14 @@ bool cmSystemTools::CopyFileTime(const char* fromFile, const char* toFile) return SetFileTime(hTo, &timeCreation, &timeLastAccess, &timeLastWrite) != 0; #else struct stat fromStat; - if (stat(fromFile, &fromStat) < 0) { + if (stat(fromFile.c_str(), &fromStat) < 0) { return false; } struct utimbuf buf; buf.actime = fromStat.st_atime; buf.modtime = fromStat.st_mtime; - return utime(toFile, &buf) >= 0; + return utime(toFile.c_str(), &buf) >= 0; #endif } @@ -2123,7 +2124,8 @@ void cmSystemTools::FileTimeDelete(cmSystemToolsFileTime* t) delete t; } -bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) +bool cmSystemTools::FileTimeGet(const std::string& fname, + cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = CreateFileW( @@ -2138,7 +2140,7 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) } #else struct stat st; - if (stat(fname, &st) < 0) { + if (stat(fname.c_str(), &st) < 0) { return false; } t->timeBuf.actime = st.st_atime; @@ -2147,7 +2149,8 @@ bool cmSystemTools::FileTimeGet(const char* fname, cmSystemToolsFileTime* t) return true; } -bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) +bool cmSystemTools::FileTimeSet(const std::string& fname, + const cmSystemToolsFileTime* t) { #if defined(_WIN32) && !defined(__CYGWIN__) cmSystemToolsWindowsHandle h = CreateFileW( @@ -2159,7 +2162,7 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) return SetFileTime(h, &t->timeCreation, &t->timeLastAccess, &t->timeLastWrite) != 0; #else - return utime(fname, &t->timeBuf) >= 0; + return utime(fname.c_str(), &t->timeBuf) >= 0; #endif } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 88758a6..ba6de51 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -144,16 +144,16 @@ public: static bool IsPathToFramework(const char* value); static bool DoesFileExistWithExtensions( - const char* name, const std::vector<std::string>& sourceExts); + const std::string& name, const std::vector<std::string>& sourceExts); /** * Check if the given file exists in one of the parent directory of the * given file or directory and if it does, return the name of the file. * Toplevel specifies the top-most directory to where it will look. */ - static std::string FileExistsInParentDirectories(const char* fname, - const char* directory, - const char* toplevel); + static std::string FileExistsInParentDirectories( + const std::string& fname, const std::string& directory, + const std::string& toplevel); static void Glob(const std::string& directory, const std::string& regexp, std::vector<std::string>& files); @@ -443,13 +443,15 @@ public: /** Copy the file create/access/modify times from the file named by the first argument to that named by the second. */ - static bool CopyFileTime(const char* fromFile, const char* toFile); + static bool CopyFileTime(const std::string& fromFile, + const std::string& toFile); /** Save and restore file times. */ static cmSystemToolsFileTime* FileTimeNew(); static void FileTimeDelete(cmSystemToolsFileTime*); - static bool FileTimeGet(const char* fname, cmSystemToolsFileTime* t); - static bool FileTimeSet(const char* fname, cmSystemToolsFileTime* t); + static bool FileTimeGet(const std::string& fname, cmSystemToolsFileTime* t); + static bool FileTimeSet(const std::string& fname, + const cmSystemToolsFileTime* t); /** Random seed generation. */ static unsigned int RandomSeed(); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8e08417..00a2d74 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3439,18 +3439,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkDirs.push_back("%(AdditionalLibraryDirectories)"); linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs); - std::string targetName; - std::string targetNameSO; - std::string targetNameFull; - std::string targetNameImport; - std::string targetNamePDB; + cmGeneratorTarget::Names targetNames; if (this->GeneratorTarget->GetType() == cmStateEnums::EXECUTABLE) { - this->GeneratorTarget->GetExecutableNames( - targetName, targetNameFull, targetNameImport, targetNamePDB, config); + targetNames = this->GeneratorTarget->GetExecutableNames(config); } else { - this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, - targetNameFull, targetNameImport, - targetNamePDB, config); + targetNames = this->GeneratorTarget->GetLibraryNames(config); } if (this->MSTools) { @@ -3491,11 +3484,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( std::string pdb = this->GeneratorTarget->GetPDBDirectory(config); pdb += "/"; - pdb += targetNamePDB; + pdb += targetNames.PDB; std::string imLib = this->GeneratorTarget->GetDirectory( config, cmStateEnums::ImportLibraryArtifact); imLib += "/"; - imLib += targetNameImport; + imLib += targetNames.ImportLibrary; linkOptions.AddFlag("ImportLibrary", imLib); linkOptions.AddFlag("ProgramDataBaseFile", pdb); @@ -3519,7 +3512,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions( linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib"); } } else if (this->NsightTegra) { - linkOptions.AddFlag("SoName", targetNameSO); + linkOptions.AddFlag("SoName", targetNames.SharedObject); } linkOptions.Parse(flags); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8023298..ff6b04b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1105,7 +1105,7 @@ std::string cmake::FindCacheFile(const std::string& binaryDir) if (cmSystemTools::FileExists(cmakeFiles)) { std::string cachePathFound = cmSystemTools::FileExistsInParentDirectories("CMakeCache.txt", - cachePath.c_str(), "/"); + cachePath, "/"); if (!cachePathFound.empty()) { cachePath = cmSystemTools::GetFilenamePath(cachePathFound); } @@ -1705,7 +1705,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure) ret = this->Generate(); std::string message = "Build files have been written to: "; message += this->GetHomeOutputDirectory(); - this->UpdateProgress(message.c_str(), -1); + this->UpdateProgress(message, -1); return ret; } @@ -1925,7 +1925,7 @@ void cmake::SetProgressCallback(ProgressCallbackType f) this->ProgressCallback = std::move(f); } -void cmake::UpdateProgress(const char* msg, float prog) +void cmake::UpdateProgress(const std::string& msg, float prog) { if (this->ProgressCallback && !this->State->GetIsInTryCompile()) { this->ProgressCallback(msg, prog); @@ -2640,7 +2640,7 @@ int cmake::Build(int jobs, const std::string& dir, const std::string& target, } std::string message = "Build files have been written to: "; message += this->GetHomeOutputDirectory(); - this->UpdateProgress(message.c_str(), -1); + this->UpdateProgress(message, -1); // Restore the previously set directories to their original value. this->SetHomeDirectory(homeOrig); diff --git a/Source/cmake.h b/Source/cmake.h index 53d44f1..6fa2d3a 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -273,7 +273,7 @@ public: ///! Parse command line arguments that might set cache values bool SetCacheArgs(const std::vector<std::string>&); - using ProgressCallbackType = std::function<void(const char*, float)>; + using ProgressCallbackType = std::function<void(const std::string&, float)>; /** * Set the function used by GUIs to receive progress updates * Function gets passed: message as a const char*, a progress @@ -284,7 +284,7 @@ public: void SetProgressCallback(ProgressCallbackType f); ///! this is called by generators to update the progress - void UpdateProgress(const char* msg, float prog); + void UpdateProgress(const std::string& msg, float prog); #if defined(CMAKE_BUILD_WITH_CMAKE) ///! Get the variable watch object diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index a49246b..09068f8 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -148,14 +148,15 @@ static void cmakemainMessageCallback(const std::string& m, std::cerr << m << cmakemainGetStack(cm) << std::endl << std::flush; } -static void cmakemainProgressCallback(const char* m, float prog, cmake* cm) +static void cmakemainProgressCallback(const std::string& m, float prog, + cmake* cm) { cmMakefile* mf = cmakemainGetMakefile(cm); std::string dir; - if ((mf) && (strstr(m, "Configuring") == m) && (prog < 0)) { + if (mf && cmHasLiteralPrefix(m, "Configuring") && (prog < 0)) { dir = " "; dir += mf->GetCurrentSourceDirectory(); - } else if ((mf) && (strstr(m, "Generating") == m)) { + } else if (mf && cmHasLiteralPrefix(m, "Generating")) { dir = " "; dir += mf->GetCurrentBinaryDirectory(); } @@ -323,7 +324,7 @@ int do_cmake(int ac, char const* const* av) [&cm](const std::string& msg, const char* title) { cmakemainMessageCallback(msg, title, &cm); }); - cm.SetProgressCallback([&cm](const char* msg, float prog) { + cm.SetProgressCallback([&cm](const std::string& msg, float prog) { cmakemainProgressCallback(msg, prog, &cm); }); cm.SetWorkingMode(workingMode); @@ -504,7 +505,7 @@ static int do_build(int ac, char const* const* av) [&cm](const std::string& msg, const char* title) { cmakemainMessageCallback(msg, title, &cm); }); - cm.SetProgressCallback([&cm](const char* msg, float prog) { + cm.SetProgressCallback([&cm](const std::string& msg, float prog) { cmakemainProgressCallback(msg, prog, &cm); }); return cm.Build(jobs, dir, target, config, nativeOptions, clean, verbose); @@ -547,7 +548,7 @@ static int do_open(int ac, char const* const* av) [&cm](const std::string& msg, const char* title) { cmakemainMessageCallback(msg, title, &cm); }); - cm.SetProgressCallback([&cm](const char* msg, float prog) { + cm.SetProgressCallback([&cm](const std::string& msg, float prog) { cmakemainProgressCallback(msg, prog, &cm); }); return cm.Open(dir, false) ? 0 : 1; diff --git a/Source/kwsys/CommandLineArguments.hxx.in b/Source/kwsys/CommandLineArguments.hxx.in index 31115e5..7db9015 100644 --- a/Source/kwsys/CommandLineArguments.hxx.in +++ b/Source/kwsys/CommandLineArguments.hxx.in @@ -62,6 +62,9 @@ public: CommandLineArguments(); ~CommandLineArguments(); + CommandLineArguments(const CommandLineArguments&) = delete; + CommandLineArguments& operator=(const CommandLineArguments&) = delete; + /** * Various argument types. */ diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx index 31b1c15..59530a4 100644 --- a/Source/kwsys/Directory.cxx +++ b/Source/kwsys/Directory.cxx @@ -102,7 +102,7 @@ bool Directory::Load(const std::string& name) # endif char* buf; size_t n = name.size(); - if (*name.rbegin() == '/' || *name.rbegin() == '\\') { + if (name.back() == '/' || name.back() == '\\') { buf = new char[n + 1 + 1]; sprintf(buf, "%s*", name.c_str()); } else { @@ -144,7 +144,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name) # endif char* buf; size_t n = name.size(); - if (*name.rbegin() == '/') { + if (name.back() == '/') { buf = new char[n + 1 + 1]; sprintf(buf, "%s*", name.c_str()); } else { diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index 6952d24..829c138 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -263,7 +263,7 @@ bool Glob::RecurseDirectory(std::string::size_type start, } } else { if (!this->Internals->Expressions.empty() && - this->Internals->Expressions.rbegin()->find(fname)) { + this->Internals->Expressions.back().find(fname)) { this->AddFile(this->Internals->Files, realname); } } diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index f323efc..4354753 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -4620,7 +4620,7 @@ std::string SystemInformationImplementation::RunProcess( // Run the application kwsysProcess* gp = kwsysProcess_New(); - kwsysProcess_SetCommand(gp, &*args.begin()); + kwsysProcess_SetCommand(gp, args.data()); kwsysProcess_SetOption(gp, kwsysProcess_Option_HideWindow, 1); kwsysProcess_Execute(gp); diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in index 9e1ce6c..5e93878 100644 --- a/Source/kwsys/SystemInformation.hxx.in +++ b/Source/kwsys/SystemInformation.hxx.in @@ -56,6 +56,9 @@ public: SystemInformation(); ~SystemInformation(); + SystemInformation(const SystemInformation&) = delete; + SystemInformation& operator=(const SystemInformation&) = delete; + const char* GetVendorString(); const char* GetVendorID(); std::string GetTypeID(); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index cbdfe11..33a92e4 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -416,6 +416,9 @@ public: { } ~Free() { free(const_cast<envchar*>(this->Env)); } + + Free(const Free&) = delete; + Free& operator=(const Free&) = delete; }; const envchar* Release(const envchar* env) @@ -473,7 +476,7 @@ void SystemTools::GetPath(std::vector<std::string>& path, const char* env) } // A hack to make the below algorithm work. - if (!pathEnv.empty() && *pathEnv.rbegin() != pathSep) { + if (!pathEnv.empty() && pathEnv.back() != pathSep) { pathEnv += pathSep; } std::string::size_type start = 0; @@ -1943,7 +1946,7 @@ void SystemTools::ConvertToUnixSlashes(std::string& path) // a single / pathCString = path.c_str(); size_t size = path.size(); - if (size > 1 && *path.rbegin() == '/') { + if (size > 1 && path.back() == '/') { // if it is c:/ then do not remove the trailing slash if (!((size == 3 && pathCString[1] == ':'))) { path.resize(size - 1); @@ -2692,7 +2695,7 @@ std::string SystemTools::FindName(const std::string& name, for (std::vector<std::string>::iterator i = path.begin(); i != path.end(); ++i) { std::string& p = *i; - if (p.empty() || *p.rbegin() != '/') { + if (p.empty() || p.back() != '/') { p += "/"; } } @@ -2810,7 +2813,7 @@ std::string SystemTools::FindProgram(const std::string& name, for (std::vector<std::string>::iterator i = path.begin(); i != path.end(); ++i) { std::string& p = *i; - if (p.empty() || *p.rbegin() != '/') { + if (p.empty() || p.back() != '/') { p += "/"; } } @@ -2888,7 +2891,7 @@ std::string SystemTools::FindLibrary(const std::string& name, for (std::vector<std::string>::iterator i = path.begin(); i != path.end(); ++i) { std::string& p = *i; - if (p.empty() || *p.rbegin() != '/') { + if (p.empty() || p.back() != '/') { p += "/"; } } @@ -3234,10 +3237,10 @@ void SystemTools::AddTranslationPath(const std::string& a, if (SystemTools::FileIsFullPath(path_b) && path_b.find("..") == std::string::npos) { // Before inserting make sure path ends with '/' - if (!path_a.empty() && *path_a.rbegin() != '/') { + if (!path_a.empty() && path_a.back() != '/') { path_a += '/'; } - if (!path_b.empty() && *path_b.rbegin() != '/') { + if (!path_b.empty() && path_b.back() != '/') { path_b += '/'; } if (!(path_a == path_b)) { @@ -3446,7 +3449,7 @@ std::string SystemTools::RelativePath(const std::string& local, // between each entry that does not already have one for (std::vector<std::string>::iterator vit1 = finalPath.begin(); vit1 != finalPath.end(); ++vit1) { - if (!relativePath.empty() && *relativePath.rbegin() != '/') { + if (!relativePath.empty() && relativePath.back() != '/') { relativePath += "/"; } relativePath += *vit1; @@ -3648,7 +3651,7 @@ void SystemTools::SplitPath(const std::string& p, } #endif if (!homedir.empty() && - (*homedir.rbegin() == '/' || *homedir.rbegin() == '\\')) { + (homedir.back() == '/' || homedir.back() == '\\')) { homedir.resize(homedir.size() - 1); } SystemTools::SplitPath(homedir, components); @@ -4016,7 +4019,7 @@ bool SystemTools::LocateFileInDir(const char* filename, const char* dir, filename_dir = SystemTools::GetFilenamePath(filename_dir); filename_dir_base = SystemTools::GetFilenameName(filename_dir); #if defined(_WIN32) - if (filename_dir_base.empty() || *filename_dir_base.rbegin() == ':') + if (filename_dir_base.empty() || filename_dir_base.back() == ':') #else if (filename_dir_base.empty()) #endif @@ -4092,7 +4095,7 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath) std::string tempPath = path; // create a buffer // if the path passed in has quotes around it, first remove the quotes - if (!path.empty() && path[0] == '"' && *path.rbegin() == '"') { + if (!path.empty() && path[0] == '"' && path.back() == '"') { tempPath = path.substr(1, path.length() - 2); } @@ -4169,7 +4172,7 @@ bool SystemTools::GetLineFromStream(std::istream& is, std::string& line, bool haveData = !line.empty() || !is.eof(); if (!line.empty()) { // Avoid storing a carriage return character. - if (*line.rbegin() == '\r') { + if (line.back() == '\r') { line.resize(line.size() - 1); } @@ -4307,7 +4310,7 @@ bool SystemTools::IsSubDirectory(const std::string& cSubdir, if (subdir.size() <= dir.size() || dir.empty()) { return false; } - bool isRootPath = *dir.rbegin() == '/'; // like "/" or "C:/" + bool isRootPath = dir.back() == '/'; // like "/" or "C:/" size_t expectedSlashPosition = isRootPath ? dir.size() - 1u : dir.size(); if (subdir[expectedSlashPosition] != '/') { return false; diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 1967860..33b579f 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -54,6 +54,9 @@ class @KWSYS_NAMESPACE@_EXPORT SystemToolsManager public: SystemToolsManager(); ~SystemToolsManager(); + + SystemToolsManager(const SystemToolsManager&) = delete; + SystemToolsManager& operator=(const SystemToolsManager&) = delete; }; // This instance will show up in any translation unit that uses diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 40e53a2..3245f3e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3272,12 +3272,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --output-log "${CMake_BINARY_DIR}/Tests/CTestTest/testOutput.log" ) - configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) - add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} - -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V - --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" - ) + if(NOT CMake_TEST_EXTERNAL_CMAKE) + configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest2/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" @ONLY ESCAPE_QUOTES) + add_test(CTestTest2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTest2/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" + ) + endif() if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja") configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in" @@ -3309,11 +3311,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif () - get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest2 - PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - endif () + if(NOT CMake_TEST_EXTERNAL_CMAKE) + get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties ( CTestTest2 + PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) + endif() + endif() endif () if(CMake_TEST_EXTERNAL_CMAKE) diff --git a/Tests/FindOctave/Test/CMakeLists.txt b/Tests/FindOctave/Test/CMakeLists.txt index ce33fcd..73aa831 100644 --- a/Tests/FindOctave/Test/CMakeLists.txt +++ b/Tests/FindOctave/Test/CMakeLists.txt @@ -10,6 +10,10 @@ add_executable(test_tgt main.cpp) target_link_libraries(test_tgt Octave::Octave) add_test(NAME test_tgt COMMAND test_tgt) +add_executable(test_octinterp_tgt interp_main.cpp) +target_link_libraries(test_octinterp_tgt Octave::Octinterp) +add_test(NAME test_octinterp_tgt COMMAND test_octinterp_tgt) + add_test(NAME test_tgt_exe COMMAND Octave::Interpreter -q --eval "runtests('.')" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Tests/FindOctave/Test/interp_main.cpp b/Tests/FindOctave/Test/interp_main.cpp new file mode 100644 index 0000000..1efa187 --- /dev/null +++ b/Tests/FindOctave/Test/interp_main.cpp @@ -0,0 +1,26 @@ +#include <iostream> +#include <oct.h> +#include <octave.h> +#include <parse.h> +#include <toplev.h> + +int main(void) +{ + string_vector argv(2); + argv(0) = "embedded"; + argv(1) = "-q"; + + try { + octave_main(2, argv.c_str_vec(), 1); + octave_value_list in; + in(0) = 72.0; + const octave_value_list result = feval("sqrt", in); + std::cout << "result is " << result(0).scalar_value() << std::endl; + clean_up_and_exit(0); + } catch (const octave::exit_exception& ex) { + std::cerr << "Octave interpreter exited with status = " << ex.exit_status() + << std::endl; + } catch (const octave::execution_exception&) { + std::cerr << "error encountered in Octave evaluator!" << std::endl; + } +} diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt index f4b726f..9b32e59 100644 --- a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt @@ -5,10 +5,48 @@ include("../AutogenCoreTest.cmake") # Dummy executable to generate a clean target add_executable(dummy dummy.cpp) -set(timeformat "%Y%j%H%M%S") +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") set(mocBasicSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocBasic") set(mocBasicBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocBasic") +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamp When) + file(TIMESTAMP "${mocBasicBin}" time${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change) + if (timeAfter VERSION_GREATER timeBefore) + message(STATUS "As expected the file ${mocBasicBin} changed.") + else() + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} did not change!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + endif() +endmacro() + +macro(require_change_not) + if (timeAfter VERSION_GREATER timeBefore) + message(SEND_ERROR "Unexpectedly the file ${mocBasicBin} changed!\nTimestamp pre: ${timeBefore}\nTimestamp aft: ${timeAfter}\n") + else() + message(STATUS "As expected the file ${mocBasicBin} did not change.") + endif() +endmacro() + + # Initial build configure_file("${mocBasicSrcDir}/test1a.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) try_compile(MOC_RERUN @@ -21,46 +59,44 @@ try_compile(MOC_RERUN OUTPUT_VARIABLE output ) if (NOT MOC_RERUN) - message(SEND_ERROR "Initial build of mocBasic failed. Output: ${output}") + message(FATAL_ERROR "Initial build of mocBasic failed. Output: ${output}") endif() + # Get name of the output binary file(STRINGS "${mocBasicBinDir}/mocBasic.txt" mocBasicList ENCODING UTF-8) list(GET mocBasicList 0 mocBasicBin) -message("Changing the header content for a MOC rerun") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamp(Before) +sleep() +message(STATUS "Touching binary file to ensure a new timestamps") +file(TOUCH_NOCREATE "${mocBasicBin}") +acquire_timestamp(After) +require_change() + + # - Ensure that the timestamp will change -# - Change header file content and rebuild +# - Change header file content # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamp(Before) +sleep() +message(STATUS "Changing the header content for a MOC re-run") configure_file("${mocBasicSrcDir}/test1b.h.in" "${mocBasicBinDir}/test1.h" COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) -if (result) - message(SEND_ERROR "Second build of mocBasic failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") -# - Test if timestamps changed -if (NOT timeAfter GREATER timeBefore) - message(SEND_ERROR "File (${mocBasicBin}) should have changed!") -endif() +sleep() +rebuild(2) +acquire_timestamp(After) +require_change() -message("Changing nothing for a MOC rerun") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${mocBasicBin}" timeBefore "${timeformat}") # - Ensure that the timestamp would change # - Change nothing # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocBasicBinDir}" RESULT_VARIABLE result ) -if (result) - message(SEND_ERROR "Third build of mocBasic failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${mocBasicBin}" timeAfter "${timeformat}") -# - Test if timestamps changed -if (timeAfter GREATER timeBefore) - message(SEND_ERROR "File (${mocBasicBin}) should not have changed!") -endif() +acquire_timestamp(Before) +sleep() +message(STATUS "Changing nothing for no MOC re-run") +rebuild(3) +acquire_timestamp(After) +require_change_not() diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt index b83e994..6ab9538 100644 --- a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt @@ -9,10 +9,53 @@ include("../AutogenCoreTest.cmake") add_executable(dummy dummy.cpp) # Utility variables -set(timeformat "%Y%j%H%M%S") +set(timeformat "%Y.%j.%H.%M%S") set(mocPlugSrcDir "${CMAKE_CURRENT_SOURCE_DIR}/MocPlugin") set(mocPlugBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocPlugin") +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName}.") + execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}" RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} failed.") + else() + message(STATUS "Build ${buildName} finished.") + endif() +endmacro() + +macro(require_change PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(STATUS "As expected the file ${pl${PLG}File} changed.") + else() + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} did not change!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + endif() +endmacro() + +macro(require_change_not PLG) + if (pl${PLG}After VERSION_GREATER pl${PLG}Before) + message(SEND_ERROR + "Unexpectedly the file ${pl${PLG}File} changed!\nTimestamp pre: ${pl${PLG}Before}\nTimestamp aft: ${pl${PLG}After}\n") + else() + message(STATUS "As expected the file ${pl${PLG}File} did not change.") + endif() +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${plAFile}" plA${When} "${timeformat}") + file(TIMESTAMP "${plBFile}" plB${When} "${timeformat}") + file(TIMESTAMP "${plCFile}" plC${When} "${timeformat}") + file(TIMESTAMP "${plDFile}" plD${When} "${timeformat}") + file(TIMESTAMP "${plEFile}" plE${When} "${timeformat}") +endmacro() + + # Initial build try_compile(MOC_PLUGIN "${mocPlugBinDir}" @@ -24,83 +67,75 @@ try_compile(MOC_PLUGIN OUTPUT_VARIABLE output ) if (NOT MOC_PLUGIN) - message(SEND_ERROR "Initial build of mocPlugin failed. Output: ${output}") + message(FATAL_ERROR "Initial build of mocPlugin failed. Output: ${output}") endif() +# Get names of the output binaries find_library(plAFile "PlugA" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plBFile "PlugB" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plCFile "PlugC" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plDFile "PlugD" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) find_library(plEFile "PlugE" PATHS "${mocPlugBinDir}/Debug" "${mocPlugBinDir}" NO_DEFAULT_PATH) +# To avoid a race condition where the library has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch library to ensure it has a new timestamp +acquire_timestamps(Before) +sleep() +message(STATUS "Touching library files to ensure new timestamps") +file(TOUCH_NOCREATE "${plAFile}" "${plBFile}" "${plCFile}" "${plDFile}" "${plEFile}") +acquire_timestamps(After) +require_change(A) +require_change(B) +require_change(C) +require_change(D) +require_change(E) + + # - Ensure that the timestamp will change. # - Change the json files referenced by Q_PLUGIN_METADATA # - Rebuild -file(TIMESTAMP "${plAFile}" plABefore "${timeformat}") -file(TIMESTAMP "${plBFile}" plBBefore "${timeformat}") -file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") -file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") -file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}") - -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files") configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleC.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/StyleE.json") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - -file(TIMESTAMP "${plAFile}" plAAfter "${timeformat}") -file(TIMESTAMP "${plBFile}" plBAfter "${timeformat}") -file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") -file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") -file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}") - -if (plAAfter GREATER plABefore) - message(SEND_ERROR "file (${plAFile}) should not have changed!") -endif() -if (plBAfter GREATER plBBefore) - message(SEND_ERROR "file (${plBFile}) should not have changed!") -endif() -if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") -endif() -if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") -endif() -if (NOT plEAfter GREATER plEBefore) - # There's a bug in Ninja on Windows - # https://gitlab.kitware.com/cmake/cmake/issues/16776 - if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) - message(SEND_ERROR "file (${plEFile}) should have changed!") - endif() +sleep() +rebuild(2) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows: +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) endif() + # - Ensure that the timestamp will change. # - Change the json files referenced by A_CUSTOM_MACRO # - Rebuild -file(TIMESTAMP "${plCFile}" plCBefore "${timeformat}") -file(TIMESTAMP "${plDFile}" plDBefore "${timeformat}") -file(TIMESTAMP "${plEFile}" plEBefore "${timeformat}") - -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing json files") configure_file("${mocPlugSrcDir}/jsonIn/StyleE.json" "${mocPlugBinDir}/jsonFiles/StyleC_Custom.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleC.json" "${mocPlugBinDir}/jsonFiles/sub/StyleD_Custom.json") configure_file("${mocPlugSrcDir}/jsonIn/StyleD.json" "${mocPlugBinDir}/jsonFiles/StyleE_Custom.json") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${mocPlugBinDir}") - -file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}") -file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}") -file(TIMESTAMP "${plEFile}" plEAfter "${timeformat}") - -if (NOT plCAfter GREATER plCBefore) - message(SEND_ERROR "file (${plCFile}) should have changed!") -endif() -if (NOT plDAfter GREATER plDBefore) - message(SEND_ERROR "file (${plDFile}) should have changed!") -endif() -if (NOT plEAfter GREATER plEBefore) - # There's a bug in Ninja on Windows - # https://gitlab.kitware.com/cmake/cmake/issues/16776 - if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) - message(SEND_ERROR "file (${plEFile}) should have changed!") - endif() +sleep() +rebuild(3) +acquire_timestamps(After) +# Test changes +require_change_not(A) +require_change_not(B) +require_change(C) +require_change(D) +# There's a bug in Ninja on Windows +# https://gitlab.kitware.com/cmake/cmake/issues/16776 +if(NOT ("${CMAKE_GENERATOR}" MATCHES "Ninja")) + require_change(E) endif() diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt index dcb7a79..33c01ac 100644 --- a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt @@ -9,10 +9,23 @@ add_executable(dummy dummy.cpp) # When a .qrc or a file listed in a .qrc file changes, # the target must be rebuilt -set(timeformat "%Y%j%H%M%S") set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccConfigChange") set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccConfigChange") +# Rebuild macro +macro(rebuild CFG) + message(STATUS "Rebuilding rccConfigChange in ${CFG} configuration.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . --config "${CFG}" + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "${CFG} build of rccConfigChange failed.") + else() + message(STATUS "${CFG} build of rccConfigChange finished.") + endif() +endmacro() + # Initial build try_compile(RCC_DEPENDS "${rccDepBD}" @@ -24,19 +37,11 @@ try_compile(RCC_DEPENDS OUTPUT_VARIABLE output ) if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccConfigChange failed. Output: ${output}") + message(FATAL_ERROR "Initial build of rccConfigChange failed. Output: ${output}") endif() -# - Rebuild Release -message("Rebuilding rccConfigChange in Release configuration") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Release WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Release build of rccConfigChange failed.") -endif() +# Rebuild: Release +rebuild(Release) -# - Rebuild Debug -message("Rebuilding rccConfigChange in Debug configuration") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . --config Debug WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Debug build of rccConfigChange failed.") -endif() +# Rebuild: Debug +rebuild(Debug) diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt index 80c5cf0..1301550 100644 --- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt @@ -3,19 +3,63 @@ project(RerunRccDepends) include("../AutogenCoreTest.cmake") # Tests rcc rebuilding when a resource file changes +# When a .qrc or a file listed in a .qrc file changes, +# the target must be rebuilt # Dummy executable to generate a clean target add_executable(dummy dummy.cpp) -# When a .qrc or a file listed in a .qrc file changes, -# the target must be rebuilt -set(timeformat "%Y%j%H%M%S") +# Utility variables +set(timeformat "%Y.%j.%H.%M%S") set(rccDepSD "${CMAKE_CURRENT_SOURCE_DIR}/RccDepends") set(rccDepBD "${CMAKE_CURRENT_BINARY_DIR}/RccDepends") -# Initial build +# Utility macros +macro(sleep) + message(STATUS "Sleeping for a few seconds.") + execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +endmacro() + +macro(acquire_timestamps When) + file(TIMESTAMP "${rccDepBinPlain}" rdPlain${When} "${timeformat}") + file(TIMESTAMP "${rccDepBinGenerated}" rdGenerated${When} "${timeformat}") +endmacro() + +macro(rebuild buildName) + message(STATUS "Starting build ${buildName} of rccDepends.") + execute_process( + COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${rccDepBD}" + RESULT_VARIABLE result) + if (result) + message(FATAL_ERROR "Build ${buildName} of rccDepends failed.") + else() + message(STATUS "Build ${buildName} of rccDepends finished.") + endif() +endmacro() + +macro(require_change type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} changed.") + else() + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} did not change!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + endif() +endmacro() + +macro(require_change_not type) + if (rd${type}After VERSION_GREATER rd${type}Before) + message(SEND_ERROR "Unexpectedly the ${type} .qrc file ${rccDepBin${type}} changed!\nTimestamp pre: ${rd${type}Before}\nTimestamp aft: ${rd${type}After}\n") + else() + message(STATUS "As expected the ${type} .qrc file ${rccDepBin${type}} did not change.") + endif() +endmacro() + + +# Initial configuration configure_file(${rccDepSD}/resPlainA.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) configure_file(${rccDepSD}/resGenA.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) + +# Initial build try_compile(RCC_DEPENDS "${rccDepBD}" "${rccDepSD}" @@ -26,113 +70,84 @@ try_compile(RCC_DEPENDS OUTPUT_VARIABLE output ) if (NOT RCC_DEPENDS) - message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}") + message(FATAL_ERROR "Initial build of rccDepends failed. Output: ${output}") endif() # Get name of the output binaries file(STRINGS "${rccDepBD}/targetPlain.txt" targetListPlain ENCODING UTF-8) file(STRINGS "${rccDepBD}/targetGen.txt" targetListGen ENCODING UTF-8) list(GET targetListPlain 0 rccDepBinPlain) -list(GET targetListGen 0 rccDepBinGen) -message("Target that uses a plain .qrc file is:\n ${rccDepBinPlain}") -message("Target that uses a GENERATED .qrc file is:\n ${rccDepBinGen}") +list(GET targetListGen 0 rccDepBinGenerated) +message(STATUS "Target that uses a plain .qrc file is:\n ${rccDepBinPlain}") +message(STATUS "Target that uses a GENERATED .qrc file is:\n ${rccDepBinGenerated}") + +# To avoid a race condition where the binary has the same timestamp +# as a source file and therefore gets rebuild +# - sleep to ensure a timestamp change +# - touch binary to ensure it has a new timestamp +acquire_timestamps(Before) +sleep() +message(STATUS "Touching binary files to ensure new timestamps") +file(TOUCH_NOCREATE "${rccDepBinPlain}" "${rccDepBinGenerated}") +acquire_timestamps(After) +require_change(Plain) +require_change(Generated) -message("Changing a resource files listed in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change a resource files listed in the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a resource file listed in the .qrc file") file(TOUCH "${rccDepBD}/resPlain/input.txt" "${rccDepBD}/resGen/input.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Second build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(2) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing the .qrc file") configure_file(${rccDepSD}/resPlainB.qrc.in ${rccDepBD}/resPlain.qrc COPYONLY) configure_file(${rccDepSD}/resGenB.qrc.in ${rccDepBD}/resGen.qrc.in COPYONLY) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Third build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(3) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing a newly added resource files listed in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change a newly added resource files listed in the .qrc file # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) +acquire_timestamps(Before) +sleep() +message(STATUS "Changing a newly added resource file listed in the .qrc file") file(TOUCH "${rccDepBD}/resPlain/inputAdded.txt" "${rccDepBD}/resGen/inputAdded.txt") -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fourth build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +sleep() +rebuild(4) +acquire_timestamps(After) # - Test if timestamps changed -if (NOT rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should have changed!") -endif() -if (NOT rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should have changed!") -endif() +require_change(Plain) +require_change(Generated) -message("Changing nothing in the .qrc file") -# - Acquire binary timestamps before the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainBefore "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenBefore "${timeformat}") # - Ensure that the timestamp will change # - Change nothing # - Rebuild -execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) -execute_process(COMMAND "${CMAKE_COMMAND}" --build . WORKING_DIRECTORY "${rccDepBD}" RESULT_VARIABLE result) -if (result) - message(SEND_ERROR "Fifth build of rccDepends failed.") -endif() -# - Acquire binary timestamps after the build -file(TIMESTAMP "${rccDepBinPlain}" rdPlainAfter "${timeformat}") -file(TIMESTAMP "${rccDepBinGen}" rdGenAfter "${timeformat}") +acquire_timestamps(Before) +sleep() +message(STATUS "Changing nothing in the .qrc file") +rebuild(5) +acquire_timestamps(After) # - Test if timestamps changed -if (rdPlainAfter GREATER rdPlainBefore) - message(SEND_ERROR "Plain .qrc binary ${rccDepBinPlain}) should NOT have changed!") -endif() -if (rdGenAfter GREATER rdGenBefore) - message(SEND_ERROR "GENERATED .qrc binary ${rccDepBinGen} should NOT have changed!") -endif() +require_change_not(Plain) +require_change_not(Generated) diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt index fd954e6..ed68400 100644 --- a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt @@ -1,7 +1,7 @@ ^CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\): Error evaluating generator expression: - \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY1>> + \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY2>> Dependency loop found. Call Stack \(most recent call first\): @@ -11,7 +11,7 @@ Call Stack \(most recent call first\): CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\): Loop step 1 - \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY2>> + \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY1>> Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) @@ -20,7 +20,7 @@ Call Stack \(most recent call first\): CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\): Loop step 2 - \$<TARGET_GENEX_EVAL:recursion,\$<TARGET_PROPERTY:recursion,CUSTOM_PROPERTY1>> + \$<GENEX_EVAL:\$<TARGET_PROPERTY:CUSTOM_PROPERTY2>> Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake index ab8988b..153cd17 100644 --- a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake +++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake @@ -7,5 +7,6 @@ add_library (example SHARED empty.c) set_property (TARGET example PROPERTY CUSTOM_PROPERTY1 "PROPERTY1") set_property (TARGET example PROPERTY CUSTOM_PROPERTY2 "$<TARGET_PROPERTY:CUSTOM_PROPERTY1>") set_property (TARGET example PROPERTY CUSTOM_PROPERTY3 "$<GENEX_EVAL:BEFORE_$<TARGET_PROPERTY:CUSTOM_PROPERTY2>_AFTER>") +set_property (TARGET example PROPERTY CUSTOM_PROPERTY4 "$<GENEX_EVAL:$<TARGET_PROPERTY:CUSTOM_PROPERTY3>>") -file(GENERATE OUTPUT "GENEX_EVAL-generated.txt" CONTENT "$<TARGET_GENEX_EVAL:example,$<TARGET_PROPERTY:example,CUSTOM_PROPERTY3>>") +file(GENERATE OUTPUT "GENEX_EVAL-generated.txt" CONTENT "$<TARGET_GENEX_EVAL:example,$<TARGET_PROPERTY:example,CUSTOM_PROPERTY4>>") diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 184a7be..54e96a2 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -165,6 +165,35 @@ try_compile(TEST_INNER OUTPUT_VARIABLE output) TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") +try_compile(COMPILE_DEFINITIONS_LIST_EXPANDED + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/check_a_b.c + OUTPUT_VARIABLE output + COMPILE_DEFINITIONS "-DDEF_A;-DDEF_B" + ) +if(COMPILE_DEFINITIONS_LIST_EXPANDED) + message(STATUS "COMPILE_DEFINITIONS list expanded correctly") +else() + string(REPLACE "\n" "\n " output " ${output}") + message(SEND_ERROR "COMPILE_DEFINITIONS list did not expand correctly\n${output}") +endif() + +try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE output + COMPILE_DEFINITIONS "bad#source.c" + ) +if(SHOULD_FAIL_DUE_TO_BAD_SOURCE AND NOT CMAKE_GENERATOR MATCHES "Watcom WMake|NMake Makefiles") + string(REPLACE "\n" "\n " output " ${output}") + message(SEND_ERROR "try_compile with bad#source.c did not fail:\n${output}") +elseif(NOT output MATCHES [[(bad#source\.c|bad\\)]]) + string(REPLACE "\n" "\n " output " ${output}") + message(SEND_ERROR "try_compile with bad#source.c failed without mentioning bad source:\n${output}") +else() + message(STATUS "try_compile with bad#source.c correctly failed") +endif() + add_executable(TryCompile pass.c) ###################################### diff --git a/Tests/TryCompile/check_a_b.c b/Tests/TryCompile/check_a_b.c new file mode 100644 index 0000000..05fba0f --- /dev/null +++ b/Tests/TryCompile/check_a_b.c @@ -0,0 +1,10 @@ +#ifndef DEF_A +# error DEF_A not defined +#endif +#ifndef DEF_B +# error DEF_B not defined +#endif +int main() +{ + return 0; +} |