summaryrefslogtreecommitdiffstats
path: root/Help/guide/tutorial/index.rst
diff options
context:
space:
mode:
authorBetsy McPhail <betsy.mcphail@kitware.com>2019-07-09 17:36:53 (GMT)
committerBrad King <brad.king@kitware.com>2019-08-19 15:49:05 (GMT)
commitbc64401c3d9355f3c8fd6a205b8ef9d24a795204 (patch)
treec6f83c6c3f49683011e7d5bd7756e9dee65796e2 /Help/guide/tutorial/index.rst
parent49ce4d6ff4e70026ab1da6da91d7965ef61863ab (diff)
downloadCMake-bc64401c3d9355f3c8fd6a205b8ef9d24a795204.zip
CMake-bc64401c3d9355f3c8fd6a205b8ef9d24a795204.tar.gz
CMake-bc64401c3d9355f3c8fd6a205b8ef9d24a795204.tar.bz2
Tutorial: Improve Step 3
* Move `option(USE_MYMATH...` to the same location in all CMakeLists files
Diffstat (limited to 'Help/guide/tutorial/index.rst')
-rw-r--r--Help/guide/tutorial/index.rst25
1 files changed, 19 insertions, 6 deletions
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index d893090..cbeec4d 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -253,12 +253,14 @@ requirements are:
- ``target_include_directories``
- ``target_link_libraries``
-First up is MathFunctions. We first state that anybody linking to MathFunctions
-needs to include the current source directory, while MathFunctions itself
-doesn't. So this can become an ``INTERFACE`` usage requirement.
+Let's refactor our code from `Adding a Library (Step 2)`_ to use the modern
+CMake approach of usage requirements. We first state that anybody linking to
+MathFunctions needs to include the current source directory, while
+MathFunctions itself doesn't. So this can become an ``INTERFACE`` usage
+requirement.
Remember ``INTERFACE`` means things that consumers require but the producer
-doesn't. Update ``MathFunctions/CMakeLists.txt`` with:
+doesn't. Add the following lines to the end of ``MathFunctions/CMakeLists.txt``:
.. literalinclude:: Step4/MathFunctions/CMakeLists.txt
:language: cmake
@@ -266,7 +268,18 @@ doesn't. Update ``MathFunctions/CMakeLists.txt`` with:
Now that we've specified usage requirements for MathFunctions we can safely
remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level
-CMakeLists.
+CMakeLists, here:
+
+.. literalinclude:: Step4/CMakeLists.txt
+ :language: cmake
+ :start-after: # add the MathFunctions library
+ :end-before: # add the executable
+
+And here:
+
+.. literalinclude:: Step4/CMakeLists.txt
+ :language: cmake
+ :start-after: # so that we will find TutorialConfig.h
Once this is done, run **cmake** or **cmake-gui** to configure the project
and then build it with your chosen build tool or by using ``cmake --build .``
@@ -355,7 +368,7 @@ CMakeLists file as follows:
.. literalinclude:: Step6/CMakeLists.txt
:language: cmake
:start-after: # does this system provide the log and exp functions?
- :end-before: # should we use our own math functions
+ :end-before: # configure a header file to pass some of the CMake settings
Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them
from ``mysqrt.cxx``: