Skip to content

Commit

Permalink
switch between properties and visibility levels
Browse files Browse the repository at this point in the history
  • Loading branch information
code4yonglei committed Sep 10, 2024
1 parent 08e7579 commit dfc8bd6
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions content/targets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------

Expand Down Expand Up @@ -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``.




0 comments on commit dfc8bd6

Please sign in to comment.