summaryrefslogtreecommitdiffstats
path: root/Help/guide
diff options
context:
space:
mode:
authorMarkus Ferrell <markus.ferrell@kitware.com>2022-07-08 20:30:02 (GMT)
committerMarkus Ferrell <markus.ferrell@kitware.com>2022-07-19 17:18:55 (GMT)
commitbc0aef31ee0880f87a07b7c2ef5db04d79249229 (patch)
treea4d9886a0ce15c126bc0c4ad2bb7b1e3587d5a32 /Help/guide
parent0beb0ec22fe3d9e08a308ab76183ed97d75c6bfb (diff)
downloadCMake-bc0aef31ee0880f87a07b7c2ef5db04d79249229.zip
CMake-bc0aef31ee0880f87a07b7c2ef5db04d79249229.tar.gz
CMake-bc0aef31ee0880f87a07b7c2ef5db04d79249229.tar.bz2
Tutorial: Add reference links for step 1 commands
Diffstat (limited to 'Help/guide')
-rw-r--r--Help/guide/tutorial/A Basic Starting Point.rst26
1 files changed, 19 insertions, 7 deletions
diff --git a/Help/guide/tutorial/A Basic Starting Point.rst b/Help/guide/tutorial/A Basic Starting Point.rst
index cf1ec01..d57cc35 100644
--- a/Help/guide/tutorial/A Basic Starting Point.rst
+++ b/Help/guide/tutorial/A Basic Starting Point.rst
@@ -19,8 +19,19 @@ required. This will be the starting point for our tutorial. Create a
add_executable(Tutorial tutorial.cxx)
-Note that this example uses lower case commands in the ``CMakeLists.txt`` file.
-Upper, lower, and mixed case commands are supported by CMake. The source
+Any project's top most ``CMakeLists.txt`` must start by specifying
+a minimum CMake version using :command:`cmake_minimum_required`. This ensures
+that the later CMake functions are run with a compatible version of CMake.
+
+To start a project, we use :command:`project` to set the project name. This
+call is required with every project and should be called soon after
+:command:`cmake_minimum_required`.
+
+Lastly, we use :command:`add_executable` to specify we want an executable
+named Tutorial generated using ``tutorial.cxx`` as the source.
+
+Note that this example uses lower case commands in the ``CMakeLists.txt``
+file. Upper, lower, and mixed case commands are supported by CMake. The source
code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be
used to compute the square root of a number.
@@ -79,7 +90,7 @@ to set the project name and version number.
:language: cmake
:end-before: # specify the C++ standard
-Then, configure a header file to pass the version number to the source
+Then use :command:`configure_file` to pass the version number to the source
code:
.. literalinclude:: Step2/CMakeLists.txt
@@ -91,7 +102,8 @@ code:
Since the configured file will be written into the binary tree, we
must add that directory to the list of paths to search for include
-files. Add the following lines to the end of the ``CMakeLists.txt`` file:
+files. Use :command:`target_include_directories` to add the following lines to
+the end of the ``CMakeLists.txt`` file:
.. literalinclude:: Step2/CMakeLists.txt
:caption: CMakeLists.txt
@@ -107,9 +119,9 @@ directory with the following contents:
:name: TutorialConfig.h.in
:language: c++
-When CMake configures this header file the values for
+When CMake configures this header file, the values for
``@Tutorial_VERSION_MAJOR@`` and ``@Tutorial_VERSION_MINOR@`` will be
-replaced.
+replaced with the corresponding version numbers from the project.
Next modify ``tutorial.cxx`` to include the configured header file,
``TutorialConfig.h``.
@@ -141,7 +153,7 @@ Next let's add some C++11 features to our project by replacing ``atof`` with
We will need to explicitly state in the CMake code that it should use the
correct flags. The easiest way to enable support for a specific C++ standard
in CMake is by using the :variable:`CMAKE_CXX_STANDARD` variable. For this
-tutorial, set the :variable:`CMAKE_CXX_STANDARD` variable in the
+tutorial, :command:`set` the :variable:`CMAKE_CXX_STANDARD` variable in the
``CMakeLists.txt`` file to ``11`` and :variable:`CMAKE_CXX_STANDARD_REQUIRED`
to ``True``. Make sure to add the ``CMAKE_CXX_STANDARD`` declarations above the
call to ``add_executable``.