Skip to content

Commit

Permalink
consider to use the demo from coderefineary for visibility levels
Browse files Browse the repository at this point in the history
  • Loading branch information
code4yonglei committed Sep 10, 2024
1 parent dfc8bd6 commit 6578a31
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions content/targets-new-visibility-levels.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.. _targets-new-visibility-levels:

Visibility levels (Code from Coderefineary)
-------------------------------------------


Visibility levels ``PRIVATE``, ``PUBLIC``, or ``INTERFACE`` are very powerful and herein we will briefly demonstrate their difference.


In this demo, we split the source code into 3 libraries and all files are available in the ``content/code/xx_visibility-levels/`` folder.

.
├── CMakeLists.txt
├── greeting
│   ├── greeting.cpp
│   └── greeting.hpp
├── hello_world
│   ├── hello_world.cpp
│   └── hello_world.hpp
├── main.cpp
└── world
├── world.cpp

Check failure on line 22 in content/targets-new-visibility-levels.rst

View workflow job for this annotation

GitHub Actions / Build

Unexpected indentation.

Check failure on line 22 in content/targets-new-visibility-levels.rst

View workflow job for this annotation

GitHub Actions / Build

Unexpected indentation.

Check failure on line 22 in content/targets-new-visibility-levels.rst

View workflow job for this annotation

GitHub Actions / Build

Unexpected indentation.
└── world.hpp


In this source code, the main function links to greeting which links to hello_world which links to world.


.. typealong:: The internal dependency tree

If you have installed ``Graphviz``, you can visualize the dependencies between these targets:

.. code-block:: console
$ cd build
$ cmake --graphviz=project.dot ..
$ dot -T svg project.dot -o project.svg
.. figure:: img/project.svg
:align: center

The dependencies between the four targets in the code example.


0 comments on commit 6578a31

Please sign in to comment.