summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorBetsy McPhail <betsy.mcphail@kitware.com>2019-06-12 19:12:39 (GMT)
committerBrad King <brad.king@kitware.com>2019-06-19 12:59:31 (GMT)
commit0a6c9c417a5a5a254cf43eea77b2e8ac64dfcbb7 (patch)
treef6eabb94c017132cd1b3a83e6341bc14734ac96d /Help
parenteef3e020c21d2fdba19aab0daf1b99f8de0a16fe (diff)
downloadCMake-0a6c9c417a5a5a254cf43eea77b2e8ac64dfcbb7.zip
CMake-0a6c9c417a5a5a254cf43eea77b2e8ac64dfcbb7.tar.gz
CMake-0a6c9c417a5a5a254cf43eea77b2e8ac64dfcbb7.tar.bz2
Help: Update tutorial to include text from CMake book
Diffstat (limited to 'Help')
-rw-r--r--Help/guide/tutorial/index.rst35
1 files changed, 35 insertions, 0 deletions
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index 673f284..3265645 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -1,9 +1,34 @@
CMake Tutorial
**************
+This tutorial provides a step-by-step guide that covers common build
+system issues that CMake helps address. Seeing how various topics all
+work together in an example project can be very helpful. This tutorial
+can be found in the ``Help/guide/tutorial`` directory of the CMake
+source code tree. Each topic has its own subdirectory containing code
+that may be used as a starting point for that step. The tutorial
+examples are progressive so that each step provides the complete
+solution for the previous step.
+
A Basic Starting Point (Step 1)
===============================
+The most basic project is an executable built from source code files.
+For simple projects, a two line CMakeLists file is all that is required.
+This will be the starting point for our tutorial. The CMakeLists file
+looks like:
+
+.. literalinclude:: Step1/CMakeLists.txt
+ :language: cmake
+
+Note that this example uses lower case commands in the CMakeLists file.
+Upper, lower, and mixed case commands are supported by CMake. The source
+code for ``tutorial.cxx`` will compute the square root of a number and
+the first version of it is very simple, as follows:
+
+.. literalinclude:: Step1/tutorial.cxx
+ :language: c++
+
Adding a Version Number and Configured Header File
--------------------------------------------------
@@ -18,6 +43,14 @@ To add a version number we modify the CMakeLists file as follows:
:start-after: # set the version number
:end-before: # configure a header file
+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.
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :language: cmake
+ :start-after: # so that we will find TutorialConfig.h
+
We then create a ``TutorialConfig.h.in`` file in the source tree with the
following contents:
@@ -35,6 +68,8 @@ version numbers. The updated source code is listed below.
:start-after: // report version
:end-before: return 1;
+The main changes are the inclusion of the ``TutorialConfig.h`` header
+file and printing out a version number as part of the usage message.
Specify the C++ Standard
-------------------------