mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Tutorial: Restore USE_MYMATH in place of MY_MATH
In commit 80f5d28813 (Tutorial: Update step 2 style, 2022-07-25,
v3.25.0-rc1~226^2) we replaced some uses of `USE_MYMATH` with `MY_MATH`.
Restore the former name for consistency with the rest of the tutorial.
This commit is contained in:
committed by
Brad King
parent
d0451d1a67
commit
277fbb3035
@@ -236,11 +236,12 @@ Getting Started
|
||||
Start with the resulting files from Exercise 1. Complete ``TODO 7`` through
|
||||
``TODO 13``.
|
||||
|
||||
First create a variable ``MY_MATH`` using the :command:`option` command
|
||||
First create a variable ``USE_MYMATH`` using the :command:`option` command
|
||||
in the top-level ``CMakeLists.txt`` file. In that same file, use that option
|
||||
to determine whether to build and use the ``MathFunctions`` library.
|
||||
|
||||
Then, update ``tutorial.cxx`` and ``TutorialConfig.h.in`` to use ``MY_MATH``.
|
||||
Then, update ``tutorial.cxx`` and ``TutorialConfig.h.in`` to use
|
||||
``USE_MYMATH``.
|
||||
|
||||
Build and Run
|
||||
-------------
|
||||
@@ -314,9 +315,9 @@ Next, create an :command:`if` statement which checks the value of
|
||||
:command:`add_subdirectory` command from Exercise 1 with the additional
|
||||
:command:`list` commands.
|
||||
|
||||
When ``MY_MATH`` is ``ON``, the lists will be generated and will be added to
|
||||
our project. When ``MY_MATH`` is ``OFF``, the lists stay empty. With this
|
||||
strategy, we allow users to toggle ``MY_MATH`` to manipulate what library is
|
||||
When ``USE_MYMATH`` is ``ON``, the lists will be generated and will be added to
|
||||
our project. When ``USE_MYMATH`` is ``OFF``, the lists stay empty. With this
|
||||
strategy, we allow users to toggle ``USE_MYMATH`` to manipulate what library is
|
||||
used in the build.
|
||||
|
||||
The top-level CMakeLists.txt file will now look like the following:
|
||||
@@ -380,7 +381,7 @@ will cover the modern approach in the Step 3 of the tutorial.
|
||||
|
||||
The corresponding changes to the source code are fairly straightforward.
|
||||
First, in ``tutorial.cxx``, we include the ``MathFunctions.h`` header if
|
||||
``MY_MATH`` is defined.
|
||||
``USE_MYMATH`` is defined.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ project(Tutorial VERSION 1.0)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# TODO 7: Create a variable MY_MATH using option and set default to ON
|
||||
# TODO 7: Create a variable USE_MYMATH using option and set default to ON
|
||||
|
||||
# configure a header file to pass some of the CMake settings
|
||||
# to the source code
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
|
||||
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
|
||||
|
||||
// TODO 13: use cmakedefine to define MY_MATH
|
||||
// TODO 13: use cmakedefine to define USE_MYMATH
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "TutorialConfig.h"
|
||||
|
||||
// TODO 11: Only include MathFunctions if MY_MATH is defined
|
||||
// TODO 11: Only include MathFunctions if USE_MYMATH is defined
|
||||
|
||||
// TODO 5: Include MathFunctions.h
|
||||
|
||||
@@ -22,7 +22,7 @@ int main(int argc, char* argv[])
|
||||
// convert input to double
|
||||
const double inputValue = std::stod(argv[1]);
|
||||
|
||||
// TODO 12: Use mysqrt if MY_MATH is defined and sqrt otherwise
|
||||
// TODO 12: Use mysqrt if USE_MYMATH is defined and sqrt otherwise
|
||||
|
||||
// TODO 6: Replace sqrt with mysqrt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user