diff options
49 files changed, 448 insertions, 79 deletions
diff --git a/Help/manual/cmake-cxxmodules.7.rst b/Help/manual/cmake-cxxmodules.7.rst index b4c9cf1..3ee6645 100644 --- a/Help/manual/cmake-cxxmodules.7.rst +++ b/Help/manual/cmake-cxxmodules.7.rst @@ -30,6 +30,10 @@ following queries. The first query that provides a yes/no answer is used. - Otherwise, the source file will be scanned if the compiler and generator support scanning. See policy :policy:`CMP0155`. +Note that any scanned source will be excluded from any unity build (see +:prop_tgt:`UNITY_BUILD`) because module-related statements can only happen at +one place within a C++ translation unit. + Compiler Support ================ diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 3e58b31..a0b5b66 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -2333,10 +2333,13 @@ Export And Install Expressions Content of the install prefix when the target is exported via :command:`install(EXPORT)`, or when evaluated in the - :prop_tgt:`INSTALL_NAME_DIR` property, the ``INSTALL_NAME_DIR`` argument of - :command:`install(RUNTIME_DEPENDENCY_SET)`, the code argument of - :command:`install(CODE)`, or the file argument of :command:`install(SCRIPT)`, - and empty otherwise. + :prop_tgt:`INSTALL_NAME_DIR` property or the ``INSTALL_NAME_DIR`` argument of + :command:`install(RUNTIME_DEPENDENCY_SET)`, and empty otherwise. + + .. versionchanged:: 3.27 + Evaluates to the content of the install prefix + in the code argument of :command:`install(CODE)` or + the file argument of :command:`install(SCRIPT)`. Multi-level Expression Evaluation --------------------------------- diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index 0917191..1924d4f 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -754,6 +754,16 @@ The available ``<dashboard-options>`` are the following: This option will submit extra files to the dashboard. +.. option:: --http-header <header> + + .. versionadded:: 3.29 + + Append HTTP header when submitting to the dashboard. + + This option will cause CTest to append the specified header + when submitting to the dashboard. + This option may be specified more than once. + .. option:: --http1.0 Submit using `HTTP 1.0`. diff --git a/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst index ae526ac..38a0a78 100644 --- a/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst +++ b/Help/prop_sf/SKIP_UNITY_BUILD_INCLUSION.rst @@ -11,3 +11,7 @@ in the same way as it would with unity builds disabled. This property helps with "ODR (One definition rule)" problems where combining a particular source file with others might lead to build errors or other unintended side effects. + +Note that sources which are scanned for C++ modules (see +:manual:`cmake-cxxmodules(7)`) are not eligible for unity build inclusion and +will automatically be excluded. diff --git a/Help/prop_tgt/UNITY_BUILD.rst b/Help/prop_tgt/UNITY_BUILD.rst index 52f4714..577b0c9 100644 --- a/Help/prop_tgt/UNITY_BUILD.rst +++ b/Help/prop_tgt/UNITY_BUILD.rst @@ -76,6 +76,11 @@ a number of measures to help address such problems: :prop_sf:`INCLUDE_DIRECTORIES` source property will not be combined into a unity source. +* Any source file which is scanned for C++ module sources via + :prop_tgt:`CXX_SCAN_FOR_MODULES`, :prop_sf:`CXX_SCAN_FOR_MODULES`, or + membership of a ``CXX_MODULES`` file set will not be combined into a unity + source. See :manual:`cmake-cxxmodules(7)` for details. + * Projects can prevent an individual source file from being combined into a unity source by setting its :prop_sf:`SKIP_UNITY_BUILD_INCLUSION` source property to true. This can be a more effective way to prevent diff --git a/Help/release/dev/ctest-cli-http-headers.rst b/Help/release/dev/ctest-cli-http-headers.rst new file mode 100644 index 0000000..81d4c7b --- /dev/null +++ b/Help/release/dev/ctest-cli-http-headers.rst @@ -0,0 +1,5 @@ +ctest-cli-http-headers +---------------------- + +* :manual:`ctest(1)` gained a :option:`--http-header <ctest --http-header>` + option to add custom headers on submission to CDash. diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 04d500e..7a1c64a 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -56,6 +56,7 @@ set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "") set(CMAKE_Swift_LINK_LIBRARY_FLAG "-l") set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ") set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @) +set(CMAKE_Swift_RESPONSE_FILE_FLAG @) set(CMAKE_Swift_LINKER_PREFERENCE 50) set(CMAKE_Swift_LINKER_PREFERENCE_PROPAGATES 1) diff --git a/Modules/Compiler/LCC-C.cmake b/Modules/Compiler/LCC-C.cmake index 3dd6e68..99f791f 100644 --- a/Modules/Compiler/LCC-C.cmake +++ b/Modules/Compiler/LCC-C.cmake @@ -12,18 +12,25 @@ endif() set(CMAKE_C_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c) -set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") -set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") -set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 1.23) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) +endif() + set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) -set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") -set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") -set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) -set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") -set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") -set(CMAKE_C23_STANDARD_COMPILE_OPTION "-std=c2x") -set(CMAKE_C23_EXTENSION_COMPILE_OPTION "-std=gnu2x") + +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 1.20) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 1.26) + set(CMAKE_C17_STANDARD_COMPILE_OPTION "-std=c17") + set(CMAKE_C17_EXTENSION_COMPILE_OPTION "-std=gnu17") +endif() __compiler_check_default_language_standard(C 1.23 90 1.20 11 1.26 17) diff --git a/Modules/Compiler/LCC-CXX.cmake b/Modules/Compiler/LCC-CXX.cmake index b3bdd3c..385947a 100644 --- a/Modules/Compiler/LCC-CXX.cmake +++ b/Modules/Compiler/LCC-CXX.cmake @@ -17,15 +17,27 @@ set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hi set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) -set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") -set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") -set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) -set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") -set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") -set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) -set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") -set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") -set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") -set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.20) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.21) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.24) + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") +endif() + +if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 1.26) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") +endif() __compiler_check_default_language_standard(CXX 1.19 98 1.20 11 1.21 14 1.24 17 1.26 20) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 0ba35b6..d55c4ca 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -514,7 +514,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) string(TOLOWER "${resolved_file}" lower) if(UNIX) - if(resolved_file MATCHES "^(/lib/|/lib32/|/libx32/|/lib64/|/usr/lib/|/usr/lib32/|/usr/libx32/|/usr/lib64/|/usr/X11R6/|/usr/bin/)") + if(resolved_file MATCHES "^/*(/lib/|/lib32/|/libx32/|/lib64/|/usr/lib/|/usr/lib32/|/usr/libx32/|/usr/lib64/|/usr/X11R6/|/usr/bin/)") set(is_system 1) endif() endif() diff --git a/Modules/Internal/CPack/CPack.NuGet.nuspec.in b/Modules/Internal/CPack/CPack.NuGet.nuspec.in index d89d69f..4548a59 100644 --- a/Modules/Internal/CPack/CPack.NuGet.nuspec.in +++ b/Modules/Internal/CPack/CPack.NuGet.nuspec.in @@ -15,12 +15,14 @@ @_CPACK_NUGET_LICENSE_TAG@ @_CPACK_NUGET_ICONURL_TAG@ @_CPACK_NUGET_ICON_TAG@ + @_CPACK_NUGET_README_TAG@ @_CPACK_NUGET_REQUIRELICENSEACCEPTANCE_TAG@ @_CPACK_NUGET_SUMMARY_TAG@ @_CPACK_NUGET_RELEASENOTES_TAG@ @_CPACK_NUGET_COPYRIGHT_TAG@ @_CPACK_NUGET_LANGUAGE_TAG@ @_CPACK_NUGET_TAGS_TAG@ + @_CPACK_NUGET_REPOSITORY_TAG@ @_CPACK_NUGET_DEPENDENCIES_TAG@ </metadata> @_CPACK_NUGET_FILES_TAG@ diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index 056d025..67f318a 100644 --- a/Modules/Internal/CPack/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -294,6 +294,27 @@ function(_cpack_nuget_render_spec) # attributes: "type", "url", "branch", and "commit". While all fields are # considered optional, they are not independent. Currently unsupported. + # NuGet >= 5.10 + _cpack_nuget_variable_fallback_and_wrap_into_element(readme README) + + set(_CPACK_NUGET_REPOSITORY_TAG) + _cpack_nuget_variable_fallback(_repo_type REPOSITORY_TYPE) + _cpack_nuget_variable_fallback(_repo_url REPOSITORY_URL) + if(_repo_type AND _repo_url) + set(_CPACK_NUGET_REPOSITORY_TAG "<repository type=\"${_repo_type}\" url=\"${_repo_url}\"") + _cpack_nuget_variable_fallback(_repo_br REPOSITORY_BRANCH) + if(_repo_br) + string(APPEND _CPACK_NUGET_REPOSITORY_TAG " branch=\"${_repo_br}\"") + endif() + _cpack_nuget_variable_fallback(_repo_commit REPOSITORY_COMMIT) + if(_repo_commit) + string(APPEND _CPACK_NUGET_REPOSITORY_TAG " commit=\"${_repo_commit}\"") + endif() + string(APPEND _CPACK_NUGET_REPOSITORY_TAG " />") + else() + message(AUTHOR_WARNING "Skip adding the `<repository .../>` element due to missing URL or type") + endif() + # Handle dependencies _cpack_nuget_variable_fallback(_deps DEPENDENCIES) set(_collected_deps) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index fb119ae..d44baf3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 28) -set(CMake_VERSION_PATCH 20240109) +set(CMake_VERSION_PATCH 20240110) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 77af889..db8a054 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -138,6 +138,19 @@ void cmCTestSubmitHandler::Initialize() this->Files.clear(); } +int cmCTestSubmitHandler::ProcessCommandLineArguments( + const std::string& currentArg, size_t& idx, + const std::vector<std::string>& allArgs) +{ + if (cmHasLiteralPrefix(currentArg, "--http-header") && + idx < allArgs.size() - 1) { + ++idx; + this->HttpHeaders.push_back(allArgs[idx]); + this->CommandLineHttpHeaders.push_back(allArgs[idx]); + } + return 1; +} + bool cmCTestSubmitHandler::SubmitUsingHTTP( const std::string& localprefix, const std::vector<std::string>& files, const std::string& remoteprefix, const std::string& url) diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 0c7253c..e8eb38a 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <cstddef> #include <iosfwd> #include <set> #include <string> @@ -33,6 +34,11 @@ public: void Initialize() override; + //! Set all the submit arguments + int ProcessCommandLineArguments( + const std::string& currentArg, size_t& idx, + const std::vector<std::string>& allArgs) override; + /** Specify a set of parts (by name) to submit. */ void SelectParts(std::set<cmCTest::Part> const& parts); @@ -44,7 +50,12 @@ public: void SetHttpHeaders(std::vector<std::string> const& v) { - this->HttpHeaders = v; + if (this->CommandLineHttpHeaders.empty()) { + this->HttpHeaders = v; + } else { + this->HttpHeaders = this->CommandLineHttpHeaders; + this->HttpHeaders.insert(this->HttpHeaders.end(), v.begin(), v.end()); + } } private: @@ -75,5 +86,6 @@ private: bool HasWarnings; bool HasErrors; std::set<std::string> Files; + std::vector<std::string> CommandLineHttpHeaders; std::vector<std::string> HttpHeaders; }; diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 89068ab..549cca2 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -91,10 +91,6 @@ public slots: const QString& description, const QVariant& value, bool advanced); - // set the view type - void setViewType(ViewType t); - ViewType viewType() const; - public: // get the properties QCMakePropertyList properties() const; @@ -112,6 +108,10 @@ public: // get the data in the model for this property void getPropertyData(const QModelIndex& idx1, QCMakeProperty& prop) const; + // set the view type + void setViewType(ViewType t); + ViewType viewType() const; + protected: bool EditEnabled; int NewPropertyCount; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index e74a8b0..8a07073 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1612,6 +1612,13 @@ bool cmGlobalGenerator::Compute() } } + // Add unity sources after computing compile features. Unity sources do + // not change the set of languages or features, but we need to know them + // to filter out sources that are scanned for C++ module dependencies. + if (!this->AddUnitySources()) { + return false; + } + for (const auto& localGen : this->LocalGenerators) { cmMakefile* mf = localGen->GetMakefile(); for (const auto& g : mf->GetInstallGenerators()) { @@ -1888,7 +1895,6 @@ bool cmGlobalGenerator::AddAutomaticSources() if (!gt->CanCompileSources()) { continue; } - lg->AddUnityBuild(gt.get()); lg->AddISPCDependencies(gt.get()); // Targets that reuse a PCH are handled below. if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) { @@ -1920,6 +1926,28 @@ bool cmGlobalGenerator::AddAutomaticSources() return true; } +bool cmGlobalGenerator::AddUnitySources() +{ + for (const auto& lg : this->LocalGenerators) { + for (const auto& gt : lg->GetGeneratorTargets()) { + if (!gt->CanCompileSources()) { + continue; + } + lg->AddUnityBuild(gt.get()); + } + } + // The above transformation may have changed the classification of sources. + // Clear the source list and classification cache (KindedSources) of all + // targets so that it will be recomputed correctly by the generators later + // now that the above transformations are done for all targets. + for (const auto& lg : this->LocalGenerators) { + for (const auto& gt : lg->GetGeneratorTargets()) { + gt->ClearSourcesCache(); + } + } + return true; +} + std::unique_ptr<cmLinkLineComputer> cmGlobalGenerator::CreateLinkLineComputer( cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index d83b669..b1ce323 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -679,6 +679,7 @@ protected: bool AddHeaderSetVerification(); bool AddAutomaticSources(); + bool AddUnitySources(); std::string SelectMakeProgram(const std::string& makeProgram, const std::string& makeDefault = "") const; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 55eb9b5..74a6bea 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -828,6 +828,9 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() this->NinjaExpectedEncoding = codecvt_Encoding::ANSI; } #endif + this->NinjaSupportsCWDDepend = + !cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, this->NinjaVersion, + RequiredNinjaVersionForCWDDepend()); } void cmGlobalNinjaGenerator::CheckNinjaCodePage() @@ -1996,6 +1999,11 @@ bool cmGlobalNinjaGenerator::SupportsMultilineDepfile() const return this->NinjaSupportsMultilineDepfile; } +bool cmGlobalNinjaGenerator::SupportsCWDDepend() const +{ + return this->NinjaSupportsCWDDepend; +} + bool cmGlobalNinjaGenerator::WriteTargetCleanAdditional(std::ostream& os) { const auto& lgr = this->LocalGenerators.at(0); diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 3443643..64eed4d 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -415,10 +415,12 @@ public: return "1.10.2"; } static std::string RequiredNinjaVersionForCodePage() { return "1.11"; } + static std::string RequiredNinjaVersionForCWDDepend() { return "1.7"; } bool SupportsDirectConsole() const override; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; bool SupportsMultilineDepfile() const; + bool SupportsCWDDepend() const; std::string NinjaOutputPath(std::string const& path) const; bool HasOutputPathPrefix() const { return !this->OutputPathPrefix.empty(); } @@ -597,6 +599,7 @@ private: bool NinjaSupportsMultipleOutputs = false; bool NinjaSupportsMetadataOnRegeneration = false; bool NinjaSupportsCodePage = false; + bool NinjaSupportsCWDDepend = false; codecvt_Encoding NinjaExpectedEncoding = codecvt_Encoding::None; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 38c49ed..ab1de4f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3210,6 +3210,15 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target) std::vector<cmSourceFile*> sources; target->GetSourceFiles(sources, configs[ci]); for (cmSourceFile* sf : sources) { + // Files which need C++ scanning cannot participate in unity builds as + // there is a single place in TUs that may perform module-dependency bits + // and a unity source cannot `#include` them in-order and represent a + // valid TU. + if (sf->GetLanguage() == "CXX"_s && + target->NeedDyndepForSource("CXX", configs[ci], sf)) { + continue; + } + auto mi = index.find(sf); if (mi == index.end()) { unitySources.emplace_back(sf); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 4fd22fc..ff509ce 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1724,11 +1724,10 @@ void cmMakefileTargetGenerator::GenerateCustomRuleFile( if (!ccg.GetCC().GetDepfile().empty()) { // Add dependency over timestamp file for dependencies management - auto dependTimestamp = cmSystemTools::ConvertToOutputPath( - this->LocalGenerator->MaybeRelativeToTopBinDir( - cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.ts"))); + auto dependTimestamp = this->LocalGenerator->MaybeRelativeToTopBinDir( + cmStrCat(this->TargetBuildDirectoryFull, "/compiler_depend.ts")); - depends.push_back(dependTimestamp); + depends.emplace_back(std::move(dependTimestamp)); } // Write the rule. diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 99ea009..d365ef6 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -453,7 +453,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, vars.Language = lang.c_str(); vars.AIXExports = "$AIX_EXPORTS"; - if (this->TargetLinkLanguage(config) == "Swift") { + if (!this->GetLocalGenerator()->IsSplitSwiftBuild() && + this->TargetLinkLanguage(config) == "Swift") { vars.SwiftLibraryName = "$SWIFT_LIBRARY_NAME"; vars.SwiftModule = "$SWIFT_MODULE"; vars.SwiftModuleName = "$SWIFT_MODULE_NAME"; @@ -508,7 +509,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile, vars.LinkLibraries = "$LINK_PATH $LINK_LIBRARIES"; } - if (this->TargetLinkLanguage(config) == "Swift") { + if (!this->GetLocalGenerator()->IsSplitSwiftBuild() && + this->TargetLinkLanguage(config) == "Swift") { vars.SwiftSources = responseFlag.c_str(); } else { vars.Objects = responseFlag.c_str(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index bc75a95..c493778 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -411,28 +411,29 @@ std::string cmNinjaTargetGenerator::GetCompiledSourceNinjaPath( return this->ConvertToNinjaAbsPath(source->GetFullPath()); } -std::string cmNinjaTargetGenerator::GetObjectFilePath( - cmSourceFile const* source, const std::string& config) const +std::string cmNinjaTargetGenerator::GetObjectFileDir( + const std::string& config) const { std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); if (!path.empty()) { path += '/'; } - std::string const& objectName = this->GeneratorTarget->GetObjectName(source); - path += cmStrCat( - this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), - this->GetGlobalGenerator()->ConfigDirectory(config), '/', objectName); + path += + cmStrCat(this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), + this->GetGlobalGenerator()->ConfigDirectory(config)); return path; } -std::string cmNinjaTargetGenerator::GetBmiFilePath( +std::string cmNinjaTargetGenerator::GetObjectFilePath( cmSourceFile const* source, const std::string& config) const { - std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); - if (!path.empty()) { - path += '/'; - } + std::string const& objectName = this->GeneratorTarget->GetObjectName(source); + return cmStrCat(this->GetObjectFileDir(config), '/', objectName); +} +std::string cmNinjaTargetGenerator::GetBmiFilePath( + cmSourceFile const* source, const std::string& config) const +{ auto& importedConfigInfo = this->Configs.at(config).ImportedCxxModules; if (!importedConfigInfo.Initialized()) { std::string configUpper = cmSystemTools::UpperCase(config); @@ -444,10 +445,7 @@ std::string cmNinjaTargetGenerator::GetBmiFilePath( std::string bmiName = importedConfigInfo.BmiNameForSource(source->GetFullPath()); - path += cmStrCat( - this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), - this->GetGlobalGenerator()->ConfigDirectory(config), '/', bmiName); - return path; + return cmStrCat(this->GetObjectFileDir(config), '/', bmiName); } std::string cmNinjaTargetGenerator::GetClangTidyReplacementsFilePath( @@ -1025,6 +1023,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( } } + if (!this->GetGlobalGenerator()->SupportsCWDDepend()) { + // Ensure that the object directory exists. If there are no objects in the + // target (e.g., an empty `OBJECT` library), the directory is still listed + // as an order-only depends in the build files. Alternate `ninja` + // implementations may not allow this (such as `samu`). See #25526. + auto const objectDir = this->GetObjectFileDir(config); + this->EnsureDirectoryExists(objectDir); + } + { cmNinjaBuild build("phony"); build.Comment = @@ -1099,11 +1106,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( // that "output ... of phony edge with no inputs doesn't exist" and // consider the phony output "dirty". if (orderOnlyDeps.empty()) { - // Any path that always exists will work here. It would be nice to - // use just "." but that is not supported by Ninja < 1.7. - std::string tgtDir = cmStrCat( - this->LocalGenerator->GetCurrentBinaryDirectory(), '/', - this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget)); + std::string tgtDir; + if (this->GetGlobalGenerator()->SupportsCWDDepend()) { + tgtDir = "."; + } else { + // Any path that always exists will work here. + tgtDir = cmStrCat( + this->LocalGenerator->GetCurrentBinaryDirectory(), '/', + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget)); + } orderOnlyDeps.push_back(this->ConvertToNinjaPath(tgtDir)); } @@ -2017,6 +2028,7 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement( std::string const targetObjectFilename = this->ConvertToNinjaPath(cmStrCat( objectDir, '/', moduleName, this->GetGlobalGenerator()->GetLanguageOutputExtension(language))); + objBuild.RspFile = cmStrCat(targetObjectFilename, ".swift.rsp"); if (isSingleOutput) { this->LocalGenerator->AppendFlags(vars["FLAGS"], @@ -2076,7 +2088,8 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement( // Write object build this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig), - objBuild); + objBuild, + this->ForceResponseFile() ? -1 : 0); } void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang, diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index f081117..2bfed80 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -128,6 +128,7 @@ protected: /// @return the source file path for the given @a source. std::string GetCompiledSourceNinjaPath(cmSourceFile const* source) const; + std::string GetObjectFileDir(const std::string& config) const; /// @return the object file path for the given @a source. std::string GetObjectFilePath(cmSourceFile const* source, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bbd934..d572f30 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2784,7 +2784,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( isCppModule = true; if (shouldScanForModules && this->GlobalGenerator->IsScanDependenciesSupported()) { - // ScanSourceforModuleDependencies uses 'cl /scanDependencies' and + // ScanSourceForModuleDependencies uses 'cl /scanDependencies' and // can distinguish module interface units and internal partitions. compileAsPerConfig = "CompileAsCpp"; } else { @@ -2827,7 +2827,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( // use them if (!flags.empty() || !options.empty() || !configDefines.empty() || !includes.empty() || compileAsPerConfig || noWinRT || - !options.empty() || needsPCHFlags) { + !options.empty() || needsPCHFlags || shouldScanForModules) { cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator; cmIDEFlagTable const* flagtable = nullptr; const std::string& srclang = source->GetLanguage(); @@ -2856,9 +2856,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( clOptions.AddFlag("CompileAs", compileAsPerConfig); } if (shouldScanForModules) { - clOptions.AddFlag("ScanSourceforModuleDependencies", "true"); - } else { - clOptions.AddFlag("ScanSourceforModuleDependencies", "false"); + clOptions.AddFlag("ScanSourceForModuleDependencies", "true"); } if (noWinRT) { clOptions.AddFlag("CompileAsWinRT", "false"); @@ -3574,6 +3572,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( e2.Element("AdditionalUsingDirectories", dirs); } } + + // Disable C++ source scanning by default. + e2.Element("ScanSourceForModuleDependencies", "false"); } bool cmVisualStudio10TargetGenerator::ComputeRcOptions() diff --git a/Source/ctest.cxx b/Source/ctest.cxx index fa38a65..b2867e2 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -25,7 +25,7 @@ const cmDocumentationEntry cmDocumentationName = { const cmDocumentationEntry cmDocumentationUsage = { {}, " ctest [options]" }; -const cmDocumentationEntry cmDocumentationOptions[74] = { +const cmDocumentationEntry cmDocumentationOptions[] = { { "--preset <preset>, --preset=<preset>", "Read arguments from a test preset." }, { "--list-presets", "List available test presets." }, @@ -143,6 +143,7 @@ const cmDocumentationEntry cmDocumentationOptions[74] = { { "--tomorrow-tag", "Nightly or experimental starts with next day tag." }, { "--overwrite", "Overwrite CTest configuration option." }, { "--extra-submit <file>[;<file>]", "Submit extra files to the dashboard." }, + { "--http-header <header>", "Append HTTP header when submitting" }, { "--force-new-ctest-process", "Run child CTest instances as new processes" }, { "--schedule-random", "Use a random order for scheduling tests" }, diff --git a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake index 19c09c8..c3725a4 100644 --- a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake +++ b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake @@ -24,6 +24,17 @@ add_library(toplib STATIC toplib.c) add_subdirectory(DepfileSubdir) +set(TEST_SPACE 1) +if(CMAKE_GENERATOR STREQUAL "Unix Makefiles") + execute_process(COMMAND "${CMAKE_MAKE_PROGRAM}" no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) + if(NOT res EQUAL 0 OR NOT out MATCHES "GNU") + set(TEST_SPACE 0) + endif() +endif() +if(TEST_SPACE) + add_subdirectory(DepfileSubdirWithSpace) +endif() + add_custom_command( OUTPUT toplib2.c DEPFILE toplib2.c.d diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt new file mode 100644 index 0000000..204f740 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory("path with space") diff --git a/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt new file mode 100644 index 0000000..37c0a57 --- /dev/null +++ b/Tests/RunCMake/BuildDepends/DepfileSubdirWithSpace/path with space/CMakeLists.txt @@ -0,0 +1,9 @@ + +add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" + COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" + DEPFILE dummy.txt.d +) + +add_custom_target(subdir_space ALL + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/dummy.txt" +) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a4e4800..cbd9cbc 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -345,7 +345,17 @@ if(DEFINED CMake_TEST_OBJC) list(APPEND CompilerTest_ARGS -DCMake_TEST_OBJC=${CMake_TEST_OBJC}) endif() if(CMAKE_Fortran_COMPILER) - list(APPEND CompilerTest_ARGS -DCMake_TEST_Fortran=1) + # lfortran < 1.24 cannot handle long file names. Fortran is not + # enabled here, so check the C compiler version instead. + if(CMAKE_C_COMPILER_ID STREQUAL "LCC" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "1.24") + string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}" _CCBD_LEN) + if(_CCBD_LEN LESS 35) + list(APPEND CompilerTest_ARGS -DCMake_TEST_Fortran=1) + endif() + unset(_CCBD_LEN) + else() + list(APPEND CompilerTest_ARGS -DCMake_TEST_Fortran=1) + endif() endif() foreach(lang IN ITEMS CUDA HIP ISPC) if(CMake_TEST_${lang}) @@ -1040,6 +1050,31 @@ set(cpack_tests if(APPLE) list(APPEND cpack_tests DragNDrop) endif() + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k" AND NOT DEFINED CMake_TEST_E2K_BROKEN_LIBC) + # Exclude tests that fail due to a broken libc version on Elbrus. + find_program(DPKG_QUERY "dpkg-query" ) + execute_process(COMMAND "${DPKG_QUERY}" "-f" "\${Version}" "-W" "glibc" OUTPUT_VARIABLE LIBC_VERSION) + if(LIBC_VERSION MATCHES "2.29-25.*") + list(REMOVE_ITEM cpack_tests + DEB.AUTO_SUFFIXES + DEB.CUSTOM_NAMES + DEB.DEB_PACKAGE_VERSION_BACK_COMPATIBILITY + DEB.PROJECT_META DEB.DEPENDENCIES + RPM.PARTIALLY_RELOCATABLE_WARNING + RPM.PER_COMPONENT_FIELDS + RPM.USER_FILELIST + RPM.DIST + RPM.AUTO_SUFFIXES + TGZ + ZIP + STGZ + External + ) + set(CMake_TEST_E2K_BROKEN_LIBC 1) + endif() +endif() + add_RunCMake_test_group(CPack "${cpack_tests}") # add a test to make sure symbols are exported from a shared library # for MSVC compilers CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS property is used @@ -1094,14 +1129,16 @@ add_RunCMake_test(CMakePresetsBuild -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} ) -add_RunCMake_test(CMakePresetsTest - -DPython_EXECUTABLE=${Python_EXECUTABLE} - -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} - ) -add_RunCMake_test(CMakePresetsPackage - -DPython_EXECUTABLE=${Python_EXECUTABLE} - -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} - ) +if(NOT CMake_TEST_E2K_BROKEN_LIBC) + add_RunCMake_test(CMakePresetsTest + -DPython_EXECUTABLE=${Python_EXECUTABLE} + -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} + ) + add_RunCMake_test(CMakePresetsPackage + -DPython_EXECUTABLE=${Python_EXECUTABLE} + -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} + ) +endif() add_RunCMake_test(CMakePresetsWorkflow -DPython_EXECUTABLE=${Python_EXECUTABLE} -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index fcfa60a..abede44 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -170,7 +170,9 @@ run_cxx_module_test(scan-with-pch) # Tests which use named modules. if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(simple) + run_cxx_module_test(vs-without-flags) run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF) + run_cxx_module_test(unity-build) run_cxx_module_test(object-library) run_cxx_module_test(generated) run_cxx_module_test(deep-chain) diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt index 47be1d9..110e411 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/CMakeLists.txt @@ -18,8 +18,10 @@ string(REPLACE "<DEFINES>" "<DEFINES> -DCMAKE_SCANNED_THIS_SOURCE" set_property(SOURCE always_scan.cxx PROPERTY CXX_SCAN_FOR_MODULES 1) -set_property(SOURCE never_scan.cxx +set_property(SOURCE never_scan.ixx PROPERTY CXX_SCAN_FOR_MODULES 0) +set_property(SOURCE never_scan.ixx + PROPERTY LANGUAGE CXX) add_executable(scans_everything) target_sources(scans_everything @@ -27,7 +29,7 @@ target_sources(scans_everything main.cxx join.cxx always_scan.cxx - never_scan.cxx + never_scan.ixx PRIVATE FILE_SET CXX_MODULES BASE_DIRS @@ -46,7 +48,7 @@ target_sources(no_scan_everything main.cxx join.cxx always_scan.cxx - never_scan.cxx + never_scan.ixx PRIVATE FILE_SET CXX_MODULES BASE_DIRS diff --git a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx b/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.ixx index b47510b..b47510b 100644 --- a/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.cxx +++ b/Tests/RunCMake/CXXModules/examples/scan_properties/never_scan.ixx diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt new file mode 100644 index 0000000..ce1751d --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.28) +project(cxx_modules_unity CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +set(CMAKE_UNITY_BUILD 1) + +add_executable(unity) +target_sources(unity + PRIVATE + main.cxx + unity1.cxx + unity2.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + importable.cxx) +target_compile_features(unity PUBLIC cxx_std_20) + +set_property(SOURCE unity1.cxx unity2.cxx + PROPERTY + CXX_SCAN_FOR_MODULES 0) + +add_test(NAME unity COMMAND unity) diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx new file mode 100644 index 0000000..148b033 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/importable.cxx @@ -0,0 +1,10 @@ +module; + +#include "unity.h" + +export module importable; + +export int from_import() +{ + return unity1() + unity2(); +} diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx new file mode 100644 index 0000000..feb38d2 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/main.cxx @@ -0,0 +1,6 @@ +import importable; + +int main(int argc, char* argv[]) +{ + return from_import(); +} diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity.h b/Tests/RunCMake/CXXModules/examples/unity-build/unity.h new file mode 100644 index 0000000..4a65a4b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity.h @@ -0,0 +1,7 @@ +#ifndef unity_h +#define unity_h + +int unity1(); +int unity2(); + +#endif diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx new file mode 100644 index 0000000..fd1cbb3 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity1.cxx @@ -0,0 +1,8 @@ +#include "unity.h" + +#define DETECT_UNITY + +int unity1() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx b/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx new file mode 100644 index 0000000..0f25cff --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/unity-build/unity2.cxx @@ -0,0 +1,10 @@ +#include "unity.h" + +#ifndef DETECT_UNITY +# error "Should have detected a unity build" +#endif + +int unity2() +{ + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt new file mode 100644 index 0000000..0d18a66 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.28) +project(cxx_modules_vs_without_flags CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_SCAN_FOR_MODULES ON) + +add_executable(vs_without_flags) +target_sources(vs_without_flags + PRIVATE + main.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + module.cxx) + +add_test(NAME vs_without_flags COMMAND vs_without_flags) diff --git a/Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx b/Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx new file mode 100644 index 0000000..239ab00 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx @@ -0,0 +1,6 @@ +import mod; + +int main(int argc, char* argv[]) +{ + return f(); +} diff --git a/Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx b/Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx new file mode 100644 index 0000000..27a61a6 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx @@ -0,0 +1,6 @@ +export module mod; + +export int f() +{ + return 0; +} diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesFortran.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesFortran.cmake index 48dc525..68c5735 100644 --- a/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesFortran.cmake +++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesFortran.cmake @@ -5,6 +5,14 @@ include(CheckSourceCompiles) set(Fortran 1) # test that this is tolerated +# lfortran < 1.24 cannot handle long file names. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "LCC" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "1.24") + string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}" _CCBD_LEN) + if(_CCBD_LEN GREATER_EQUAL 35) + return() + endif() +endif() + check_source_compiles(Fortran [=[ PROGRAM TEST_HAVE_PRINT PRINT *, 'Hello' diff --git a/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsFortran.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsFortran.cmake index 50e8ec8..fc5506a 100644 --- a/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsFortran.cmake +++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsFortran.cmake @@ -5,6 +5,14 @@ include(CheckSourceRuns) set(Fortran 1) # test that this is tolerated +# lfortran < 1.24 cannot handle long file names. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "LCC" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS "1.24") + string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}" _CCBD_LEN) + if(_CCBD_LEN GREATER_EQUAL 35) + return() + endif() +endif() + check_source_runs(Fortran [=[ PROGRAM TEST_HAVE_PRINT PRINT *, 'Hello' diff --git a/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt new file mode 100644 index 0000000..576f5a1 --- /dev/null +++ b/Tests/RunCMake/Swift/ForceResponseFile-check-stdout.txt @@ -0,0 +1,4 @@ +swiftc [^ +]* -c @CMakeFiles/L.dir/L.o.swift.rsp [^ +]* +.*swiftc -emit-library -static -o libL.a @CMakeFiles/L.rsp.* diff --git a/Tests/RunCMake/Swift/ForceResponseFile.cmake b/Tests/RunCMake/Swift/ForceResponseFile.cmake new file mode 100644 index 0000000..7fd4636 --- /dev/null +++ b/Tests/RunCMake/Swift/ForceResponseFile.cmake @@ -0,0 +1,13 @@ +if(POLICY CMP0157) + cmake_policy(SET CMP0157 NEW) +endif() + +if(NOT CMAKE_GENERATOR STREQUAL "Ninja") + message(SEND_ERROR "this test must use Ninja generator, found ${CMAKE_GENERATOR} ") +endif() + +set(CMAKE_NINJA_FORCE_RESPONSE_FILE TRUE) + +enable_language(Swift) + +add_library(L STATIC L.swift) diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake index f0ad0bd..5de4346 100644 --- a/Tests/RunCMake/Swift/RunCMakeTest.cmake +++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake @@ -69,6 +69,13 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja) run_cmake(CompileCommands) run_cmake_command(CompileCommands-check ${CMAKE_COMMAND} --build ${CompileCommands_TEST_BINARY_DIR}) endblock() + + block() + set(ForceResponseFile_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ForceResponseFile-build) + run_cmake(ForceResponseFile) + # -v: verbose to capture executed commands -n: dry-run to avoid actually compiling + run_cmake_command(ForceResponseFile-check ${CMAKE_COMMAND} --build ${ForceResponseFile_TEST_BINARY_DIR} -- -vn) + endblock() endif() elseif(RunCMake_GENERATOR STREQUAL "Ninja Multi-Config") if(CMake_TEST_Swift) diff --git a/Tests/RunCMake/export/DependOnDoubleExport-stderr.txt b/Tests/RunCMake/export/DependOnDoubleExport-stderr.txt index e8f8a09..a884939 100644 --- a/Tests/RunCMake/export/DependOnDoubleExport-stderr.txt +++ b/Tests/RunCMake/export/DependOnDoubleExport-stderr.txt @@ -1,7 +1,7 @@ CMake Error in CMakeLists.txt: export called with target "exported" which requires target "doubleexported" - that is not in this export set, but in multiple other export sets: - .*/Tests/RunCMake/export/DependOnDoubleExport-build/exportset.cmake, + that is not in this export set, but in multiple other export sets:.* + .*/Tests/RunCMake/export/DependOnDoubleExport-build/exportset.cmake,.* .*/Tests/RunCMake/export/DependOnDoubleExport-build/manual.cmake. + An exported target cannot depend upon another target which is exported |