Skip to content

Commit

Permalink
update code examples orders
Browse files Browse the repository at this point in the history
  • Loading branch information
code4yonglei committed Sep 19, 2024
1 parent 759c6b1 commit 82b0cf3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions content/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ A complete list of ``Find<PackageName>.cmake`` can be found from the command-lin
We can configure and build verbosely. [#verbose]_
Notice that compiler flags, include directories, and link libraries are properly resolved by CMake.

You can find the complete working example in ``content/code/09_taskloop/solution``.
You can find the complete working example in ``content/code/10_taskloop/solution``.

.. exercise:: Exercise 10: Using MPI
.. exercise:: Exercise 11: Using MPI

In this exercise, you will attempt compiling a "Hello, world" program that
uses the message passing interface (MPI).
Expand All @@ -144,7 +144,7 @@ A complete list of ``Find<PackageName>.cmake`` can be found from the command-lin

.. tab:: C++

The scaffold project is in ``content/code/10_mpi-cxx``.
The scaffold project is in ``content/code/11_mpi-cxx``.

#. Compile the source file to an executable.
#. Link against the MPI imported target.
Expand All @@ -154,7 +154,7 @@ A complete list of ``Find<PackageName>.cmake`` can be found from the command-lin

.. tab:: Fortran

The scaffold project is in ``content/code/10_mpi-f``.
The scaffold project is in ``content/code/11_mpi-f``.

#. Compile the source file to an executable.
#. Link against the MPI imported target.
Expand Down
4 changes: 2 additions & 2 deletions content/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ In this workshop, you will learn

hello-cmake
cmake-syntax
hello-ctest
targets
.. hello-ctest
.. dependencies
.. fetch-content
.. python-bindings
Expand All @@ -68,9 +68,9 @@ In this workshop, you will learn

20 min ; :doc:`hello-cmake`
30 min ; :doc:`cmake-syntax`
50 min ; :doc:`targets`
30 min ; :doc:`probing`
20 min ; :doc:`dependencies`
40 min ; :doc:`targets`
10 min ; :doc:`tips-and-tricks`
10 min ; :doc:`additional-topics`

Expand Down
16 changes: 8 additions & 8 deletions content/probing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ command. You **should not** rely on ``execute_process`` to update any artifacts
**build-time**.


.. exercise:: Exercise 05: Find a Python module
.. exercise:: Exercise 06: Find a Python module

In this exercise, we'll use `execute_process <https://cmake.org/cmake/help/latest/command/execute_process.html>`_
to check whether the `cffi <https://cffi.readthedocs.io/en/latest/index.html>`_ Python module is
Expand All @@ -71,7 +71,7 @@ command. You **should not** rely on ``execute_process`` to update any artifacts
$ python -c "import cffi; print(cffi.__version__)"
Your goal is to replicate the same in CMake.
The scaffold code is in ``content/code/05_find_cffi``.
The scaffold code is in ``content/code/06_find_cffi``.
You will have to modify the call to ``execute_process`` to run the command above.

A working example is in the ``solution`` subfolder.
Expand Down Expand Up @@ -118,7 +118,7 @@ instances.
and ``PRE_LINK``) or after (with ``POST_BUILD``)


.. exercise:: Exercise 06: Before and after build
.. exercise:: Exercise 07: Before and after build

We want to perform some action before and after building a target, in this case a Fortran executable:

Expand All @@ -127,7 +127,7 @@ instances.
- After building, we want to check the size of the static allocations in the
binary, by invoking the ``size`` command. We use the ``static-size.py`` Python script.

The scaffold code is in ``content/code/06_pre_post-f``.
The scaffold code is in ``content/code/07_pre_post-f``.

#. Add CMake commands to build the ``example`` executable from the Fortran
sources. Find the text file with the link line under the build folder.
Expand All @@ -154,13 +154,13 @@ CMake provides modules and commands for these purposes:

In all cases, ``<LANG>`` can be one of ``CXX``, ``C`` or ``Fortran``.

.. exercise:: Exercise 07: Check that a compiler accepts a compiler flag
.. exercise:: Exercise 08: Check that a compiler accepts a compiler flag

Compilers evolve: they add and/or remove flags and sometimes you will face
the need to test whether some flags are available before using them in your
build.

The scaffold code is in ``content/code/07_check_compiler_flag``.
The scaffold code is in ``content/code/08_check_compiler_flag``.

#. Implement a ``CMakeLists.txt`` to build an executable from the
``asan-example.cpp`` source file.
Expand All @@ -178,13 +178,13 @@ In all cases, ``<LANG>`` can be one of ``CXX``, ``C`` or ``Fortran``.
A working example is in the ``solution`` subfolder.


.. exercise:: Exercise 08: Testing runtime capabilities
.. exercise:: Exercise 09: Testing runtime capabilities

Testing that some features will work properly for your code requires not only
compiling an object files, but also linking an executable and running it
successfully.

The scaffold code is in ``content/code/08_check_source_runs``.
The scaffold code is in ``content/code/09_check_source_runs``.

#. Create an executable target from the source file ``use-uuid.cpp``.
#. Add a check that linking against the library produces working executables.
Expand Down
6 changes: 3 additions & 3 deletions content/targets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Why it is robust to use targets and properties than using variables? Given a tar

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.
In this demo, we split the source code into 3 libraries and all files are available in the ``content/code/04_visibility-levels/`` folder.

.. code-block:: bash
Expand Down Expand Up @@ -232,13 +232,13 @@ Typically, you only need to pass the first argument: the folder within the build



.. exercise:: Exercise 04: Cellular automata
.. exercise:: Exercise 05: Cellular automata

Let's work with a project spanning multiple folders. We will implement a relatively simple code to compute and print to screen elementary `cellular automata <https://en.wikipedia.org/wiki/Cellular_automaton#Elementary_cellular_automata>`_. We separate the sources into ``src`` and ``external`` to simulate a nested project which reuses an external project.

Your goal is to:

- 1. Build the main executable at ``content/code/04_automata-cxx/`` for C++ and ``content/code/04_automata-f/`` for Fortran.
- 1. Build the main executable at ``content/code/05_automata-cxx/`` for C++ and ``content/code/05_automata-f/`` for Fortran.
- 2. Where are the obtained executables located in the build tree? Remember that CMake generates a build tree mirroring the source tree.
- 3. The executable will accept 3 arguments: the length, number of steps, and
automaton rule. You can run it with:
Expand Down

0 comments on commit 82b0cf3

Please sign in to comment.