diff options
43 files changed, 348 insertions, 180 deletions
diff --git a/.gitlab/ci/cmake.ps1 b/.gitlab/ci/cmake.ps1 index 5d01e3f..fd8e29f 100755 --- a/.gitlab/ci/cmake.ps1 +++ b/.gitlab/ci/cmake.ps1 @@ -1,7 +1,7 @@ $erroractionpreference = "stop" -$version = "3.21.0" -$sha256sum = "C7B88C907A753F4EC86E43DDC89F91F70BF1B011859142F7F29E6D51EA4ABB3C" +$version = "3.23.1" +$sha256sum = "9B509CC4EB7191DC128CFA3F2170036F9CBC7D9D5F93FF7FAFC5B2D77B3B40DC" $filename = "cmake-$version-windows-x86_64" $tarball = "$filename.zip" diff --git a/.gitlab/ci/cmake.sh b/.gitlab/ci/cmake.sh index c37f6dc..7d964ee 100755 --- a/.gitlab/ci/cmake.sh +++ b/.gitlab/ci/cmake.sh @@ -2,22 +2,22 @@ set -e -readonly version="3.21.0" +readonly version="3.23.1" case "$(uname -s)-$(uname -m)" in Linux-x86_64) shatool="sha256sum" - sha256sum="d54ef6909f519740bc85cec07ff54574cd1e061f9f17357d9ace69f61c6291ce" + sha256sum="f3c654b2e226b9d43369e0bd8487c51618d4dbe5a1af929dd32af7e6ca432d60" platform="linux-x86_64" ;; Linux-aarch64) shatool="sha256sum" - sha256sum="b1e46825bf370f45f8f47c3a497b1122759ee41fbd60187e525f517a4b0934eb" + sha256sum="74062efddeb935bce3d33694a4db534cef9a650f77a9a153a9f217d9dc385c75" platform="linux-aarch64" ;; Darwin-*) shatool="shasum -a 256" - sha256sum="c1c6f19dfc9c658a48b5aed22806595b2337bb3aedb71ab826552f74f568719f" + sha256sum="f794ed92ccb4e9b6619a77328f313497d7decf8fb7e047ba35a348b838e0e1e2" platform="macos-universal" ;; *) diff --git a/Help/prop_tgt/HEADER_SETS.rst b/Help/prop_tgt/HEADER_SETS.rst index fcf723e..ceb1df5 100644 --- a/Help/prop_tgt/HEADER_SETS.rst +++ b/Help/prop_tgt/HEADER_SETS.rst @@ -3,14 +3,13 @@ HEADER_SETS .. versionadded:: 3.23 -List of the target's ``PRIVATE`` and ``PUBLIC`` header sets (i.e. all -file sets with the type ``HEADERS``). Files listed in these file sets -are treated as source files for the purpose of IDE integration. -The files also have their :prop_sf:`HEADER_FILE_ONLY` property set to -``TRUE``. +Read-only list of the target's ``PRIVATE`` and ``PUBLIC`` header sets (i.e. +all file sets with the type ``HEADERS``). Files listed in these file sets are +treated as source files for the purpose of IDE integration. The files also +have their :prop_sf:`HEADER_FILE_ONLY` property set to ``TRUE``. -This property is normally only set by :command:`target_sources(FILE_SET)` -rather than being manipulated directly. +Header sets may be defined using the :command:`target_sources` command +``FILE_SET`` option with type ``HEADERS``. See also :prop_tgt:`HEADER_SET_<NAME>`, :prop_tgt:`HEADER_SET` and :prop_tgt:`INTERFACE_HEADER_SETS`. diff --git a/Help/prop_tgt/INTERFACE_HEADER_SETS.rst b/Help/prop_tgt/INTERFACE_HEADER_SETS.rst index 62db5b3..2d3bdac 100644 --- a/Help/prop_tgt/INTERFACE_HEADER_SETS.rst +++ b/Help/prop_tgt/INTERFACE_HEADER_SETS.rst @@ -3,12 +3,12 @@ INTERFACE_HEADER_SETS .. versionadded:: 3.23 -List of the target's ``INTERFACE`` and ``PUBLIC`` header sets (i.e. all -file sets with the type ``HEADERS``). Files listed in these header sets +Read-only list of the target's ``INTERFACE`` and ``PUBLIC`` header sets (i.e. +all file sets with the type ``HEADERS``). Files listed in these header sets can be installed with :command:`install(TARGETS)` and exported with :command:`install(EXPORT)` and :command:`export`. -This property is normally only set by :command:`target_sources(FILE_SET)` -rather than being manipulated directly. +Header sets may be defined using the :command:`target_sources` command +``FILE_SET`` option with type ``HEADERS``. See also :prop_tgt:`HEADER_SETS`. diff --git a/Help/release/3.22.rst b/Help/release/3.22.rst index efac925..00e93f6 100644 --- a/Help/release/3.22.rst +++ b/Help/release/3.22.rst @@ -151,9 +151,9 @@ Changes made since CMake 3.22.0 include the following. 3.22.1 ------ -This version made no changes to documented features or interfaces. -Some implementation updates were made to support ecosystem changes -and/or fix regressions. +* This version made no changes to documented features or interfaces. + Some implementation updates were made to support ecosystem changes + and/or fix regressions. 3.22.2 ------ @@ -169,3 +169,10 @@ and/or fix regressions. errors in existing projects. The fix has been reverted to restore compatibility. The fix may be restored in a future version of CMake via a policy. + +3.22.4 +------ + +* This version made no changes to documented features or interfaces. + Some implementation updates were made to support ecosystem changes + and/or fix regressions. diff --git a/Help/release/3.23.rst b/Help/release/3.23.rst index 257c3d5..2febbec 100644 --- a/Help/release/3.23.rst +++ b/Help/release/3.23.rst @@ -114,8 +114,8 @@ Variables Properties ---------- -* The :prop_tgt:`HEADER_SETS` and :prop_tgt:`INTERFACE_HEADER_SETS` target - properties were added to list header sets associated with a target. +* The :prop_tgt:`HEADER_SETS` and :prop_tgt:`INTERFACE_HEADER_SETS` read-only + target properties were added to list header sets associated with a target. * The :prop_tgt:`HEADER_SET` and :prop_tgt:`HEADER_SET_<NAME>` target properties were added to list files in the default header set @@ -278,3 +278,7 @@ Changes made since CMake 3.23.0 include the following. targets. Pending further work in a future version of CMake, it is now an error to add a ``FILE_SET`` of type ``HEADERS`` to such targets on Apple platforms. + +* The :prop_tgt:`HEADER_SETS` and :prop_tgt:`INTERFACE_HEADER_SETS` target + properties added in CMake 3.23.0 are now read-only records of the header + sets created by the :command:`target_sources` command. diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake index 6424472..452348b 100644 --- a/Modules/CheckPIESupported.cmake +++ b/Modules/CheckPIESupported.cmake @@ -22,10 +22,13 @@ property for executables will be honored at link time. Options are: ``OUTPUT_VARIABLE <output>`` - Set ``<output>`` variable with details about any error. + Set ``<output>`` variable with details about any error. If the check is + bypassed because it uses cached results from a previous call, the output + will be empty even if errors were present in the previous call. ``LANGUAGES <lang>...`` Check the linkers used for each of the specified languages. + If this option is not provided, the command checks all enabled languages. ``C``, ``CXX``, ``Fortran`` are supported. @@ -43,9 +46,9 @@ Variables For each language checked, two boolean cache variables are defined. ``CMAKE_<lang>_LINK_PIE_SUPPORTED`` - Set to ``YES`` if ``PIE`` is supported by the linker and ``NO`` otherwise. + Set to true if ``PIE`` is supported by the linker and false otherwise. ``CMAKE_<lang>_LINK_NO_PIE_SUPPORTED`` - Set to ``YES`` if ``NO_PIE`` is supported by the linker and ``NO`` otherwise. + Set to true if ``NO_PIE`` is supported by the linker and false otherwise. Examples ^^^^^^^^ @@ -139,7 +142,7 @@ function (check_pie_supported) # no support at link time. Set cache variables to NO set(CMAKE_${lang}_LINK_PIE_SUPPORTED NO CACHE INTERNAL "PIE (${lang})") set(CMAKE_${lang}_LINK_NO_PIE_SUPPORTED NO CACHE INTERNAL "NO_PIE (${lang})") - string (APPEND outputs "PIE and NO_PIE are not supported by linker for ${lang}") + string (APPEND outputs "PIE and NO_PIE are not supported by linker for ${lang}\n") endif() endforeach() diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 7a16048..43041c5 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -97,6 +97,9 @@ endfunction() find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) pkg_check_modules(GLUT QUIET glut) + if(NOT GLUT_FOUND) + pkg_check_modules(GLUT QUIET freeglut) + endif() if(GLUT_FOUND) # GLUT_INCLUDE_DIRS is now the official result variable, but # older versions of CMake only provided GLUT_INCLUDE_DIR. @@ -111,7 +114,7 @@ if(WIN32) find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h PATHS ${GLUT_ROOT_PATH}/include ) mark_as_advanced(GLUT_INCLUDE_DIR) - find_library( GLUT_glut_LIBRARY_RELEASE NAMES glut glut32 freeglut + find_library( GLUT_glut_LIBRARY_RELEASE NAMES freeglut glut glut32 PATHS ${OPENGL_LIBRARY_DIR} ${GLUT_ROOT_PATH}/Release diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake index 99850b4..08a386a 100644 --- a/Modules/FindGit.cmake +++ b/Modules/FindGit.cmake @@ -31,16 +31,16 @@ Example usage: endif() #]=======================================================================] -# Look for 'git' or 'eg' (easy git) +# Look for 'git' # -set(git_names git eg) +set(git_names git) # Prefer .cmd variants on Windows unless running in a Makefile # in the MSYS shell. # if(CMAKE_HOST_WIN32) if(NOT CMAKE_GENERATOR MATCHES "MSYS") - set(git_names git.cmd git eg.cmd eg) + set(git_names git.cmd git) # GitHub search path for Windows file(GLOB github_path "$ENV{LOCALAPPDATA}/Github/PortableGit*/cmd" diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 25c5c09..2233aa0 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -53,7 +53,7 @@ is set regardless of the presence of the ``Server`` component in find_package ca # In Windows the default installation of PostgreSQL uses that as part of the path. # E.g C:\Program Files\PostgreSQL\8.4. # Currently, the following version numbers are known to this module: -# "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# "14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" # # To use this variable just do something like this: # set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") @@ -102,7 +102,7 @@ set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to wher set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} - "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + "14" "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") # Define additional search paths for root directories. set( PostgreSQL_ROOT_DIRECTORIES diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 63af9b6..f7996ba 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -218,7 +218,7 @@ endif() #===================================================================== # Determine whether unix or win32 paths should be used #===================================================================== -if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_CROSSCOMPILING) +if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT MINGW AND NOT CMAKE_CROSSCOMPILING) set(wxWidgets_FIND_STYLE "win32") else() set(wxWidgets_FIND_STYLE "unix") diff --git a/Modules/Internal/HeaderpadWorkaround.cmake b/Modules/Internal/HeaderpadWorkaround.cmake new file mode 100644 index 0000000..9a7f9f5 --- /dev/null +++ b/Modules/Internal/HeaderpadWorkaround.cmake @@ -0,0 +1,69 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# Do NOT include this module directly into any of your code. It is used by +# the try_compile() implementation to work around a specific issue with +# conflicting flags when building for Apple platforms. +if(NOT APPLE) + return() +endif() + +cmake_policy(PUSH) +cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced + +function(__cmake_internal_workaround_headerpad_flag_conflict _LANG) + + # Until we can avoid hard-coding -Wl,-headerpad_max_install_names in the + # linker flags, we need to remove it here for cases where we know it will + # conflict with other flags, generate a warning and be ignored. + set(regex "(^| )(-fembed-bitcode(-marker|=(all|bitcode|marker))?|-bundle_bitcode)($| )") + set(remove_headerpad NO) + + # Check arbitrary flags that the user or project has set. These compiler + # flags get added to the linker command line. + if("${CMAKE_${_LANG}_FLAGS}" MATCHES "${regex}") + set(remove_headerpad YES) + endif() + if(NOT remove_headerpad) + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + # Only one of these config-specific variables will be set by try_compile() + # and the rest will be unset, but we can't easily tell which one is set. + # No harm to just add them all here, empty ones won't add flags to check. + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) + if("${CMAKE_${_LANG}_FLAGS_${config}}" MATCHES "${regex}") + set(remove_headerpad YES) + break() + endif() + endforeach() + else() + if("${CMAKE_${_LANG}_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") + set(remove_headerpad YES) + endif() + endif() + endif() + + # The try_compile() command passes compiler flags to check in a way that + # results in them being added to add_definitions(). Those don't end up on + # the linker command line, so we don't need to check them here. + + if(remove_headerpad) + foreach(flag IN ITEMS + CMAKE_${_LANG}_LINK_FLAGS + CMAKE_SHARED_LIBRARY_CREATE_${_LANG}_FLAGS + CMAKE_SHARED_MODULE_CREATE_${_LANG}_FLAGS) + string(REPLACE "-Wl,-headerpad_max_install_names" "" ${flag} "${${flag}}") + set(${flag} "${${flag}}" PARENT_SCOPE) + endforeach() + endif() +endfunction() + +get_property(__enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach(__lang IN LISTS __enabled_languages) + __cmake_internal_workaround_headerpad_flag_conflict(${__lang}) +endforeach() +unset(__lang) +unset(__enabled_languages) + +cmake_policy(POP) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index dbf49c6..9bcb3bf 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 23) -set(CMake_VERSION_PATCH 20220410) +set(CMake_VERSION_PATCH 20220414) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 9b3a649..8a7bb86 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -191,9 +191,9 @@ void cmCursesLongMessageForm::HandleInput() if (key == 'o' || key == 'e') { break; } - if (key == KEY_DOWN || key == ctrl('n')) { + if (key == KEY_DOWN || key == ctrl('n') || key == 'j') { form_driver(this->Form, REQ_SCR_FLINE); - } else if (key == KEY_UP || key == ctrl('p')) { + } else if (key == KEY_UP || key == ctrl('p') || key == 'k') { form_driver(this->Form, REQ_SCR_BLINE); } else if (key == KEY_NPAGE || key == ctrl('d')) { form_driver(this->Form, REQ_SCR_FPAGE); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 84fa897..324ce87 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -831,6 +831,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, ? "NEW" : "OLD"); + // Workaround for -Wl,-headerpad_max_install_names issue until we can avoid + // adding that flag in the platform and compiler language files + fprintf(fout, + "include(\"${CMAKE_ROOT}/Modules/Internal/" + "HeaderpadWorkaround.cmake\")\n"); + if (targetType == cmStateEnums::EXECUTABLE) { /* Put the executable at a known location (for COPY_FILE). */ fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n", diff --git a/Source/cmFileSet.cxx b/Source/cmFileSet.cxx index 2c06dc6..1d1d29e 100644 --- a/Source/cmFileSet.cxx +++ b/Source/cmFileSet.cxx @@ -7,19 +7,79 @@ #include <utility> #include <vector> +#include <cmext/string_view> + #include "cmsys/RegularExpression.hxx" #include "cmGeneratorExpression.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" +#include "cmMakefile.h" #include "cmMessageType.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" -cmFileSet::cmFileSet(std::string name, std::string type) +cm::static_string_view cmFileSetVisibilityToName(cmFileSetVisibility vis) +{ + switch (vis) { + case cmFileSetVisibility::Interface: + return "INTERFACE"_s; + case cmFileSetVisibility::Public: + return "PUBLIC"_s; + case cmFileSetVisibility::Private: + return "PRIVATE"_s; + } + return ""_s; +} + +cmFileSetVisibility cmFileSetVisibilityFromName(cm::string_view name, + cmMakefile* mf) +{ + if (name == "INTERFACE"_s) { + return cmFileSetVisibility::Interface; + } + if (name == "PUBLIC"_s) { + return cmFileSetVisibility::Public; + } + if (name == "PRIVATE"_s) { + return cmFileSetVisibility::Private; + } + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("File set visibility \"", name, "\" is not valid.")); + return cmFileSetVisibility::Private; +} + +bool cmFileSetVisibilityIsForSelf(cmFileSetVisibility vis) +{ + switch (vis) { + case cmFileSetVisibility::Interface: + return false; + case cmFileSetVisibility::Public: + case cmFileSetVisibility::Private: + return true; + } + return false; +} + +bool cmFileSetVisibilityIsForInterface(cmFileSetVisibility vis) +{ + switch (vis) { + case cmFileSetVisibility::Interface: + case cmFileSetVisibility::Public: + return true; + case cmFileSetVisibility::Private: + return false; + } + return false; +} + +cmFileSet::cmFileSet(std::string name, std::string type, + cmFileSetVisibility visibility) : Name(std::move(name)) , Type(std::move(type)) + , Visibility(visibility) { } diff --git a/Source/cmFileSet.h b/Source/cmFileSet.h index 3aad75f..5357e77 100644 --- a/Source/cmFileSet.h +++ b/Source/cmFileSet.h @@ -7,20 +7,38 @@ #include <string> #include <vector> +#include <cm/string_view> +#include <cmext/string_view> + #include "cmListFileCache.h" class cmCompiledGeneratorExpression; struct cmGeneratorExpressionDAGChecker; class cmGeneratorTarget; class cmLocalGenerator; +class cmMakefile; + +enum class cmFileSetVisibility +{ + Private, + Public, + Interface, +}; +cm::static_string_view cmFileSetVisibilityToName(cmFileSetVisibility vis); +cmFileSetVisibility cmFileSetVisibilityFromName(cm::string_view name, + cmMakefile* mf); +bool cmFileSetVisibilityIsForSelf(cmFileSetVisibility vis); +bool cmFileSetVisibilityIsForInterface(cmFileSetVisibility vis); class cmFileSet { public: - cmFileSet(std::string name, std::string type); + cmFileSet(std::string name, std::string type, + cmFileSetVisibility visibility); const std::string& GetName() const { return this->Name; } const std::string& GetType() const { return this->Type; } + cmFileSetVisibility GetVisibility() const { return this->Visibility; } void ClearDirectoryEntries(); void AddDirectoryEntry(BT<std::string> directories); @@ -61,6 +79,7 @@ public: private: std::string Name; std::string Type; + cmFileSetVisibility Visibility; std::vector<BT<std::string>> DirectoryEntries; std::vector<BT<std::string>> FileEntries; }; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 4fa7d4f..c54d5bf 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2493,12 +2493,12 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) static const std::array<std::string, 4> langs = { { "C", "CXX", "OBJC", "OBJCXX" } }; - bool haveAnyPch = false; + std::set<std::string> pchLangSet; if (this->GetGlobalGenerator()->IsXcode()) { for (const std::string& lang : langs) { const std::string pchHeader = target->GetPchHeader(config, lang, ""); if (!pchHeader.empty()) { - haveAnyPch = true; + pchLangSet.emplace(lang); } } } @@ -2543,9 +2543,11 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) const std::string pchHeader = target->GetPchHeader(config, lang, arch); if (pchSource.empty() || pchHeader.empty()) { - if (this->GetGlobalGenerator()->IsXcode() && haveAnyPch) { + if (this->GetGlobalGenerator()->IsXcode() && !pchLangSet.empty()) { for (auto* sf : sources) { - sf->SetProperty("SKIP_PRECOMPILE_HEADERS", "ON"); + if (pchLangSet.find(sf->GetLanguage()) == pchLangSet.end()) { + sf->SetProperty("SKIP_PRECOMPILE_HEADERS", "ON"); + } } } continue; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e2314e2..5c43bc8 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1484,37 +1484,14 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) BT<std::string>(value, this->impl->Makefile->GetBacktrace())); } } else if (prop == propHEADER_SETS) { - if (value) { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - } - this->impl->HeaderSetsEntries.clear(); - if (!StringIsEmpty(value)) { - this->impl->HeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); - } + this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, + "HEADER_SETS property is read-only\n"); + return; } else if (prop == propINTERFACE_HEADER_SETS) { - if (value) { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - } - this->impl->InterfaceHeaderSetsEntries.clear(); - if (!StringIsEmpty(value)) { - this->impl->InterfaceHeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); - } + this->impl->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "INTERFACE_HEADER_SETS property is read-only\n"); + return; } else { this->impl->Properties.SetProperty(prop, value); } @@ -1680,27 +1657,14 @@ void cmTarget::AppendProperty(const std::string& prop, fileSet->AddFileEntry( BT<std::string>(value, this->impl->Makefile->GetBacktrace())); } else if (prop == "HEADER_SETS") { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - this->impl->HeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); + this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, + "HEADER_SETS property is read-only\n"); + return; } else if (prop == "INTERFACE_HEADER_SETS") { - for (auto const& name : cmExpandedList(value)) { - if (!this->GetFileSet(name)) { - this->impl->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - cmStrCat("Header set \"", name, "\" has not yet been created.")); - return; - } - } - this->impl->InterfaceHeaderSetsEntries.emplace_back( - value, this->impl->Makefile->GetBacktrace()); + this->impl->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "INTERFACE_HEADER_SETS property is read-only\n"); + return; } else { this->impl->Properties.AppendProperty(prop, value, asString); } @@ -2125,13 +2089,26 @@ cmValue cmTarget::GetProperty(const std::string& prop) const return cmValue(output); } if (prop == propHEADER_SETS) { + std::vector<std::string> set_names; + for (auto const& file_set : this->impl->FileSets) { + if (cmFileSetVisibilityIsForSelf(file_set.second.GetVisibility())) { + set_names.push_back(file_set.second.GetName()); + } + } static std::string output; - output = cmJoin(this->impl->HeaderSetsEntries, ";"_s); + output = cmJoin(set_names, ";"_s); return cmValue(output); } if (prop == propINTERFACE_HEADER_SETS) { + std::vector<std::string> set_names; + for (auto const& file_set : this->impl->FileSets) { + if (cmFileSetVisibilityIsForInterface( + file_set.second.GetVisibility())) { + set_names.push_back(file_set.second.GetName()); + } + } static std::string output; - output = cmJoin(this->impl->InterfaceHeaderSetsEntries, ";"_s); + output = cmJoin(set_names, ";"_s); return cmValue(output); } } @@ -2429,10 +2406,20 @@ cmFileSet* cmTarget::GetFileSet(const std::string& name) } std::pair<cmFileSet*, bool> cmTarget::GetOrCreateFileSet( - const std::string& name, const std::string& type) + const std::string& name, const std::string& type, cmFileSetVisibility vis) { - auto result = - this->impl->FileSets.emplace(std::make_pair(name, cmFileSet(name, type))); + auto result = this->impl->FileSets.emplace( + std::make_pair(name, cmFileSet(name, type, vis))); + if (result.second) { + if (cmFileSetVisibilityIsForSelf(vis)) { + this->impl->HeaderSetsEntries.emplace_back( + name, this->impl->Makefile->GetBacktrace()); + } + if (cmFileSetVisibilityIsForInterface(vis)) { + this->impl->InterfaceHeaderSetsEntries.emplace_back( + name, this->impl->Makefile->GetBacktrace()); + } + } return std::make_pair(&result.first->second, result.second); } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 0cdd2fc..97fdbeb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -12,6 +12,7 @@ #include <vector> #include "cmAlgorithms.h" +#include "cmFileSet.h" #include "cmPolicies.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -19,7 +20,6 @@ #include "cmValue.h" class cmCustomCommand; -class cmFileSet; class cmGlobalGenerator; class cmInstallTargetGenerator; class cmListFileBacktrace; @@ -287,7 +287,8 @@ public: const cmFileSet* GetFileSet(const std::string& name) const; cmFileSet* GetFileSet(const std::string& name); std::pair<cmFileSet*, bool> GetOrCreateFileSet(const std::string& name, - const std::string& type); + const std::string& type, + cmFileSetVisibility vis); std::vector<std::string> GetAllInterfaceFileSets() const; diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx index 9173a34..b1367e1 100644 --- a/Source/cmTargetSourcesCommand.cxx +++ b/Source/cmTargetSourcesCommand.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTargetSourcesCommand.h" -#include <algorithm> #include <sstream> #include <utility> @@ -239,7 +238,11 @@ bool TargetSourcesImpl::HandleOneFileSet( (args.Type.empty() && args.FileSet[0] >= 'A' && args.FileSet[0] <= 'Z'); std::string type = isDefault ? args.FileSet : args.Type; - auto fileSet = this->Target->GetOrCreateFileSet(args.FileSet, type); + cmFileSetVisibility visibility = + cmFileSetVisibilityFromName(scope, this->Makefile); + + auto fileSet = + this->Target->GetOrCreateFileSet(args.FileSet, type, visibility); if (fileSet.second) { if (!isDefault) { if (!cmFileSet::IsValidName(args.FileSet)) { @@ -261,15 +264,6 @@ bool TargetSourcesImpl::HandleOneFileSet( if (args.BaseDirs.empty()) { args.BaseDirs.emplace_back(this->Makefile->GetCurrentSourceDirectory()); } - - if (scope == "PRIVATE"_s || scope == "PUBLIC"_s) { - this->Target->AppendProperty(cmTarget::GetFileSetsPropertyName(type), - args.FileSet); - } - if (scope == "INTERFACE"_s || scope == "PUBLIC"_s) { - this->Target->AppendProperty( - cmTarget::GetInterfaceFileSetsPropertyName(type), args.FileSet); - } } else { type = fileSet.first->GetType(); if (!args.Type.empty() && args.Type != type) { @@ -279,37 +273,11 @@ bool TargetSourcesImpl::HandleOneFileSet( return false; } - std::string existingScope = "PRIVATE"; - - auto const fileSetsProperty = cmTarget::GetFileSetsPropertyName(type); - auto const interfaceFileSetsProperty = - cmTarget::GetInterfaceFileSetsPropertyName(type); - std::vector<std::string> fileSets; - std::vector<std::string> interfaceFileSets; - cmExpandList(this->Target->GetSafeProperty(fileSetsProperty), fileSets); - cmExpandList(this->Target->GetSafeProperty(interfaceFileSetsProperty), - interfaceFileSets); - - if (std::find(interfaceFileSets.begin(), interfaceFileSets.end(), - args.FileSet) != interfaceFileSets.end()) { - existingScope = "INTERFACE"; - } - if (std::find(fileSets.begin(), fileSets.end(), args.FileSet) != - fileSets.end()) { - if (existingScope == "INTERFACE"_s) { - existingScope = "PUBLIC"; - } - } else if (existingScope != "INTERFACE"_s) { - this->SetError(cmStrCat("File set \"", args.FileSet, "\" is not in ", - fileSetsProperty, " or ", - interfaceFileSetsProperty)); - return false; - } - - if (scope != existingScope) { + if (visibility != fileSet.first->GetVisibility()) { this->SetError( cmStrCat("Scope ", scope, " for file set \"", args.FileSet, - "\" does not match original scope ", existingScope)); + "\" does not match original scope ", + cmFileSetVisibilityToName(fileSet.first->GetVisibility()))); return false; } } @@ -330,11 +298,11 @@ bool TargetSourcesImpl::HandleOneFileSet( for (auto const& dir : cmExpandedList(baseDirectories)) { auto interfaceDirectoriesGenex = cmStrCat("$<BUILD_INTERFACE:", dir, ">"); - if (scope == "PRIVATE"_s || scope == "PUBLIC"_s) { + if (cmFileSetVisibilityIsForSelf(visibility)) { this->Target->AppendProperty("INCLUDE_DIRECTORIES", interfaceDirectoriesGenex); } - if (scope == "INTERFACE"_s || scope == "PUBLIC"_s) { + if (cmFileSetVisibilityIsForInterface(visibility)) { this->Target->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", interfaceDirectoriesGenex); } diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 96bf845..28be166 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -308,10 +308,11 @@ int do_cmake(int ac, char const* const* av) parsedArgs.emplace_back("--find-package"); return true; } }, - CommandArgument{ "--list-presets", CommandArgument::Values::Zero, - [&](std::string const&) -> bool { + CommandArgument{ "--list-presets", CommandArgument::Values::ZeroOrOne, + [&](std::string const& value) -> bool { workingMode = cmake::HELP_MODE; parsedArgs.emplace_back("--list-presets"); + parsedArgs.emplace_back(value); return true; } }, }; diff --git a/Tests/RunCMake/CMakePresets/ListConfigurePresetsWorkingDir-stdout.txt b/Tests/RunCMake/CMakePresets/ListConfigurePresetsWorkingDir-stdout.txt new file mode 100644 index 0000000..97eedae --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListConfigurePresetsWorkingDir-stdout.txt @@ -0,0 +1,7 @@ +^Not searching for unused variables given on the command line\. +Available configure presets: + + "zzzzzz" - Sleepy + "aaaaaaaa" - Screaming + "mmmmmm" + "no-generator"$ diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 449132a..5867efd 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -71,13 +71,18 @@ function(run_cmake_presets name) set(_unused_cli) endif() + set(_preset "--preset=${name}") + if(CMakePresets_NO_PRESET) + set(_preset) + endif() + set(RunCMake_TEST_COMMAND ${CMAKE_COMMAND} ${_source_args} -DRunCMake_TEST=${name} -DRunCMake_GENERATOR=${RunCMake_GENERATOR} -DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM} ${_unused_cli} - --preset=${name} + ${_preset} ${ARGN} ) run_cmake(${name}) @@ -288,7 +293,10 @@ run_cmake_presets(ListPresets --list-presets) set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/ListPresetsWorkingDir") set(RunCMake_TEST_NO_CLEAN 1) set(CMakePresets_NO_SOURCE_ARGS 1) +set(CMakePresets_NO_PRESET 1) run_cmake_presets(ListPresetsWorkingDir --list-presets) +run_cmake_presets(ListConfigurePresetsWorkingDir --list-presets=configure) +unset(CMakePresets_NO_PRESET) unset(CMakePresets_NO_SOURCE_ARGS) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_BINARY_DIR) diff --git a/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake b/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake new file mode 100644 index 0000000..128f9db --- /dev/null +++ b/Tests/RunCMake/CheckCompilerFlag/HeaderpadWorkaround.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +include(CheckCompilerFlag) + +# Confirm we can check the conflicting flag directly. This should pass with +# or without the workaround. +check_compiler_flag(C "-fembed-bitcode" result1) +if(NOT result1) + message(FATAL_ERROR "False negative when -fembed-bitcode tested directly") +endif() + +# Check conflicting flag set by user or project won't cause a false negative +# when testing a valid flag. This only passes with the workaround. +set(CMAKE_C_FLAGS -fembed-bitcode) +check_compiler_flag(C "-O" result2) +if(NOT result2) + message(FATAL_ERROR "False negative when -fembed-bitcode set in CMAKE_C_FLAGS") +endif() diff --git a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake index 7ef1860..df2b667 100644 --- a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake +++ b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake @@ -26,3 +26,7 @@ endif() if(CMake_TEST_HIP) run_cmake(CheckHIPCompilerFlag) endif() + +if(APPLE) + run_cmake_with_options(HeaderpadWorkaround --debug-trycompile) +endif() diff --git a/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake b/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake new file mode 100644 index 0000000..dd582ac --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16) +project(PchIncludedAllLanguages C CXX) + +if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH) + add_definitions(-DHAVE_PCH_SUPPORT) +endif() + +add_executable(main + main.cpp + empty.c + pch-included.cpp +) + +target_precompile_headers(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/pch.h>) + +enable_testing() +add_test(NAME main COMMAND main) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index a7b3126..fd41e2f 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -30,4 +30,5 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") endif() run_test(PchReuseFromObjLib) run_test(PchIncludedAllLanguages) +run_test(PchIncludedOneLanguage) run_test(PchLibObjLibExe) diff --git a/Tests/RunCMake/target_sources/FileSetImport.cmake b/Tests/RunCMake/target_sources/FileSetImport.cmake index 9c7358a..7e790c7 100644 --- a/Tests/RunCMake/target_sources/FileSetImport.cmake +++ b/Tests/RunCMake/target_sources/FileSetImport.cmake @@ -17,7 +17,7 @@ include("${export_build_dir}/export.cmake") include("${export_build_dir}/install/lib/cmake/export.cmake") assert_prop_eq(export::lib1 HEADER_SETS "") -assert_prop_eq(export::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") +assert_prop_eq(export::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;dir3;e;f;g") assert_prop_eq(export::lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/error.c") assert_prop_eq(export::lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") assert_prop_eq(export::lib1 HEADER_SET_b "${CMAKE_CURRENT_SOURCE_DIR}/h2.h") @@ -35,7 +35,7 @@ assert_prop_eq(export::lib1 HEADER_DIRS_g "${CMAKE_CURRENT_SOURCE_DIR}/dir1;${CM assert_prop_eq(export::lib1 INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR};$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/dir1;${CMAKE_CURRENT_SOURCE_DIR}/dir2;${CMAKE_CURRENT_SOURCE_DIR}/dir3;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir1>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir2>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir3>") assert_prop_eq(install::lib1 HEADER_SETS "") -assert_prop_eq(install::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") +assert_prop_eq(install::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;dir3;e;f;g") assert_prop_eq(install::lib1 HEADER_SET "${export_build_dir}/install/include/error.c") assert_prop_eq(install::lib1 HEADER_DIRS "${export_build_dir}/install/include") assert_prop_eq(install::lib1 HEADER_SET_b "${export_build_dir}/install/include/h2.h") diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt b/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt deleted file mode 100644 index 3972c89..0000000 --- a/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -^CMake Error at FileSetNoExistInterface\.cmake:[0-9]+ \(set_property\): - Header set "a" has not yet been created\. -Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt deleted file mode 100644 index 336bafe..0000000 --- a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -^CMake Error at FileSetNoExistPrivate\.cmake:[0-9]+ \(set_property\): - Header set "a" has not yet been created\. -Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake b/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake deleted file mode 100644 index f501912..0000000 --- a/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake +++ /dev/null @@ -1,7 +0,0 @@ -enable_language(C) - -add_library(lib1 STATIC empty.c) -set_property(TARGET lib1 PROPERTY HEADER_SETS "a") - -# Error happens at configure-time, so this doesn't help. -target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt deleted file mode 100644 index 835ffe7..0000000 --- a/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -^CMake Error at FileSetNoScope\.cmake:[0-9]+ \(target_sources\): - target_sources File set "a" is not in HEADER_SETS or INTERFACE_HEADER_SETS -Call Stack \(most recent call first\): - CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoScope.cmake b/Tests/RunCMake/target_sources/FileSetNoScope.cmake deleted file mode 100644 index 79ff341..0000000 --- a/Tests/RunCMake/target_sources/FileSetNoScope.cmake +++ /dev/null @@ -1,6 +0,0 @@ -enable_language(C) - -add_library(lib1 STATIC empty.c) -target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) -set_property(TARGET lib1 PROPERTY HEADER_SETS) -target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS FILES h2.h) diff --git a/Tests/RunCMake/target_sources/FileSetProperties.cmake b/Tests/RunCMake/target_sources/FileSetProperties.cmake index a671ab3..74487fe 100644 --- a/Tests/RunCMake/target_sources/FileSetProperties.cmake +++ b/Tests/RunCMake/target_sources/FileSetProperties.cmake @@ -57,14 +57,14 @@ assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURC assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") target_sources(lib1 PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES h1.h) -assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a;c;d;HEADERS") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "HEADERS;a;c;d") assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h") assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") target_sources(lib1 PUBLIC FILE_SET HEADERS FILES h2.h) -assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a;c;d;HEADERS") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "HEADERS;a;c;d") assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h") assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") diff --git a/Tests/RunCMake/target_sources/FileSetNoScope-result.txt b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/target_sources/FileSetNoScope-result.txt +++ b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-result.txt diff --git a/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt new file mode 100644 index 0000000..2307d13 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetReadOnlyInterface\.cmake:[0-9]+ \(set_property\): + INTERFACE_HEADER_SETS property is read-only + +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface.cmake index 266bc61..468ef91 100644 --- a/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake +++ b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface.cmake @@ -2,6 +2,3 @@ enable_language(C) add_library(lib1 STATIC empty.c) set_property(TARGET lib1 PROPERTY INTERFACE_HEADER_SETS "a") - -# Error happens at configure-time, so this doesn't help. -target_sources(lib1 INTERFACE FILE_SET a TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt +++ b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-result.txt diff --git a/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt new file mode 100644 index 0000000..5f955da --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetReadOnlyPrivate\.cmake:[0-9]+ \(set_property\): + HEADER_SETS property is read-only + +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate.cmake b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate.cmake new file mode 100644 index 0000000..eda92c1 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +set_property(TARGET lib1 PROPERTY HEADER_SETS "a") diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index 743879e..8429c96 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -33,9 +33,8 @@ run_cmake(FileSetWrongBaseDirsRelative) run_cmake(FileSetOverlappingBaseDirs) run_cmake(FileSetInstallMissingSetsPrivate) run_cmake(FileSetInstallMissingSetsInterface) -run_cmake(FileSetNoScope) -run_cmake(FileSetNoExistPrivate) -run_cmake(FileSetNoExistInterface) +run_cmake(FileSetReadOnlyPrivate) +run_cmake(FileSetReadOnlyInterface) run_cmake(FileSetNoExistInstall) run_cmake(FileSetDirectories) run_cmake(FileSetCustomTarget) |