summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--Help/guide/tutorial/Step6/CMakeLists.txt6
-rw-r--r--Help/guide/tutorial/Step7/CMakeLists.txt6
-rw-r--r--Help/guide/tutorial/Step8/CMakeLists.txt6
-rw-r--r--Help/guide/tutorial/Step9/CMakeLists.txt6
-rw-r--r--Help/guide/tutorial/index.rst25
5 files changed, 31 insertions, 18 deletions
diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt
index 175f99f..2bb0859 100644
--- a/Help/guide/tutorial/Step6/CMakeLists.txt
+++ b/Help/guide/tutorial/Step6/CMakeLists.txt
@@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
check_symbol_exists(log "math.h" HAVE_LOG)
check_symbol_exists(exp "math.h" HAVE_EXP)
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
# configure a header file to pass some of the CMake settings
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt
index d1c0d1f..dada2d3 100644
--- a/Help/guide/tutorial/Step7/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/CMakeLists.txt
@@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
check_symbol_exists(log "math.h" HAVE_LOG)
check_symbol_exists(exp "math.h" HAVE_EXP)
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
# configure a header file to pass some of the CMake settings
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt
index d8e9145..4d62cd1 100644
--- a/Help/guide/tutorial/Step8/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/CMakeLists.txt
@@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
check_symbol_exists(log "math.h" HAVE_LOG)
check_symbol_exists(exp "math.h" HAVE_EXP)
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
# configure a header file to pass some of the CMake settings
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt
index 62bf1c8..f88976f 100644
--- a/Help/guide/tutorial/Step9/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/CMakeLists.txt
@@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
+# should we use our own math functions
+option(USE_MYMATH "Use tutorial provided math implementation" ON)
+
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
check_symbol_exists(log "math.h" HAVE_LOG)
check_symbol_exists(exp "math.h" HAVE_EXP)
-# should we use our own math functions
-option(USE_MYMATH "Use tutorial provided math implementation" ON)
-
# configure a header file to pass the version number only
configure_file(TutorialConfig.h.in TutorialConfig.h)
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``: