From dfc8bd6196052006a6da9ecd167eec5df3664cfe Mon Sep 17 00:00:00 2001 From: YL Wang <121748352+code4yonglei@users.noreply.github.com> Date: Tue, 10 Sep 2024 11:49:43 +0200 Subject: [PATCH] switch between properties and visibility levels --- content/targets.rst | 70 +++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/content/targets.rst b/content/targets.rst index b0907ce..a7abfd9 100644 --- a/content/targets.rst +++ b/content/targets.rst @@ -70,32 +70,6 @@ There are additional commands in the ``target_*`` family: -Properties ----------- - - -CMake lets you set properties at many different levels of visibility across the project: - -- **Global scope**. These are equivalent to variables set in the root ``CMakeLists.txt``. Their use is, however, more powerful as they can be set from *any* leaf ``CMakeLists.txt``. -- **Directory scope**. These are equivalent to variables set in a given leaf ``CMakeLists.txt``. -- **Target**. These are the properties set on targets that we discussed above. -- **Test**. -- **Source files**. For example, compiler flags. -- **Cache entries**. -- **Installed files**. - - -For a complete list of properties known to CMake: - -.. code-block:: bash - - $ cmake --help-properties | less - - -You can get the current value of any property with ``get_property`` and set the value of any property with ``set_property``. - - - Visibility levels ----------------- @@ -161,13 +135,41 @@ Why it is robust to use targets and properties than using variables? Given a tar When working out which visibility settings to use for the properties of your targets you can refer to the following table: - ============== ================ ============ - Who needs? Others - -------------- ----------------------------- - Target **YES** **NO** - ============== ================ ============ - **YES** ``PUBLIC`` ``PRIVATE`` - **NO** ``INTERFACE`` N/A - ============== ================ ============ + ============== ================ ============ + Who needs? Others + -------------- ----------------------------- + Target **YES** **NO** + ============== ================ ============ + **YES** ``PUBLIC`` ``PRIVATE`` + **NO** ``INTERFACE`` N/A + ============== ================ ============ + + + +Properties +---------- + + +CMake lets you set properties at many different levels of visibility across the project: + +- **Global scope**. These are equivalent to variables set in the root ``CMakeLists.txt``. Their use is, however, more powerful as they can be set from *any* leaf ``CMakeLists.txt``. +- **Directory scope**. These are equivalent to variables set in a given leaf ``CMakeLists.txt``. +- **Target**. These are the properties set on targets that we discussed above. +- **Test**. +- **Source files**. For example, compiler flags. +- **Cache entries**. +- **Installed files**. + + +For a complete list of properties known to CMake: + +.. code-block:: bash + + $ cmake --help-properties | less + + +You can get the current value of any property with ``get_property`` and set the value of any property with ``set_property``. + +