summaryrefslogtreecommitdiffstats
path: root/Help/guide/tutorial/Step11
diff options
context:
space:
mode:
authorBetsy McPhail <betsy.mcphail@kitware.com>2019-07-09 17:21:40 (GMT)
committerBrad King <brad.king@kitware.com>2019-08-19 15:48:58 (GMT)
commit82332f81bbb0609bf521d29c36b3ecf1566be892 (patch)
tree5ec58581dcc9e85f34c57efd013e7932e21d889d /Help/guide/tutorial/Step11
parent1996e0157826903f27f73825a01f83d53dc8fba4 (diff)
downloadCMake-82332f81bbb0609bf521d29c36b3ecf1566be892.zip
CMake-82332f81bbb0609bf521d29c36b3ecf1566be892.tar.gz
CMake-82332f81bbb0609bf521d29c36b3ecf1566be892.tar.bz2
Tutorial: Improve Step 1
* Update minimum required version to 3.10 * Use VERSION argument to project command rather than separate variables * Replace `endif(USE_MYMATH)` with more modern `endif()` * Simplify the call to 'configure_file()' * Add comments to tutorial.cxx to use as anchors in documentation * Remove CMakeLists and TutorialConfig.h.in files that users should create. Consequently, remove Step1 from CMake tests.
Diffstat (limited to 'Help/guide/tutorial/Step11')
-rw-r--r--Help/guide/tutorial/Step11/CMakeLists.txt13
-rw-r--r--Help/guide/tutorial/Step11/tutorial.cxx3
2 files changed, 6 insertions, 10 deletions
diff --git a/Help/guide/tutorial/Step11/CMakeLists.txt b/Help/guide/tutorial/Step11/CMakeLists.txt
index e54bdde..5ca2444 100644
--- a/Help/guide/tutorial/Step11/CMakeLists.txt
+++ b/Help/guide/tutorial/Step11/CMakeLists.txt
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.15)
-project(Tutorial)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
add_library(tutorial_compiler_flags INTERFACE)
target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11)
@@ -13,10 +15,6 @@ target_compile_options(tutorial_compiler_flags INTERFACE
"$<${msvc_cxx}:$<BUILD_INTERFACE:-W3>>"
)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# control where the static and shared libraries are built so that on windows
# we don't need to tinker with the path to run the executable
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
@@ -26,10 +24,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
# configure a header file to pass the version number only
-configure_file(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library
add_subdirectory(MathFunctions)
diff --git a/Help/guide/tutorial/Step11/tutorial.cxx b/Help/guide/tutorial/Step11/tutorial.cxx
index 6acafd2..a3a2bdc 100644
--- a/Help/guide/tutorial/Step11/tutorial.cxx
+++ b/Help/guide/tutorial/Step11/tutorial.cxx
@@ -16,7 +16,8 @@ int main(int argc, char* argv[])
return 1;
}
- double inputValue = std::stod(argv[1]);
+ // convert input to double
+ const double inputValue = std::stod(argv[1]);
const double outputValue = mathfunctions::sqrt(inputValue);