genex-LINK_LIBRARY: rename configuration variables

To be more consistent between genex and variables as well as
the forecomming LINK_GROUP genex, rename variable *_LINK_USING_<FEATURE>*
in *_LINK_LIBRARY_USING_<FEATURE>*
This commit is contained in:
Marc Chevrier
2022-02-16 18:34:28 +01:00
parent 1e495fdab9
commit 397ee55cd6
47 changed files with 216 additions and 211 deletions

View File

@@ -1,5 +1,5 @@
CMAKE_<LANG>_LINK_USING_<FEATURE>
---------------------------------
CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>
-----------------------------------------
.. versionadded:: 3.24
@@ -12,11 +12,11 @@ using :genex:`LINK_LIBRARY` generator expression.
Feature names defined in all uppercase are reserved to CMake.
See also the associated variable
:variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>_SUPPORTED` and
:variable:`CMAKE_LINK_USING_<FEATURE>` variable for the definition of features
independent from the link language.
:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` and
:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variable for the definition of
features independent from the link language.
.. include:: CMAKE_LINK_USING_FEATURE.txt
.. include:: CMAKE_LINK_LIBRARY_USING_FEATURE.txt
Predefined Features
^^^^^^^^^^^^^^^^^^^

View File

@@ -0,0 +1,13 @@
CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED
---------------------------------------------------
.. versionadded:: 3.24
Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>`, is supported for the
linker language ``<LANG>``.
.. note::
This variable is evaluated before the more generic variable
:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED`.

View File

@@ -1,13 +0,0 @@
CMAKE_<LANG>_LINK_USING_<FEATURE>_SUPPORTED
-------------------------------------------
.. versionadded:: 3.24
Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
:variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>`, is supported for the linker
language ``<LANG>``.
.. note::
This variable is evaluated before the more generic variable
:variable:`CMAKE_LINK_USING_<FEATURE>_SUPPORTED`.

View File

@@ -1,5 +1,5 @@
CMAKE_LINK_USING_<FEATURE>
--------------------------
CMAKE_LINK_LIBRARY_USING_<FEATURE>
----------------------------------
.. versionadded:: 3.24
@@ -12,15 +12,16 @@ using :genex:`LINK_LIBRARY` generator expression.
Feature names defined in all uppercase are reserved to CMake.
See also the associated variable
:variable:`CMAKE_LINK_USING_<FEATURE>_SUPPORTED` and
:variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>` variable for the definition of
features dependent from the link language.
:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` and
:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` variable for the
definition of features dependent from the link language.
This variable will be used by :genex:`LINK_LIBRARY` generator expression if,
for the linker language, the variable
:variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>_SUPPORTED` is false or not set.
:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is false or not
set.
.. include:: CMAKE_LINK_USING_FEATURE.txt
.. include:: CMAKE_LINK_LIBRARY_USING_FEATURE.txt
Predefined Features
^^^^^^^^^^^^^^^^^^^

View File

@@ -46,27 +46,27 @@ is offered by various environments but with a specific syntax:
.. code-block:: cmake
set(CMAKE_C_LINK_USING_whole_archive_SUPPORTED TRUE)
set(CMAKE_C_LINK_LIBRARY_USING_whole_archive_SUPPORTED TRUE)
if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_C_LINK_USING_whole_archive "-force_load <LIB_ITEM>")
set(CMAKE_C_LINK_LIBRARY_USING_whole_archive "-force_load <LIB_ITEM>")
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU"
AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_C_LINK_USING_whole_archive "LINKER:--push-state,--whole-archive"
"<LINK_ITEM>"
"LINKER:--pop-state")
set(CMAKE_C_LINK_LIBRARY_USING_whole_archive "LINKER:--push-state,--whole-archive"
"<LINK_ITEM>"
"LINKER:--pop-state")
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
set(CMAKE_C_LINK_USING_whole_archive "/WHOLEARCHIVE:<LIBRARY>")
set(CMAKE_C_LINK_LIBRARY_USING_whole_archive "/WHOLEARCHIVE:<LIBRARY>")
else()
# feature not yet supported for the other environments
set(CMAKE_C_LINK_USING_whole_archive_SUPPORTED FALSE)
set(CMAKE_C_LINK_LIBRARY_USING_whole_archive_SUPPORTED FALSE)
endif()
add_library(lib1 STATIC ...)
add_library(lib2 SHARED ...)
if(CMAKE_C_LINK_USING_whole_archive_SUPPORTED)
if(CMAKE_C_LINK_LIBRARY_USING_whole_archive_SUPPORTED)
target_link_libraries(lib2 PRIVATE
$<LINK_LIBRARY:whole_archive,lib1,$<IF:$<LINK_LANG_AND_ID:C,Clang>,libexternal.a,external>>)
"$<LINK_LIBRARY:whole_archive,lib1,$<IF:$<LINK_LANG_AND_ID:C,Clang>,libexternal.a,external>>")
else()
target_link_libraries(lib2 PRIVATE lib1 external)
endif()
@@ -95,14 +95,15 @@ library specified by path and by name. This constraint by be solved by using
.. code-block:: cmake
if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_LINK_USING_weak_library "PATH{-weak_library <LIBRARY>}NAME{LINKER:-weak-l<LIB_ITEM>}")
set(CMAKE_LINK_USING_weak_library_SUPPORTED TRUE)
set(CMAKE_LINK_LIBRARY_USING_weak_library
"PATH{-weak_library <LIBRARY>}NAME{LINKER:-weak-l<LIB_ITEM>}")
set(CMAKE_LINK_LIBRARY_USING_weak_library_SUPPORTED TRUE)
endif()
add_library(lib SHARED ...)
add_executable(main ...)
if(CMAKE_LINK_USING_weak_library_SUPPORTED)
target_link_libraries(main PRIVATE $<LINK_LIBRARY:weak_library,lib,external>)
if(CMAKE_LINK_LIBRARY_USING_weak_library_SUPPORTED)
target_link_libraries(main PRIVATE "$<LINK_LIBRARY:weak_library,lib,external>")
else()
target_link_libraries(main PRIVATE lib external)
endif()

View File

@@ -0,0 +1,14 @@
CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED
--------------------------------------------
.. versionadded:: 3.24
Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>`, is supported regardless the
linker language.
.. note::
This variable is evaluated if, and only if, the variable
:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` evaluates to
``FALSE``.

View File

@@ -1,14 +0,0 @@
CMAKE_LINK_USING_<FEATURE>_SUPPORTED
------------------------------------
.. versionadded:: 3.24
Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
:variable:`CMAKE_LINK_USING_<FEATURE>`, is supported regardless the linker
language.
.. note::
This variable is evaluated if, and only if, the variable
:variable:`CMAKE_<LANG>_LINK_USING_<FEATURE>_SUPPORTED` evaluates to
``FALSE``.

View File

@@ -23,9 +23,11 @@ compatible with it.
linker option ``-weak_framework``).
Features for framework linking have a special handling in ``CMake``: the
framework can be specified as a ``CMake`` framework target or file path. In
the later case, if the path includes a directory part, this one will be
specified as framework search path at link step.
framework can be specified as a ``CMake`` framework target or file path. In the
first case, the target must have the :prop_tgt:`FRAMEWORK` target property set
as ``TRUE`` to enable framework handling. In the later case, if the path
includes a directory part, this one will be specified as framework search path
at link step.
.. code-block:: cmake