From 576567f028f2366dda84fe3deb1d6cca62cb9890 Mon Sep 17 00:00:00 2001 From: Marc Chevrier <marc.chevrier@gmail.com> Date: Sun, 16 Jun 2024 16:02:30 +0200 Subject: Link feature attributes: stabilization * enhance OVERRIDE handling * Update wording --- Help/manual/cmake-variables.7.rst | 4 +- Help/release/3.30.rst | 6 +- .../CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst | 10 ++ .../CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst | 10 -- .../CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst | 116 +++++++++++++ .../CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst | 115 ------------ Help/variable/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 +++++++++++---------- .../RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake | 15 +- .../bad-feature-attributes1-result.txt | 1 + .../bad-feature-attributes1-stderr.txt | 4 + .../bad-feature-attributes1.cmake | 10 ++ .../bad-feature-attributes2-result.txt | 1 + .../bad-feature-attributes2-stderr.txt | 4 + .../bad-feature-attributes2.cmake | 10 ++ .../bad-feature-attributes3-result.txt | 1 + .../bad-feature-attributes3-stderr.txt | 4 + .../bad-feature-attributes3.cmake | 10 ++ .../bad-feature-attributes4-result.txt | 1 + .../bad-feature-attributes4-stderr.txt | 4 + .../bad-feature-attributes4.cmake | 10 ++ .../bad-feature-attributes5-result.txt | 1 + .../bad-feature-attributes5-stderr.txt | 4 + .../bad-feature-attributes5.cmake | 10 ++ .../bad-feature-properties1-result.txt | 1 - .../bad-feature-properties1-stderr.txt | 4 - .../bad-feature-properties1.cmake | 10 -- .../bad-feature-properties2-result.txt | 1 - .../bad-feature-properties2-stderr.txt | 4 - .../bad-feature-properties2.cmake | 10 -- .../bad-feature-properties3-result.txt | 1 - .../bad-feature-properties3-stderr.txt | 4 - .../bad-feature-properties3.cmake | 10 -- .../bad-feature-properties4-result.txt | 1 - .../bad-feature-properties4-stderr.txt | 4 - .../bad-feature-properties4.cmake | 10 -- .../bad-feature-properties5-result.txt | 1 - .../bad-feature-properties5-stderr.txt | 4 - .../bad-feature-properties5.cmake | 10 -- .../GenEx-LINK_LIBRARY/cyclic-override-result.txt | 1 + .../GenEx-LINK_LIBRARY/cyclic-override-stderr.txt | 6 + .../GenEx-LINK_LIBRARY/cyclic-override.cmake | 14 ++ .../GenEx-LINK_LIBRARY/library-ignored.cmake | 2 +- .../GenEx-LINK_LIBRARY/multiple-override.cmake | 14 ++ .../unsupported-library_type-stderr.txt | 6 + .../unsupported-library_type.cmake | 10 ++ 58 files changed, 394 insertions(+), 320 deletions(-) create mode 100644 Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst delete mode 100644 Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst create mode 100644 Help/variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst delete mode 100644 Help/variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-result.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-stderr.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1.cmake create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-result.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-stderr.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2.cmake create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-result.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-stderr.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3.cmake create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-result.txt 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 create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-result.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-stderr.txt create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5.cmake delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-result.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1.cmake delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-result.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2.cmake delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-result.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3.cmake delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-result.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4.cmake delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-result.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-stderr.txt delete mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5.cmake 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 create mode 100644 Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type.cmake diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 6400a93..1abdd62 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 dc0d573..ce489f6 100644 --- a/Help/release/3.30.rst +++ b/Help/release/3.30.rst @@ -148,9 +148,9 @@ Generator Expressions associated :variable:`CMAKE_<LANG>_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_<FEATURE>_PROPERTIES` or - :variable:`CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_PROPERTIES` variables. + gained the ability to have attributes that describe their behavior by + specifying the :variable:`CMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` or + :variable:`CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` variables. * The :genex:`QUOTE` generator expression was added to evaluate to ``"``. diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst new file mode 100644 index 0000000..8769d60 --- /dev/null +++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst @@ -0,0 +1,10 @@ +CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_ATTRIBUTES +---------------------------------------------- + +.. versionadded:: 3.30 + +This variable defines the semantics of the specified link library ``<FEATURE>`` +when linking with the link language ``<LANG>``. It takes precedence over +:variable:`CMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` if that variable is also +defined for the same ``<FEATURE>``, but otherwise has similar effects. +See :variable:`CMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` for further details. diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst deleted file mode 100644 index 10f4fda..0000000 --- a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FEATURE_PROPERTIES.rst +++ /dev/null @@ -1,10 +0,0 @@ -CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_PROPERTIES ----------------------------------------------- - -.. versionadded:: 3.30 - -This variable defines the semantics of the specified link library ``<FEATURE>`` -when linking with the link language ``<LANG>``. It takes precedence over -:variable:`CMAKE_LINK_LIBRARY_<FEATURE>_PROPERTIES` if that variable is also -defined for the same ``<FEATURE>``, but otherwise has similar effects. -See :variable:`CMAKE_LINK_LIBRARY_<FEATURE>_PROPERTIES` for further details. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst b/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst new file mode 100644 index 0000000..c9966ff --- /dev/null +++ b/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_ATTRIBUTES.rst @@ -0,0 +1,116 @@ +CMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES +--------------------------------------- + +.. versionadded:: 3.30 + +This variable defines the behavior of the specified link library +``<FEATURE>``. It specifies how the ``<FEATURE>`` interacts with other +features, when the ``<FEATURE>`` should be applied, and aspects of how the +``<FEATURE>`` should be handled when CMake assembles the final linker +command line (e.g. de-duplication). + +The syntax of the linker flags for the ``<FEATURE>`` are controlled by the +:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` and +:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variables. +The :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` and +:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` variables +control whether the ``<FEATURE>`` is available at all. + +When linking for a particular language ``<LANG>``, +``CMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES`` is ignored if the +:variable:`CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` variable is also +defined for the same ``<FEATURE>``. + +The value of ``CMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES`` and +:variable:`CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` at the end of the +directory scope in which a target is defined is what matters. + +Feature Attributes Definition +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A feature attributes definition is a +:ref:`semicolon-separated list <CMake Language Lists>` of +``attribute=value(s)`` items. If an attribute has multiple values, those values +must be comma-separated. + +The following attributes are supported: + +``LIBRARY_TYPE=<library-type-list>`` + Specify the library types supported by the feature. Supported values are: + ``STATIC``, ``SHARED``, ``MODULE``, and ``EXECUTABLE``. + + 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 + developer warning and the feature will be ignored. + +``OVERRIDE=<feature-list>`` + Specify which features this one replaces in the event of a conflict. + This override mechanism is superseded by + :prop_tgt:`LINK_LIBRARY_OVERRIDE` or + :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target property definitions, + if defined. + + If this attribute is not specified, the default is an empty list. + +``DEDUPLICATION=YES|NO|DEFAULT`` + Specify the de-duplication strategy for a library using this feature. + + ``YES`` + The library is always de-duplicated. The default strategy CMake would + normally apply is ignored. + + ``NO`` + The library is never de-duplicated. The default strategy CMake would + normally apply is ignored. + + ``DEFAULT`` + Let CMake determine a de-duplication strategy automatically. + + If this attribute is not specified, ``DEFAULT`` will be used. + +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 attributes: + +.. code-block:: cmake + + set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_ATTRIBUTES + LIBRARY_TYPE=STATIC + OVERRIDE=DEFAULT + DEDUPLICATION=YES + ) + +``LIBRARY_TYPE=STATIC`` + This feature is only meaningful for static libraries. +``OVERRIDE=DEFAULT`` + The ``DEFAULT`` feature will be overridden by the ``WHOLE_ARCHIVE`` feature + because they are compatible and enhance the user's experience: standard + library specification and ``$<LINK_LIBRARY:WHOLE_ARCHIVE>`` can be used + freely. +``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. + +The ``WHOLE_ARCHIVE`` feature can be used like so: + +.. code-block:: cmake + + add_library(A STATIC ...) + add_library(B STATIC ...) + + target_link_libraries(B PUBLIC A) + target_link_libraries(A PUBLIC B) + + add_library(global SHARED ...) + target_link_libraries(global PRIVATE $<LINK_LIBRARY:WHOLE_ARCHIVE,A>) + +The resulting link command will only have one instance of the ``A`` library +specified, and the linker flags will ensure that all symbols are loaded from +the ``A`` library. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst b/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst deleted file mode 100644 index e30c30a..0000000 --- a/Help/variable/CMAKE_LINK_LIBRARY_FEATURE_PROPERTIES.rst +++ /dev/null @@ -1,115 +0,0 @@ -CMAKE_LINK_LIBRARY_<FEATURE>_PROPERTIES ---------------------------------------- - -.. versionadded:: 3.30 - -This variable defines the behavior of the specified link library -``<FEATURE>``. It specifies how the ``<FEATURE>`` interacts with other -features, when the ``<FEATURE>`` should be applied, and aspects of how the -``<FEATURE>`` should be handled when CMake assembles the final linker -command line (e.g. de-duplication). - -The syntax of the linker flags for the ``<FEATURE>`` are controlled by the -:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` and -:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variables. -The :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` and -:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` variables -control whether the ``<FEATURE>`` is available at all. - -When linking for a particular language ``<LANG>``, -``CMAKE_LINK_LIBRARY_<FEATURE>_PROPERTIES`` is ignored if the -:variable:`CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_PROPERTIES` variable is also -defined for the same ``<FEATURE>``. - -The value of ``CMAKE_LINK_LIBRARY_<FEATURE>_PROPERTIES`` and -:variable:`CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_PROPERTIES` at the end of the -directory scope in which a target is defined is what matters. - -Feature Properties Definition -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -A feature properties definition is a -:ref:`semicolon-separated list <CMake Language Lists>` of ``property=value(s)`` -items. If a property has multiple values, those values must be comma-separated. - -The following properties are supported: - -``LIBRARY_TYPE=<library-type-list>`` - 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 - ``LIBRARY_TYPE=STATIC,SHARED,MODULE,EXECUTABLE``. - - If the feature is used with an unsupported library type, CMake will emit a - developer warning and the feature will be ignored. - -``OVERRIDE=<feature-list>`` - Specify which features this one replaces in the event of a conflict. - This override mechanism is superseded by - :prop_tgt:`LINK_LIBRARY_OVERRIDE` or - :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target property definitions, - if defined. - - If this property is not specified, the default is an empty list. - -``UNICITY=YES|NO|DEFAULT`` - Specify the de-duplication strategy for a library using this feature. - - ``YES`` - The library is always de-duplicated. The default strategy CMake would - normally apply is ignored. - - ``NO`` - The library is never de-duplicated. The default strategy CMake would - normally apply is ignored. - - ``DEFAULT`` - Let CMake determine a de-duplication strategy automatically. - - If this property is not specified, ``DEFAULT`` will be used. - -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: - -.. code-block:: cmake - - set(CMAKE_LINK_LIBRARY_WHOLE_ARCHIVE_PROPERTIES - LIBRARY_TYPE=STATIC - OVERRIDE=DEFAULT - UNICITY=YES - ) - -``LIBRARY_TYPE=STATIC`` - This feature is only meaningful for static libraries. -``OVERRIDE=DEFAULT`` - The ``DEFAULT`` feature will be overridden by the ``WHOLE_ARCHIVE`` feature - because they are compatible and enhance the user's experience: standard - library specification and ``$<LINK_LIBRARY:WHOLE_ARCHIVE>`` can be used - freely. -``UNICITY=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. - -The ``WHOLE_ARCHIVE`` feature can be used like so: - -.. code-block:: cmake - - add_library(A STATIC ...) - add_library(B STATIC ...) - - target_link_libraries(B PUBLIC A) - target_link_libraries(A PUBLIC B) - - add_library(global SHARED ...) - target_link_libraries(global PRIVATE $<LINK_LIBRARY:WHOLE_ARCHIVE,A>) - -The resulting link command will only have one instance of the ``A`` library -specified, and the linker flags will ensure that all symbols are loaded from -the ``A`` library. diff --git a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt index 59a0d02..f5c19e0 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_<LANG>_LINK_LIBRARY_<FEATURE>_PROPERTIES` and -:variable:`CMAKE_LINK_LIBRARY_<FEATURE>_PROPERTIES` variables. +:variable:`CMAKE_<LANG>_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` and +:variable:`CMAKE_LINK_LIBRARY_<FEATURE>_ATTRIBUTES` variables. Feature Definitions ^^^^^^^^^^^^^^^^^^^ diff --git a/Modules/Platform/Apple-Clang.cmake b/Modules/Platform/Apple-Clang.cmake index e0b6cd6..40fed44 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 <LIBRARY>") 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 20b18ad..bc4147e 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 <LIBRARY>") 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 5e2ba41..01b5f91 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 1272baf..b26912d 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -114,37 +114,37 @@ set(CMAKE_CREATE_TEXT_STUBS "<CMAKE_TAPI> stubify -isysroot <CMAKE_OSX_SYSROOT> # Defines LINK_LIBRARY features for frameworks set(CMAKE_LINK_LIBRARY_USING_FRAMEWORK "LINKER:-framework,<LIBRARY>") 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,<LIBRARY>") 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,<LIBRARY>") 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,<LIBRARY>") 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,<LIBRARY>}NAME{LINKER:-needed-l<LIBRARY>}") 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,<LIBRARY>}NAME{LINKER:-reexport-l<LIBRARY>}") 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,<LIBRARY>}NAME{LINKER:-weak-l<LIBRARY>}") 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,<LIB_ITEM>") 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 7d5f951..891422e 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 fba6ab8..b9801ee 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 af368cd..892d55b 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 73205c1..25e95e6 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 8c9b79c..e3725cb 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:<LIBRARY>") 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 d2b25c6..1a4159b 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 691c7ce..517d959 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:<LIBRARY>") 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 3a400e5..5809379 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:<LIBRARY>") 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 2f24ad7..1937674 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<cmStateEnums::TargetType> LibraryTypes = { cmStateEnums::EXECUTABLE, cmStateEnums::STATIC_LIBRARY, @@ -212,84 +212,88 @@ struct LinkLibraryFeaturePropertySet }; std::set<std::string> Override; - enum UnicityKind + enum DeduplicationKind { Default, Yes, No }; - UnicityKind Unicity = Default; + DeduplicationKind Deduplication = Default; }; -std::map<std::string, LinkLibraryFeaturePropertySet> - LinkLibraryFeatureProperties; -const LinkLibraryFeaturePropertySet& GetLinkLibraryFeatureProperties( +std::map<std::string, LinkLibraryFeatureAttributeSet> + 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 " + "'$<LINK_LIBRARY:", + itemFeature, ">', 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 " - "'$<LINK_LIBRARY:", - itemFeature, ">', 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 a061127..fdad38d 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-attributes1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1-result.txt @@ -0,0 +1 @@ +1 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 0000000..5923654 --- /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-attributes1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1.cmake new file mode 100644 index 0000000..dc743a8 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes1.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES BAD_ATTRIBUTE=XXX) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2-result.txt @@ -0,0 +1 @@ +1 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 0000000..5923654 --- /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-attributes2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2.cmake new file mode 100644 index 0000000..3012308 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes2.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES LIBRARY_TYPE=STATIC BAD_ATTRIBUTE=XXX DEDUPLICATION=YES) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3-result.txt @@ -0,0 +1 @@ +1 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 0000000..a0b0a75 --- /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-attributes3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3.cmake new file mode 100644 index 0000000..8887934 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes3.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES LIBRARY_TYPE=STATIC,BAD_TYPE) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes4-result.txt @@ -0,0 +1 @@ +1 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 0000000..a0b0a75 --- /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 0000000..3edf268 --- /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 "<LIBRARY>") +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 "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5-result.txt @@ -0,0 +1 @@ +1 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 0000000..34c1143 --- /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-attributes5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5.cmake new file mode 100644 index 0000000..5af99cd --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-attributes5.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES DEDUPLICATION=YES,NO) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 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 ac07251..0000000 --- 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-properties1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1.cmake deleted file mode 100644 index e5790a8..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties1.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(C) - -set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") -set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES BAD_PROPERTY=XXX) - -add_library(dep SHARED empty.c) - -add_library(lib SHARED empty.c) -target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 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 ac07251..0000000 --- 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-properties2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2.cmake deleted file mode 100644 index dea98d2..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties2.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(C) - -set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") -set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES LIBRARY_TYPE=STATIC BAD_PROPERTY=XXX UNICITY=YES) - -add_library(dep SHARED empty.c) - -add_library(lib SHARED empty.c) -target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 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 29f5f66..0000000 --- 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-properties3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3.cmake deleted file mode 100644 index 0a535db..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties3.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(C) - -set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") -set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES LIBRARY_TYPE=STATIC,BAD_TYPE) - -add_library(dep SHARED empty.c) - -add_library(lib SHARED empty.c) -target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 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 29f5f66..0000000 --- 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-properties4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4.cmake deleted file mode 100644 index c106653..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties4.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(C) - -set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") -set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES UNICITY=YES LIBRARY_TYPE=STATIC,BAD_TYPE) - -add_library(dep SHARED empty.c) - -add_library(lib SHARED empty.c) -target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-result.txt deleted file mode 100644 index d00491f..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 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 3e57782..0000000 --- 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/bad-feature-properties5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5.cmake deleted file mode 100644 index 06efe7e..0000000 --- a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature-properties5.cmake +++ /dev/null @@ -1,10 +0,0 @@ -enable_language(C) - -set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") -set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) -set(CMAKE_LINK_LIBRARY_feature_PROPERTIES UNICITY=YES,NO) - -add_library(dep SHARED empty.c) - -add_library(lib SHARED empty.c) -target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") 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 0000000..d00491f --- /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 0000000..4476271 --- /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 0000000..69b670b --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/cyclic-override.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature1 "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feature1_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature1_ATTRIBUTES OVERRIDE=feature2) + +set(CMAKE_LINK_LIBRARY_USING_feature2 "<LIBRARY>") +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 "$<LINK_LIBRARY:feature1,dep>" "$<LINK_LIBRARY:feature2,dep>") diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake index 675b87d..b5e52b5 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 "<LIBRARY>") -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 0000000..97d85d0 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/multiple-override.cmake @@ -0,0 +1,14 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature1 "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feature1_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature1_ATTRIBUTES OVERRIDE=feature2) + +set(CMAKE_LINK_LIBRARY_USING_feature2 "<LIBRARY>") +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 "$<LINK_LIBRARY:feature1,dep>" "$<LINK_LIBRARY:feature2,dep>") 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 0000000..a95648b --- /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 + '\$<LINK_LIBRARY:feature>', 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/unsupported-library_type.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type.cmake new file mode 100644 index 0000000..29aba56 --- /dev/null +++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/unsupported-library_type.cmake @@ -0,0 +1,10 @@ +enable_language(C) + +set(CMAKE_LINK_LIBRARY_USING_feature "<LIBRARY>") +set(CMAKE_LINK_LIBRARY_USING_feature_SUPPORTED TRUE) +set(CMAKE_LINK_LIBRARY_feature_ATTRIBUTES LIBRARY_TYPE=STATIC) + +add_library(dep SHARED empty.c) + +add_library(lib SHARED empty.c) +target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feature,dep>") -- cgit v0.12