From 576567f028f2366dda84fe3deb1d6cca62cb9890 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Sun, 16 Jun 2024 16:02:30 +0200 Subject: [PATCH] Link feature attributes: stabilization * enhance OVERRIDE handling * Update wording --- Help/manual/cmake-variables.7.rst | 4 +- Help/release/3.30.rst | 6 +- ..._LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst} | 6 +- ...CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst} | 37 ++-- .../CMAKE_LINK_LIBRARY_USING_FEATURE.txt | 4 +- Modules/Platform/Apple-Clang.cmake | 2 +- Modules/Platform/Apple-GNU.cmake | 2 +- Modules/Platform/CYGWIN-GNU.cmake | 2 +- Modules/Platform/Darwin.cmake | 16 +- Modules/Platform/FreeBSD.cmake | 2 +- Modules/Platform/Linux.cmake | 2 +- Modules/Platform/NetBSD.cmake | 2 +- Modules/Platform/SunOS.cmake | 2 +- Modules/Platform/Windows-Clang.cmake | 2 +- Modules/Platform/Windows-GNU.cmake | 2 +- Modules/Platform/Windows-IntelLLVM.cmake | 2 +- Modules/Platform/Windows-MSVC.cmake | 2 +- Source/cmComputeLinkDepends.cxx | 193 ++++++++++-------- .../GenEx-LINK_LIBRARY/RunCMakeTest.cmake | 15 +- ...txt => bad-feature-attributes1-result.txt} | 0 .../bad-feature-attributes1-stderr.txt | 4 + ...s5.cmake => bad-feature-attributes1.cmake} | 2 +- ...txt => bad-feature-attributes2-result.txt} | 0 .../bad-feature-attributes2-stderr.txt | 4 + ...s2.cmake => bad-feature-attributes2.cmake} | 2 +- ...txt => bad-feature-attributes3-result.txt} | 0 .../bad-feature-attributes3-stderr.txt | 4 + ...s3.cmake => bad-feature-attributes3.cmake} | 2 +- ...txt => bad-feature-attributes4-result.txt} | 0 .../bad-feature-attributes4-stderr.txt | 4 + .../bad-feature-attributes4.cmake | 10 + ...txt => bad-feature-attributes5-result.txt} | 0 .../bad-feature-attributes5-stderr.txt | 4 + ...s4.cmake => bad-feature-attributes5.cmake} | 2 +- .../bad-feature-properties1-stderr.txt | 4 - .../bad-feature-properties2-stderr.txt | 4 - .../bad-feature-properties3-stderr.txt | 4 - .../bad-feature-properties4-stderr.txt | 4 - .../bad-feature-properties5-stderr.txt | 4 - .../cyclic-override-result.txt | 1 + .../cyclic-override-stderr.txt | 6 + .../GenEx-LINK_LIBRARY/cyclic-override.cmake | 14 ++ .../GenEx-LINK_LIBRARY/library-ignored.cmake | 2 +- .../multiple-override.cmake | 14 ++ .../unsupported-library_type-stderr.txt | 6 + ...1.cmake => unsupported-library_type.cmake} | 2 +- 46 files changed, 240 insertions(+), 166 deletions(-) rename Help/variable/{CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst => CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst} (64%) rename Help/variable/{CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst => CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst} (78%) rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties1-result.txt => bad-feature-attributes1-result.txt} (100%) create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-stderr.txt rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties5.cmake => bad-feature-attributes1.cmake} (80%) rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties2-result.txt => bad-feature-attributes2-result.txt} (100%) create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-stderr.txt rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties2.cmake => bad-feature-attributes2.cmake} (71%) rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties3-result.txt => bad-feature-attributes3-result.txt} (100%) create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-stderr.txt rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties3.cmake => bad-feature-attributes3.cmake} (80%) rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties4-result.txt => bad-feature-attributes4-result.txt} (100%) create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-stderr.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4.cmake rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties5-result.txt => bad-feature-attributes5-result.txt} (100%) create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-stderr.txt rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties4.cmake => bad-feature-attributes5.cmake} (75%) delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-stderr.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-result.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-stderr.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override.cmake create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-override.cmake create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type-stderr.txt rename Tests/RunCMake/GenEx-LINK_LIBRARY/{bad-feature-properties1.cmake => unsupported-library_type.cmake} (80%) diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 6400a933dd..1abdd626e8 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -467,7 +467,7 @@ Variables that Control the Build /variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE /variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE /variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE_SUPPORTED - /variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES + /variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES /variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG /variable/CMAKE_LANG_LINK_LIBRARY_FLAG /variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE @@ -486,7 +486,7 @@ Variables that Control the Build /variable/CMAKE_LINK_GROUP_USING_FEATURE /variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED /variable/CMAKE_LINK_INTERFACE_LIBRARIES - /variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES + /variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES /variable/CMAKE_LINK_LIBRARY_FILE_FLAG /variable/CMAKE_LINK_LIBRARY_FLAG /variable/CMAKE_LINK_LIBRARY_USING_FEATURE diff --git a/Help/release/3.30.rst b/Help/release/3.30.rst index dc0d573fc8..ce489f62cf 100644 --- a/Help/release/3.30.rst +++ b/Help/release/3.30.rst @@ -148,9 +148,9 @@ Generator Expressions associated :variable:`CMAKE__COMPILER_FRONTEND_VARIANT` variables. * Link features, as used with the :genex:`LINK_LIBRARY` generator expression, - gained the ability to have properties that describe their behavior by - specifying the :variable:`CMAKE_LINK_LIBRARY__PROPERTIES` or - :variable:`CMAKE__LINK_LIBRARY__PROPERTIES` variables. + gained the ability to have attributes that describe their behavior by + specifying the :variable:`CMAKE_LINK_LIBRARY__ATTRIBUTES` or + :variable:`CMAKE__LINK_LIBRARY__ATTRIBUTES` variables. * The :genex:`QUOTE` generator expression was added to evaluate to ``"``. diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst similarity index 64% rename from Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst rename to Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst index 10f4fdacac..8769d605e4 100644 --- a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst +++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst @@ -1,10 +1,10 @@ -CMAKE__LINK_LIBRARY__PROPERTIES +CMAKE__LINK_LIBRARY__ATTRIBUTES ---------------------------------------------- .. versionadded:: 3.30 This variable defines the semantics of the specified link library ```` when linking with the link language ````. It takes precedence over -:variable:`CMAKE_LINK_LIBRARY__PROPERTIES` if that variable is also +:variable:`CMAKE_LINK_LIBRARY__ATTRIBUTES` if that variable is also defined for the same ````, but otherwise has similar effects. -See :variable:`CMAKE_LINK_LIBRARY__PROPERTIES` for further details. +See :variable:`CMAKE_LINK_LIBRARY__ATTRIBUTES` for further details. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst b/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst similarity index 78% rename from Help/variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst rename to Help/variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst index e30c30a7fd..c9966ff78b 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst +++ b/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst @@ -1,4 +1,4 @@ -CMAKE_LINK_LIBRARY__PROPERTIES +CMAKE_LINK_LIBRARY__ATTRIBUTES --------------------------------------- .. versionadded:: 3.30 @@ -17,28 +17,29 @@ The :variable:`CMAKE__LINK_LIBRARY_USING__SUPPORTED` and control whether the ```` is available at all. When linking for a particular language ````, -``CMAKE_LINK_LIBRARY__PROPERTIES`` is ignored if the -:variable:`CMAKE__LINK_LIBRARY__PROPERTIES` variable is also +``CMAKE_LINK_LIBRARY__ATTRIBUTES`` is ignored if the +:variable:`CMAKE__LINK_LIBRARY__ATTRIBUTES` variable is also defined for the same ````. -The value of ``CMAKE_LINK_LIBRARY__PROPERTIES`` and -:variable:`CMAKE__LINK_LIBRARY__PROPERTIES` at the end of the +The value of ``CMAKE_LINK_LIBRARY__ATTRIBUTES`` and +:variable:`CMAKE__LINK_LIBRARY__ATTRIBUTES` at the end of the directory scope in which a target is defined is what matters. -Feature Properties Definition +Feature Attributes Definition ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A feature properties definition is a -:ref:`semicolon-separated list ` of ``property=value(s)`` -items. If a property has multiple values, those values must be comma-separated. +A feature attributes definition is a +:ref:`semicolon-separated list ` of +``attribute=value(s)`` items. If an attribute has multiple values, those values +must be comma-separated. -The following properties are supported: +The following attributes are supported: ``LIBRARY_TYPE=`` Specify the library types supported by the feature. Supported values are: ``STATIC``, ``SHARED``, ``MODULE``, and ``EXECUTABLE``. - If this property is not specified, the default is + If this attribute is not specified, the default is ``LIBRARY_TYPE=STATIC,SHARED,MODULE,EXECUTABLE``. If the feature is used with an unsupported library type, CMake will emit a @@ -51,9 +52,9 @@ The following properties are supported: :prop_tgt:`LINK_LIBRARY_OVERRIDE_` target property definitions, if defined. - If this property is not specified, the default is an empty list. + If this attribute is not specified, the default is an empty list. -``UNICITY=YES|NO|DEFAULT`` +``DEDUPLICATION=YES|NO|DEFAULT`` Specify the de-duplication strategy for a library using this feature. ``YES`` @@ -67,7 +68,7 @@ The following properties are supported: ``DEFAULT`` Let CMake determine a de-duplication strategy automatically. - If this property is not specified, ``DEFAULT`` will be used. + If this attribute is not specified, ``DEFAULT`` will be used. Example ^^^^^^^ @@ -75,14 +76,14 @@ Example A common need is the loading of a full archive as part of the creation of a shared library. The built-in ``WHOLE_ARCHIVE`` feature can be used for that purpose. The implementation of that built-in feature sets the following -link library feature properties: +link library feature attributes: .. code-block:: cmake - set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES + set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC OVERRIDE=DEFAULT - UNICITY=YES + DEDUPLICATION=YES ) ``LIBRARY_TYPE=STATIC`` @@ -92,7 +93,7 @@ link library feature properties: because they are compatible and enhance the user's experience: standard library specification and ``$`` can be used freely. -``UNICITY=YES`` +``DEDUPLICATION=YES`` When this feature is used, the linker loads all symbols from the static library, so there is no need to repeat the library on the linker command line. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt index 59a0d02552..f5c19e09ca 100644 --- a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt +++ b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt @@ -3,8 +3,8 @@ and underscores. Feature names defined in all uppercase are reserved for CMake's own built-in features (see `Predefined Features`_ further below). Some aspects of feature behavior can be defined by the -:variable:`CMAKE__LINK_LIBRARY__PROPERTIES` and -:variable:`CMAKE_LINK_LIBRARY__PROPERTIES` variables. +:variable:`CMAKE__LINK_LIBRARY__ATTRIBUTES` and +:variable:`CMAKE_LINK_LIBRARY__ATTRIBUTES` variables. Feature Definitions ^^^^^^^^^^^^^^^^^^^ diff --git a/Modules/Platform/Apple-Clang.cmake b/Modules/Platform/Apple-Clang.cmake index e0b6cd6ba2..40fed4432b 100644 --- a/Modules/Platform/Apple-Clang.cmake +++ b/Modules/Platform/Apple-Clang.cmake @@ -19,7 +19,7 @@ macro(__apple_compiler_clang lang) set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK "-framework ") set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK_SUPPORTED TRUE) - set(CMAKE_${lang}_LINK_LIBRARY_FRAMEWORK_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) + set(CMAKE_${lang}_LINK_LIBRARY_FRAMEWORK_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) # linker selection set(CMAKE_${lang}_USING_LINKER_SYSTEM "-fuse-ld=ld") diff --git a/Modules/Platform/Apple-GNU.cmake b/Modules/Platform/Apple-GNU.cmake index 20b18ad818..bc4147e765 100644 --- a/Modules/Platform/Apple-GNU.cmake +++ b/Modules/Platform/Apple-GNU.cmake @@ -17,7 +17,7 @@ macro(__apple_compiler_gnu lang) set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK "-framework ") set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK_SUPPORTED TRUE) - set(CMAKE_LINK_LIBRARY_FRAMEWORK_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) + set(CMAKE_LINK_LIBRARY_FRAMEWORK_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) set(CMAKE_${lang}_USING_LINKER_SYSTEM "") set(CMAKE_${lang}_USING_LINKER_APPLE_CLASSIC "LINKER:-ld_classic") diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 5e2ba41821..01b5f912c4 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -40,7 +40,7 @@ else() "LINKER:--no-whole-archive") endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) macro(__cygwin_compiler_gnu lang) diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 1272baff5d..b26912d69a 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -114,37 +114,37 @@ set(CMAKE_CREATE_TEXT_STUBS " stubify -isysroot # Defines LINK_LIBRARY features for frameworks set(CMAKE_LINK_LIBRARY_USING_FRAMEWORK "LINKER:-framework,") set(CMAKE_LINK_LIBRARY_USING_FRAMEWORK_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_FRAMEWORK_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_FRAMEWORK_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) set(CMAKE_LINK_LIBRARY_USING_NEEDED_FRAMEWORK "LINKER:-needed_framework,") set(CMAKE_LINK_LIBRARY_USING_NEEDED_FRAMEWORK_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_NEEDED_FRAMEWORK_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_NEEDED_FRAMEWORK_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) set(CMAKE_LINK_LIBRARY_USING_REEXPORT_FRAMEWORK "LINKER:-reexport_framework,") set(CMAKE_LINK_LIBRARY_USING_REEXPORT_FRAMEWORK_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_REEXPORT_FRAMEWORK_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_REEXPORT_FRAMEWORK_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) set(CMAKE_LINK_LIBRARY_USING_WEAK_FRAMEWORK "LINKER:-weak_framework,") set(CMAKE_LINK_LIBRARY_USING_WEAK_FRAMEWORK_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WEAK_FRAMEWORK_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WEAK_FRAMEWORK_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) # Defines LINK_LIBRARY features for libraries set(CMAKE_LINK_LIBRARY_USING_NEEDED_LIBRARY "PATH{LINKER:-needed_library,}NAME{LINKER:-needed-l}") set(CMAKE_LINK_LIBRARY_USING_NEEDED_LIBRARY_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_NEEDED_LIBRARY_PROPERTIES LIBRARY_TYPE=SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_NEEDED_LIBRARY_ATTRIBUTES LIBRARY_TYPE=SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) set(CMAKE_LINK_LIBRARY_USING_REEXPORT_LIBRARY "PATH{LINKER:-reexport_library,}NAME{LINKER:-reexport-l}") set(CMAKE_LINK_LIBRARY_USING_REEXPORT_LIBRARY_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_REEXPORT_LIBRARY_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_REEXPORT_LIBRARY_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) set(CMAKE_LINK_LIBRARY_USING_WEAK_LIBRARY "PATH{LINKER:-weak_library,}NAME{LINKER:-weak-l}") set(CMAKE_LINK_LIBRARY_USING_WEAK_LIBRARY_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WEAK_LIBRARY_PROPERTIES LIBRARY_TYPE=STATIC,SHARED UNICITY=DEFAULT OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WEAK_LIBRARY_ATTRIBUTES LIBRARY_TYPE=STATIC,SHARED DEDUPLICATION=DEFAULT OVERRIDE=DEFAULT) # Defines LINK_LIBRARY feature to Force loading of all members of an archive set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:-force_load,") set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) # default to searching for frameworks first if(NOT DEFINED CMAKE_FIND_FRAMEWORK) diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index 7d5f9512ec..891422eb8f 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -51,7 +51,7 @@ else() "LINKER:--no-whole-archive") endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) # Features for LINK_GROUP generator expression diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index fba6ab81b7..b9801ee81d 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -44,7 +44,7 @@ else() "LINKER:--no-whole-archive") endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) # Features for LINK_GROUP generator expression ## RESCAN: request the linker to rescan static libraries until there is diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index af368cdc20..892d55ba19 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -37,7 +37,7 @@ else() "LINKER:--no-whole-archive") endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) # Features for LINK_GROUP generator expression diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index 73205c19ce..25e95e6bc5 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -20,7 +20,7 @@ else() "LINKER:-z,defaultextract") endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) # Features for LINK_GROUP generator expression diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 8c9b79cd71..e3725cb375 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -140,7 +140,7 @@ macro(__windows_compiler_clang_gnu lang) ## WHOLE_ARCHIVE: Force loading all members of an archive set(CMAKE_${lang}_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:/WHOLEARCHIVE:") set(CMAKE_${lang}_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) - set(CMAKE_${lang}_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) + set(CMAKE_${lang}_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) endif() enable_language(RC) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index d2b25c6f27..1a4159bcd2 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -88,7 +88,7 @@ else() "LINKER:--no-whole-archive") endif() set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) +set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) # Features for LINK_GROUP generator expression ## RESCAN: request the linker to rescan static libraries until there is diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake index 691c7ce986..517d959592 100644 --- a/Modules/Platform/Windows-IntelLLVM.cmake +++ b/Modules/Platform/Windows-IntelLLVM.cmake @@ -37,7 +37,7 @@ macro(__windows_compiler_intel lang) ## WHOLE_ARCHIVE: Force loading all members of an archive set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:/WHOLEARCHIVE:") set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) - set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) + set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) endif() set(CMAKE_${lang}_LINK_EXECUTABLE diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 3a400e5656..5809379f00 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -358,7 +358,7 @@ if(MSVC_VERSION GREATER "1900") ## WHOLE_ARCHIVE: Force loading all members of an archive set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "/WHOLEARCHIVE:") set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE) - set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES LIBRARY_TYPE=STATIC UNICITY=YES OVERRIDE=DEFAULT) + set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES LIBRARY_TYPE=STATIC DEDUPLICATION=YES OVERRIDE=DEFAULT) endif() diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 2f24ad78d0..193767413c 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -202,8 +202,8 @@ bool IsFeatureSupported(cmMakefile* makefile, std::string const& linkLanguage, return makefile->GetDefinition(featureSupported).IsOn(); } -// LINK_LIBRARY feature properties management -struct LinkLibraryFeaturePropertySet +// LINK_LIBRARY feature attributes management +struct LinkLibraryFeatureAttributeSet { std::set LibraryTypes = { cmStateEnums::EXECUTABLE, cmStateEnums::STATIC_LIBRARY, @@ -212,84 +212,88 @@ struct LinkLibraryFeaturePropertySet }; std::set Override; - enum UnicityKind + enum DeduplicationKind { Default, Yes, No }; - UnicityKind Unicity = Default; + DeduplicationKind Deduplication = Default; }; -std::map - LinkLibraryFeatureProperties; -const LinkLibraryFeaturePropertySet& GetLinkLibraryFeatureProperties( +std::map + LinkLibraryFeatureAttributes; +const LinkLibraryFeatureAttributeSet& GetLinkLibraryFeatureAttributes( cmMakefile* makefile, std::string const& linkLanguage, const std::string& feature) { - auto it = LinkLibraryFeatureProperties.find(feature); - if (it != LinkLibraryFeatureProperties.end()) { + auto it = LinkLibraryFeatureAttributes.find(feature); + if (it != LinkLibraryFeatureAttributes.end()) { return it->second; } - auto featurePropertiesVariable = - cmStrCat("CMAKE_", linkLanguage, "_LINK_LIBRARY_", feature, "_PROPERTIES"); - auto featurePropertiesValues = - makefile->GetDefinition(featurePropertiesVariable); - if (featurePropertiesValues.IsEmpty()) { + auto featureAttributesVariable = + cmStrCat("CMAKE_", linkLanguage, "_LINK_LIBRARY_", feature, "_ATTRIBUTES"); + auto featureAttributesValues = + makefile->GetDefinition(featureAttributesVariable); + if (featureAttributesValues.IsEmpty()) { // try language agnostic definition - featurePropertiesVariable = - cmStrCat("CMAKE_LINK_LIBRARY_", feature, "_PROPERTIES"); - featurePropertiesValues = - makefile->GetDefinition(featurePropertiesVariable); + featureAttributesVariable = + cmStrCat("CMAKE_LINK_LIBRARY_", feature, "_ATTRIBUTES"); + featureAttributesValues = + makefile->GetDefinition(featureAttributesVariable); } - if (!featurePropertiesValues.IsEmpty()) { - LinkLibraryFeaturePropertySet featureProperties; + if (!featureAttributesValues.IsEmpty()) { + LinkLibraryFeatureAttributeSet featureAttributes; cmsys::RegularExpression processingOption{ - "^(LIBRARY_TYPE|UNICITY|OVERRIDE)=((STATIC|SHARED|MODULE|EXECUTABLE)(,(" + "^(LIBRARY_TYPE|DEDUPLICATION|OVERRIDE)=((STATIC|SHARED|MODULE|" + "EXECUTABLE)(,(" "STATIC|" "SHARED|MODULE|EXECUTABLE)" ")*|YES|NO|DEFAULT|[A-Za-z0-9_]+(,[A-Za-z0-9_]+)*)$" }; std::string errorMessage; - for (auto const& option : cmList{ featurePropertiesValues }) { + for (auto const& option : cmList{ featureAttributesValues }) { if (processingOption.find(option)) { if (processingOption.match(1) == "LIBRARY_TYPE") { - featureProperties.LibraryTypes.clear(); + featureAttributes.LibraryTypes.clear(); for (auto const& value : cmTokenize(processingOption.match(2), ","_s)) { if (value == "STATIC") { - featureProperties.LibraryTypes.emplace( + featureAttributes.LibraryTypes.emplace( cmStateEnums::STATIC_LIBRARY); } else if (value == "SHARED") { - featureProperties.LibraryTypes.emplace( + featureAttributes.LibraryTypes.emplace( cmStateEnums::SHARED_LIBRARY); } else if (value == "MODULE") { - featureProperties.LibraryTypes.emplace( + featureAttributes.LibraryTypes.emplace( cmStateEnums::MODULE_LIBRARY); } else if (value == "EXECUTABLE") { - featureProperties.LibraryTypes.emplace(cmStateEnums::EXECUTABLE); + featureAttributes.LibraryTypes.emplace(cmStateEnums::EXECUTABLE); } else { errorMessage += cmStrCat(" ", option, '\n'); break; } } // Always add UNKNOWN type - featureProperties.LibraryTypes.emplace( + featureAttributes.LibraryTypes.emplace( cmStateEnums::UNKNOWN_LIBRARY); - } else if (processingOption.match(1) == "UNICITY") { + } else if (processingOption.match(1) == "DEDUPLICATION") { if (processingOption.match(2) == "YES") { - featureProperties.Unicity = LinkLibraryFeaturePropertySet::Yes; + featureAttributes.Deduplication = + LinkLibraryFeatureAttributeSet::Yes; } else if (processingOption.match(2) == "NO") { - featureProperties.Unicity = LinkLibraryFeaturePropertySet::No; + featureAttributes.Deduplication = + LinkLibraryFeatureAttributeSet::No; } else if (processingOption.match(2) == "DEFAULT") { - featureProperties.Unicity = LinkLibraryFeaturePropertySet::Default; + featureAttributes.Deduplication = + LinkLibraryFeatureAttributeSet::Default; } else { errorMessage += cmStrCat(" ", option, '\n'); } } else if (processingOption.match(1) == "OVERRIDE") { - featureProperties.Override.clear(); + featureAttributes.Override.clear(); auto values = cmTokenize(processingOption.match(2), ","_s); - featureProperties.Override.insert(values.begin(), values.end()); + featureAttributes.Override.insert(values.begin(), values.end()); } } else { errorMessage += cmStrCat(" ", option, '\n'); @@ -298,14 +302,14 @@ const LinkLibraryFeaturePropertySet& GetLinkLibraryFeatureProperties( if (!errorMessage.empty()) { makefile->GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, - cmStrCat("Erroneous option(s) for '", featurePropertiesVariable, + cmStrCat("Erroneous option(s) for '", featureAttributesVariable, "':\n", errorMessage)); } - return LinkLibraryFeatureProperties.emplace(feature, featureProperties) + return LinkLibraryFeatureAttributes.emplace(feature, featureAttributes) .first->second; } - return LinkLibraryFeatureProperties - .emplace(feature, LinkLibraryFeaturePropertySet{}) + return LinkLibraryFeatureAttributes + .emplace(feature, LinkLibraryFeatureAttributeSet{}) .first->second; } @@ -512,14 +516,15 @@ private: bool IncludeEntry(LinkEntry const& entry) const { if (entry.Feature != cmComputeLinkDepends::LinkEntry::DEFAULT) { - auto const& featureProperties = GetLinkLibraryFeatureProperties( + auto const& featureAttributes = GetLinkLibraryFeatureAttributes( this->Target->Makefile, this->LinkLanguage, entry.Feature); if ((entry.Target == nullptr || - featureProperties.LibraryTypes.find(entry.Target->GetType()) != - featureProperties.LibraryTypes.end()) && - featureProperties.Unicity != - LinkLibraryFeaturePropertySet::Default) { - return featureProperties.Unicity == LinkLibraryFeaturePropertySet::No; + featureAttributes.LibraryTypes.find(entry.Target->GetType()) != + featureAttributes.LibraryTypes.end()) && + featureAttributes.Deduplication != + LinkLibraryFeatureAttributeSet::Default) { + return featureAttributes.Deduplication == + LinkLibraryFeatureAttributeSet::No; } } @@ -1124,27 +1129,29 @@ void cmComputeLinkDepends::AddLinkEntries(size_t depender_index, " library '", entry.Item.Value, "'."), this->Target->GetBacktrace()); } + // check if feature is applicable to this item + if (itemFeature != LinkEntry::DEFAULT && entry.Target != nullptr) { + auto const& featureAttributes = GetLinkLibraryFeatureAttributes( + this->Makefile, this->LinkLanguage, itemFeature); + if (featureAttributes.LibraryTypes.find(entry.Target->GetType()) == + featureAttributes.LibraryTypes.end()) { + supportedItem = false; + this->CMakeInstance->IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat("The feature '", itemFeature, + "', specified as part of a generator-expression " + "'$', will not be applied to the ", + cmState::GetTargetTypeName(entry.Target->GetType()), " '", + entry.Item.Value, "'."), + this->Target->GetBacktrace()); + } + } if (ale.second) { // current item not yet defined entry.Feature = itemFeature; - - if (itemFeature != LinkEntry::DEFAULT && entry.Target != nullptr) { - auto const& featureProperties = GetLinkLibraryFeatureProperties( - this->Makefile, this->LinkLanguage, itemFeature); - if (featureProperties.LibraryTypes.find(entry.Target->GetType()) == - featureProperties.LibraryTypes.end()) { - supportedItem = false; - entry.Feature = LinkEntry::DEFAULT; - this->CMakeInstance->IssueMessage( - MessageType::AUTHOR_WARNING, - cmStrCat("The feature '", itemFeature, - "', specified as part of a generator-expression " - "'$', will not be applied to the ", - cmState::GetTargetTypeName(entry.Target->GetType()), " '", - entry.Item.Value, "'."), - this->Target->GetBacktrace()); - } + if (!supportedItem) { + entry.Feature = LinkEntry::DEFAULT; } } @@ -1173,38 +1180,50 @@ void cmComputeLinkDepends::AddLinkEntries(size_t depender_index, if (entry.Feature != itemFeature) { bool incompatibleFeatures = true; // check if an override is possible - auto const& entryFeatureProperties = GetLinkLibraryFeatureProperties( + auto const& entryFeatureAttributes = GetLinkLibraryFeatureAttributes( this->Makefile, this->LinkLanguage, entry.Feature); - auto const& itemFeatureProperties = GetLinkLibraryFeatureProperties( + auto const& itemFeatureAttributes = GetLinkLibraryFeatureAttributes( this->Makefile, this->LinkLanguage, itemFeature); - if (entryFeatureProperties.Override.empty() && - !itemFeatureProperties.Override.empty() && - itemFeatureProperties.Override.find(entry.Feature) != - itemFeatureProperties.Override.end()) { - entry.Feature = itemFeature; - incompatibleFeatures = false; - } else if (!entryFeatureProperties.Override.empty() && - itemFeatureProperties.Override.empty() && - entryFeatureProperties.Override.find(itemFeature) != - entryFeatureProperties.Override.end()) { - incompatibleFeatures = false; - } - if (incompatibleFeatures) { - // incompatibles features occurred + if (itemFeatureAttributes.Override.find(entry.Feature) != + itemFeatureAttributes.Override.end() && + entryFeatureAttributes.Override.find(itemFeature) != + entryFeatureAttributes.Override.end()) { + // features override each other this->CMakeInstance->IssueMessage( MessageType::FATAL_ERROR, cmStrCat("Impossible to link target '", this->Target->GetName(), "' because the link item '", entry.Item.Value, - "', specified ", - (itemFeature == LinkEntry::DEFAULT - ? "without any feature or 'DEFAULT' feature" - : cmStrCat("with the feature '", itemFeature, '\'')), - ", has already occurred ", - (entry.Feature == LinkEntry::DEFAULT - ? "without any feature or 'DEFAULT' feature" - : cmStrCat("with the feature '", entry.Feature, '\'')), - ", which is not allowed."), + "' is specified with the features '", itemFeature, + "' and '", entry.Feature, "'", + ", and both have an 'OVERRIDE' attribute that overrides " + "the other. Such cycles are not allowed."), this->Target->GetBacktrace()); + } else { + if (itemFeatureAttributes.Override.find(entry.Feature) != + itemFeatureAttributes.Override.end()) { + entry.Feature = itemFeature; + incompatibleFeatures = false; + } else if (entryFeatureAttributes.Override.find(itemFeature) != + entryFeatureAttributes.Override.end()) { + incompatibleFeatures = false; + } + if (incompatibleFeatures) { + // incompatibles features occurred + this->CMakeInstance->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat( + "Impossible to link target '", this->Target->GetName(), + "' because the link item '", entry.Item.Value, "', specified ", + (itemFeature == LinkEntry::DEFAULT + ? "without any feature or 'DEFAULT' feature" + : cmStrCat("with the feature '", itemFeature, '\'')), + ", has already occurred ", + (entry.Feature == LinkEntry::DEFAULT + ? "without any feature or 'DEFAULT' feature" + : cmStrCat("with the feature '", entry.Feature, '\'')), + ", which is not allowed."), + this->Target->GetBacktrace()); + } } } } diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake index a061127109..fdad38de97 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake @@ -36,9 +36,12 @@ run_cmake(override-features3) run_cmake(override-features4) run_cmake(override-features5) -# testing feature properties specification -run_cmake(bad-feature-properties1) -run_cmake(bad-feature-properties2) -run_cmake(bad-feature-properties3) -run_cmake(bad-feature-properties4) -run_cmake(bad-feature-properties5) +# testing feature attributes specification +run_cmake(bad-feature-attributes1) +run_cmake(bad-feature-attributes2) +run_cmake(bad-feature-attributes3) +run_cmake(bad-feature-attributes4) +run_cmake(bad-feature-attributes5) +run_cmake(unsupported-library_type) +run_cmake(cyclic-override) +run_cmake(multiple-override) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-result.txt similarity index 100% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-result.txt rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-result.txt diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-stderr.txt new file mode 100644 index 0000000000..5923654395 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: + Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_ATTRIBUTES': + + BAD_ATTRIBUTE=XXX diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1.cmake similarity index 80% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5.cmake rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1.cmake index 06efe7ed49..dc743a81ad 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1.cmake @@ -2,7 +2,7 @@ enable_language(C) set(CMAKE_LINK_LIBRARY_USING_feature "") set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES UNICITY=YES,NO) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES BAD_ATTRIBUTE=XXX) add_library(dep SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-result.txt similarity index 100% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-result.txt rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-result.txt diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-stderr.txt new file mode 100644 index 0000000000..5923654395 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: + Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_ATTRIBUTES': + + BAD_ATTRIBUTE=XXX diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2.cmake similarity index 71% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2.cmake rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2.cmake index dea98d29ba..3012308eac 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2.cmake @@ -2,7 +2,7 @@ enable_language(C) set(CMAKE_LINK_LIBRARY_USING_feature "") set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES LIBRARY_TYPE=STATIC BAD_PROPERTY=XXX UNICITY=YES) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES LIBRARY_TYPE=STATIC BAD_ATTRIBUTE=XXX DEDUPLICATION=YES) add_library(dep SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-result.txt similarity index 100% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-result.txt rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-result.txt diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-stderr.txt new file mode 100644 index 0000000000..a0b0a75d1a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: + Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_ATTRIBUTES': + + LIBRARY_TYPE=STATIC,BAD_TYPE diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3.cmake similarity index 80% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3.cmake rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3.cmake index 0a535dba4d..8887934cf9 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3.cmake @@ -2,7 +2,7 @@ enable_language(C) set(CMAKE_LINK_LIBRARY_USING_feature "") set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES LIBRARY_TYPE=STATIC,BAD_TYPE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES LIBRARY_TYPE=STATIC,BAD_TYPE) add_library(dep SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-result.txt similarity index 100% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-result.txt rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-result.txt diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-stderr.txt new file mode 100644 index 0000000000..a0b0a75d1a --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: + Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_ATTRIBUTES': + + LIBRARY_TYPE=STATIC,BAD_TYPE diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4.cmake new file mode 100644 index 0000000000..3edf2681c4 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature "") +set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES DEDUPLICATION=YES LIBRARY_TYPE=STATIC,BAD_TYPE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-result.txt similarity index 100% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-result.txt rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-result.txt diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-stderr.txt new file mode 100644 index 0000000000..34c11433ac --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: + Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_ATTRIBUTES': + + DEDUPLICATION=YES,NO diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5.cmake similarity index 75% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4.cmake rename to Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5.cmake index c106653ccf..5af99cd5b7 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5.cmake @@ -2,7 +2,7 @@ enable_language(C) set(CMAKE_LINK_LIBRARY_USING_feature "") set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES UNICITY=YES LIBRARY_TYPE=STATIC,BAD_TYPE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES DEDUPLICATION=YES,NO) add_library(dep SHARED empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-stderr.txt deleted file mode 100644 index ac07251248..0000000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error: - Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_PROPERTIES': - - BAD_PROPERTY=XXX diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-stderr.txt deleted file mode 100644 index ac07251248..0000000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error: - Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_PROPERTIES': - - BAD_PROPERTY=XXX diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-stderr.txt deleted file mode 100644 index 29f5f6621c..0000000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error: - Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_PROPERTIES': - - LIBRARY_TYPE=STATIC,BAD_TYPE diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-stderr.txt deleted file mode 100644 index 29f5f6621c..0000000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error: - Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_PROPERTIES': - - LIBRARY_TYPE=STATIC,BAD_TYPE diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-stderr.txt deleted file mode 100644 index 3e577821bf..0000000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-stderr.txt +++ /dev/null @@ -1,4 +0,0 @@ -CMake Error: - Erroneous option\(s\) for 'CMAKE_LINK_LIBRARY_feature_PROPERTIES': - - UNICITY=YES,NO diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-stderr.txt new file mode 100644 index 0000000000..4476271343 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at cyclic-override.cmake:[0-9]+ \(add_library\): + Impossible to link target 'lib' because the link item 'dep' is specified + with the features 'feature2' and 'feature1', and both have an 'OVERRIDE' + attribute that overrides the other. Such cycles are not allowed. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override.cmake new file mode 100644 index 0000000000..69b670bf58 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature1 "") +set(CMAKE_LINK_LIBRARY_USING_feature1_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature1_ATTRIBUTES OVERRIDE=feature2) + +set(CMAKE_LINK_LIBRARY_USING_feature2 "") +set(CMAKE_LINK_LIBRARY_USING_feature2_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature2_ATTRIBUTES OVERRIDE=feature1) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$" "$") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake index 675b87dc65..b5e52b51dd 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake @@ -2,7 +2,7 @@ enable_language(C) set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE) set(CMAKE_C_LINK_LIBRARY_USING_feat "") -set(CMAKE_C_LINK_LIBRARY_feat_PROPERTIES "LIBRARY_TYPE=STATIC") +set(CMAKE_C_LINK_LIBRARY_feat_ATTRIBUTES "LIBRARY_TYPE=STATIC") add_library(dep OBJECT empty.c) diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-override.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-override.cmake new file mode 100644 index 0000000000..97d85d07e9 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-override.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature1 "") +set(CMAKE_LINK_LIBRARY_USING_feature1_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature1_ATTRIBUTES OVERRIDE=feature2) + +set(CMAKE_LINK_LIBRARY_USING_feature2 "") +set(CMAKE_LINK_LIBRARY_USING_feature2_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature2_ATTRIBUTES OVERRIDE=feature3) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$" "$") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type-stderr.txt new file mode 100644 index 0000000000..a95648b1b7 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type-stderr.txt @@ -0,0 +1,6 @@ +CMake Warning \(dev\) at unsupported-library_type.cmake:[0-9]+ \(add_library\): + The feature 'feature', specified as part of a generator-expression + '\$', will not be applied to the SHARED_LIBRARY 'dep'. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type.cmake similarity index 80% rename from Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1.cmake rename to Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type.cmake index e5790a8000..29aba56567 100644 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1.cmake +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type.cmake @@ -2,7 +2,7 @@ enable_language(C) set(CMAKE_LINK_LIBRARY_USING_feature "") set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES BAD_PROPERTY=XXX) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES LIBRARY_TYPE=STATIC) add_library(dep SHARED empty.c)