[Cmake-commits] CMake branch, master, updated. v3.15.2-697-ga0c8405
Kitware Robot
kwrobot at kitware.com
Tue Aug 20 09:22:00 EDT 2019
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, master has been updated
via a0c8405d681d504f5d96489c2b5d44f10a29c6ed (commit)
via b80417f0fd1491d1c0f5d57019b47d4c13729545 (commit)
via 8c1d3e3b79fb921bfada3b19e6bb4115da4a4e6e (commit)
via 7432297ca081dbac34f939298db020c2ea4e2b32 (commit)
via f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b (commit)
via 6f6a32a0f601688da24e1737509a0b6e1ed4f63f (commit)
via 6a35d630dce6e9da6115cc4acb3393ce62a017ad (commit)
via 61d4d990d620815fac62ccbb28cf522703dde923 (commit)
via a36731c63460a41caae596b6dcbc75771a810549 (commit)
via df9cdf629c5211282dcab2e4751f69032e25a244 (commit)
via 442c0f0d463d8f08a6c47b371cdb13a9ec4cea41 (commit)
via bc64401c3d9355f3c8fd6a205b8ef9d24a795204 (commit)
via 49ce4d6ff4e70026ab1da6da91d7965ef61863ab (commit)
via 82332f81bbb0609bf521d29c36b3ecf1566be892 (commit)
via d56a4b16ca6f09d099c2ec832b11708f9b4b9819 (commit)
via 3c94069660112f841df3bae66891e05bfc7bad00 (commit)
via 9460501ad7353e6eecdf42d56568c1f909f64e27 (commit)
from 3d840ac939cc062203b8908b5144d45768ba041c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a0c8405d681d504f5d96489c2b5d44f10a29c6ed
commit a0c8405d681d504f5d96489c2b5d44f10a29c6ed
Merge: b80417f 3c94069
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Aug 20 13:18:41 2019 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Aug 20 09:20:49 2019 -0400
Merge topic 'trace-redirect'
3c94069660 Add --trace-redirect parameter to redirect trace output to a file
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !3645
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b80417f0fd1491d1c0f5d57019b47d4c13729545
commit b80417f0fd1491d1c0f5d57019b47d4c13729545
Merge: 8c1d3e3 6f6a32a
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Aug 20 13:16:35 2019 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Aug 20 09:19:22 2019 -0400
Merge topic 'cmake-tutorial'
6f6a32a0f6 Tutorial: Improve Step 9
6a35d630dc Tutorial: Improve Step 8
61d4d990d6 Tutorial: Improve Step 7
a36731c634 Tutorial: Improve Step 6
df9cdf629c Tutorial: Improve Step 5
442c0f0d46 Tutorial: Improve Step 4
bc64401c3d Tutorial: Improve Step 3
49ce4d6ff4 Tutorial: Improve Step 2
...
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !3528
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c1d3e3b79fb921bfada3b19e6bb4115da4a4e6e
commit 8c1d3e3b79fb921bfada3b19e6bb4115da4a4e6e
Merge: 7432297 f4fc066
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Aug 20 13:15:32 2019 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Aug 20 09:17:18 2019 -0400
Merge topic 'find_openacc_targets'
f4fc0667ae FindOpenACC: Provide import targets and OpenACC_<lang>_OPTIONS variable
9460501ad7 FindOpenACC: Provide a Fortran snippet that compiles with gfortran
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !3670
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7432297ca081dbac34f939298db020c2ea4e2b32
commit 7432297ca081dbac34f939298db020c2ea4e2b32
Merge: 3d840ac d56a4b1
Author: Brad King <brad.king at kitware.com>
AuthorDate: Tue Aug 20 13:15:16 2019 +0000
Commit: Kitware Robot <kwrobot at kitware.com>
CommitDate: Tue Aug 20 09:15:36 2019 -0400
Merge topic 'help-full'
d56a4b16ca Help: Restore installation of top-level index
Acked-by: Kitware Robot <kwrobot at kitware.com>
Merge-request: !3701
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b
commit f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b
Author: Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Tue Jul 30 11:01:57 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 15:20:38 2019 -0400
FindOpenACC: Provide import targets and OpenACC_<lang>_OPTIONS variable
Previously the FindOpenACC module had issues where the contents of
OpenACC_<lang>_FLAGS could not be used with target_compile_options
when it contained multiple compiler flags.
diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake
index 1f0238e..743e0e2 100644
--- a/Modules/FindOpenACC.cmake
+++ b/Modules/FindOpenACC.cmake
@@ -22,6 +22,14 @@ project, where ``<lang>`` is one of C, CXX, or Fortran:
Variable indicating if OpenACC support for ``<lang>`` was detected.
``OpenACC_<lang>_FLAGS``
OpenACC compiler flags for ``<lang>``, separated by spaces.
+``OpenACC_<lang>_OPTIONS``
+ OpenACC compiler flags for ``<lang>``, as a list. Suitable for usage
+ with target_compile_options or target_link_options.
+
+Additionally, the module provides :prop_tgt:`IMPORTED` targets:
+
+``OpenACC::OpenACC_<lang>``
+ Target for using OpenACC from ``<lang>``.
The module will also try to provide the OpenACC version variables:
@@ -239,6 +247,9 @@ foreach (LANG IN ITEMS C CXX Fortran)
if(NOT DEFINED OpenACC_${LANG}_FLAGS)
_OPENACC_GET_FLAGS("${LANG}" OpenACC_${LANG}_FLAGS)
endif()
+ if(NOT DEFINED OpenACC_${LANG}_OPTIONS)
+ separate_arguments(OpenACC_${LANG}_OPTIONS NATIVE_COMMAND "${OpenACC_${LANG}_FLAGS}")
+ endif()
_OPENACC_GET_SPEC_DATE("${LANG}" OpenACC_${LANG}_SPEC_DATE)
_OPENACC_SET_VERSION_BY_SPEC_DATE("${LANG}")
@@ -249,6 +260,23 @@ foreach (LANG IN ITEMS C CXX Fortran)
endif()
endforeach()
+foreach (LANG IN ITEMS C CXX Fortran)
+ if(OpenACC_${LANG}_FOUND AND NOT TARGET OpenACC::OpenACC_${LANG})
+ add_library(OpenACC::OpenACC_${LANG} INTERFACE IMPORTED)
+ endif()
+ if(OpenACC_${LANG}_LIBRARIES)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_LIBRARIES "${OpenACC_${LANG}_LIBRARIES}")
+ endif()
+ if(OpenACC_${LANG}_FLAGS)
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY
+ INTERFACE_LINK_OPTIONS "$<$<COMPILE_LANGUAGE:${LANG}>:${OpenACC_${LANG}_OPTIONS}>")
+ unset(_OpenACC_${LANG}_OPTIONS)
+ endif()
+endforeach()
+
unset(OpenACC_C_CXX_TEST_SOURCE)
unset(OpenACC_Fortran_TEST_SOURCE)
unset(OpenACC_C_CXX_CHECK_VERSION_SOURCE)
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 5b8f255..febcd7a 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1409,6 +1409,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
LibXml2
LTTngUST
ODBC
+ OpenACC
OpenCL
OpenGL
OpenMP
diff --git a/Tests/FindOpenACC/CMakeLists.txt b/Tests/FindOpenACC/CMakeLists.txt
new file mode 100644
index 0000000..ef7de65
--- /dev/null
+++ b/Tests/FindOpenACC/CMakeLists.txt
@@ -0,0 +1,20 @@
+
+set(langs C CXX)
+if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
+ list(APPEND langs Fortran)
+endif()
+
+foreach(lang IN LISTS langs)
+ if(CMAKE_${lang}_COMPILER)
+ add_test(NAME FindOpenACC.Test${lang} COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindOpenACC/${lang}Test"
+ "${CMake_BINARY_DIR}/Tests/FindOpenACC/${lang}Test"
+ ${build_generator_args}
+ --build-project TestFindOpenACC
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+ endif()
+endforeach()
diff --git a/Tests/FindOpenACC/CTest/CMakeLists.txt b/Tests/FindOpenACC/CTest/CMakeLists.txt
new file mode 100644
index 0000000..c8d0968
--- /dev/null
+++ b/Tests/FindOpenACC/CTest/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.14)
+project(VerifyFindOpenAcc C)
+
+set(CMAKE_C_STANDARD 11)
+
+find_package(OpenACC REQUIRED)
+
+add_executable(UsesOpenACC main.c)
+target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_C)
+
+add_executable(UsesOpenACCVars main.c)
+target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_C_OPTIONS})
+target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_C_OPTIONS})
diff --git a/Tests/FindOpenACC/CTest/main.c b/Tests/FindOpenACC/CTest/main.c
new file mode 100644
index 0000000..53b6cae
--- /dev/null
+++ b/Tests/FindOpenACC/CTest/main.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void vecaddgpu(float* r, float* a, float* b, int n)
+{
+#pragma acc kernels loop present(r, a, b)
+ for (int i = 0; i < n; ++i)
+ r[i] = a[i] + b[i];
+}
+
+int main()
+{
+ int n = 100000; /* vector length */
+ float* a; /* input vector 1 */
+ float* b; /* input vector 2 */
+ float* r; /* output vector */
+ float* e; /* expected output values */
+ int i, errs;
+
+ a = (float*)malloc(n * sizeof(float));
+ b = (float*)malloc(n * sizeof(float));
+ r = (float*)malloc(n * sizeof(float));
+ e = (float*)malloc(n * sizeof(float));
+ for (i = 0; i < n; ++i) {
+ a[i] = (float)(i + 1);
+ b[i] = (float)(1000 * i);
+ }
+/* compute on the GPU */
+#pragma acc data copyin(a [0:n], b [0:n]) copyout(r [0:n])
+ {
+ vecaddgpu(r, a, b, n);
+ }
+ /* compute on the host to compare */
+ for (i = 0; i < n; ++i)
+ e[i] = a[i] + b[i];
+ /* compare results */
+ errs = 0;
+ for (i = 0; i < n; ++i) {
+ if (r[i] != e[i]) {
+ ++errs;
+ }
+ }
+ return errs;
+}
diff --git a/Tests/FindOpenACC/CXXTest/CMakeLists.txt b/Tests/FindOpenACC/CXXTest/CMakeLists.txt
new file mode 100644
index 0000000..a6caf7b
--- /dev/null
+++ b/Tests/FindOpenACC/CXXTest/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.14)
+project(VerifyFindOpenAcc CXX)
+
+set(CMAKE_CXX_STANDARD 11)
+
+find_package(OpenACC REQUIRED)
+
+add_executable(UsesOpenACC main.cxx)
+target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_CXX)
+
+add_executable(UsesOpenACCVars main.cxx)
+target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_CXX_OPTIONS})
+target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_CXX_OPTIONS})
diff --git a/Tests/FindOpenACC/CXXTest/main.cxx b/Tests/FindOpenACC/CXXTest/main.cxx
new file mode 100644
index 0000000..7369045
--- /dev/null
+++ b/Tests/FindOpenACC/CXXTest/main.cxx
@@ -0,0 +1,43 @@
+
+#include <vector>
+
+void vecaddgpu(float* r, float* a, float* b, std::size_t n)
+{
+#pragma acc kernels loop present(r, a, b)
+ for (std::size_t i = 0; i < n; ++i)
+ r[i] = a[i] + b[i];
+}
+
+int main(int, char* [])
+{
+ const std::size_t n = 100000; /* vector length */
+ std::vector<float> a(n); /* input vector 1 */
+ std::vector<float> b(n); /* input vector 2 */
+ std::vector<float> r(n); /* output vector */
+ std::vector<float> e(n); /* expected output values */
+
+ for (std::size_t i = 0; i < n; ++i) {
+ a[i] = static_cast<float>(i + 1);
+ b[i] = static_cast<float>(1000 * i);
+ }
+
+ /* compute on the GPU */
+ auto a_ptr = a.data();
+ auto b_ptr = b.data();
+ auto r_ptr = r.data();
+#pragma acc data copyin(a_ptr [0:n], b_ptr [0:n]) copyout(r_ptr [0:n])
+ {
+ vecaddgpu(r_ptr, a_ptr, b_ptr, n);
+ }
+ /* compute on the host to compare */
+ for (std::size_t i = 0; i < n; ++i)
+ e[i] = a[i] + b[i];
+ /* compare results */
+ int errs = 0;
+ for (std::size_t i = 0; i < n; ++i) {
+ if (r[i] != e[i]) {
+ ++errs;
+ }
+ }
+ return errs;
+}
diff --git a/Tests/FindOpenACC/FortranTest/CMakeLists.txt b/Tests/FindOpenACC/FortranTest/CMakeLists.txt
new file mode 100644
index 0000000..12e3503
--- /dev/null
+++ b/Tests/FindOpenACC/FortranTest/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.14)
+project(VerifyFindOpenAcc Fortran)
+
+find_package(OpenACC REQUIRED)
+
+add_executable(UsesOpenACC main.f90)
+target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_Fortran)
+
+add_executable(UsesOpenACCVars main.f90)
+target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_Fortran_OPTIONS})
+target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_Fortran_OPTIONS})
diff --git a/Tests/FindOpenACC/FortranTest/main.f90 b/Tests/FindOpenACC/FortranTest/main.f90
new file mode 100644
index 0000000..2ff1ba0
--- /dev/null
+++ b/Tests/FindOpenACC/FortranTest/main.f90
@@ -0,0 +1,9 @@
+program t
+integer(4) a(10000)
+a = [ (1+i,i=1,10000) ]
+!$acc kernels
+do i = 1, 10000
+ if (a(i)/3000*3000.eq.a(i)) print *," located ",i,a(i),i.gt.5000,a(i)/5.0
+end do
+!$acc end kernels
+end
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f6a32a0f601688da24e1737509a0b6e1ed4f63f
commit 6f6a32a0f601688da24e1737509a0b6e1ed4f63f
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Thu Jul 18 15:40:25 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 9
* Move USE_MYMATH from configured header to target_compile_definitions
diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
index 3dbf287..dfa84c9 100644
--- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
@@ -13,6 +13,8 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
target_link_libraries(MakeTable tutorial_compiler_flags)
@@ -35,14 +37,12 @@ if(USE_MYMATH)
${CMAKE_CURRENT_BINARY_DIR}
)
+ # state that SqrtLibrary need PIC when the default is shared libraries
set_target_properties(SqrtLibrary PROPERTIES
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
-
-
- target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
index 483e20c..a2df2a7 100644
--- a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
@@ -13,6 +13,8 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
@@ -34,6 +36,7 @@ if(USE_MYMATH)
${CMAKE_CURRENT_BINARY_DIR}
)
+ # state that SqrtLibrary need PIC when the default is shared libraries
set_target_properties(SqrtLibrary PROPERTIES
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
@@ -41,8 +44,6 @@ if(USE_MYMATH)
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
-target_compile_definitions(MathFunctions PRIVATE "$<$<BOOL:${USE_MYMATH}>:USE_MYMATH>")
-
# define the symbol stating we are using the declspec(dllexport) when
# building on windows
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
diff --git a/Help/guide/tutorial/MultiPackage/tutorial.cxx b/Help/guide/tutorial/MultiPackage/tutorial.cxx
index ddc6364..f97805b 100644
--- a/Help/guide/tutorial/MultiPackage/tutorial.cxx
+++ b/Help/guide/tutorial/MultiPackage/tutorial.cxx
@@ -1,6 +1,5 @@
// A simple program that computes the square root of a number
#include <iostream>
-#include <sstream>
#include <string>
#include "MathFunctions.h"
diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
index 57555d3..e0c0621 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
@@ -11,6 +11,8 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
@@ -37,8 +39,6 @@ if(USE_MYMATH)
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
- target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
-
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
index df9f4df..e6cb8ba 100644
--- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
@@ -11,6 +11,8 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
target_link_libraries(MakeTable tutorial_compiler_flags)
@@ -33,13 +35,12 @@ if(USE_MYMATH)
${CMAKE_CURRENT_BINARY_DIR}
)
+ # state that SqrtLibrary need PIC when the default is shared libraries
set_target_properties(SqrtLibrary PROPERTIES
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
-
- target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/Step11/tutorial.cxx b/Help/guide/tutorial/Step11/tutorial.cxx
index a3a2bdc..a4f44d5 100644
--- a/Help/guide/tutorial/Step11/tutorial.cxx
+++ b/Help/guide/tutorial/Step11/tutorial.cxx
@@ -1,5 +1,4 @@
// A simple program that computes the square root of a number
-#include <cmath>
#include <iostream>
#include <string>
diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt
index f437053..d5f1cc8 100644
--- a/Help/guide/tutorial/Step9/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/CMakeLists.txt
@@ -10,7 +10,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
# 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 a header file to pass some of the CMake settings
+# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library
diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
index b40b464..50f0701 100644
--- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
@@ -22,10 +22,6 @@ target_include_directories(MathFunctions
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
-# use compile definitions to state if we have enabled USE_MYMATH
-# and that anything that links to use will get this define
-target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH")
-
# install rules
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step9/TutorialConfig.h.in b/Help/guide/tutorial/Step9/TutorialConfig.h.in
index 8cd2fc9..e23f521 100644
--- a/Help/guide/tutorial/Step9/TutorialConfig.h.in
+++ b/Help/guide/tutorial/Step9/TutorialConfig.h.in
@@ -1,3 +1,4 @@
-// the configured version number
+// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
+#cmakedefine USE_MYMATH
diff --git a/Help/guide/tutorial/Step9/tutorial.cxx b/Help/guide/tutorial/Step9/tutorial.cxx
index 779fbca..b3c6a4f 100644
--- a/Help/guide/tutorial/Step9/tutorial.cxx
+++ b/Help/guide/tutorial/Step9/tutorial.cxx
@@ -1,7 +1,6 @@
// A simple program that computes the square root of a number
#include <cmath>
#include <iostream>
-#include <sstream>
#include <string>
#include "TutorialConfig.h"
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index f6fd580..d858c25 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -645,7 +645,6 @@ The first step is to update the starting section of the top-level
.. literalinclude:: Step10/CMakeLists.txt
:language: cmake
- :start-after: set(CMAKE_CXX_STANDARD 14)
:end-before: # add the binary tree
Now that we have made MathFunctions always be used, we will need to update
@@ -658,7 +657,7 @@ The end result is that ``MathFunctions/CMakeLists.txt`` should look like:
.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
:language: cmake
- :lines: 1-40,46-
+ :lines: 1-36,42-
Next, update ``MathFunctions/mysqrt.cxx`` to use the ``mathfunctions`` and
``detail`` namespaces:
@@ -671,6 +670,7 @@ uses ``USE_MYMATH``:
#. Always include ``MathFunctions.h``
#. Always use ``mathfunctions::sqrt``
+#. Don't include cmath
Finally, update ``MathFunctions/MathFunctions.h`` to use dll export defines:
@@ -683,9 +683,14 @@ library that has position enabled code. The solution to this is to explicitly
set the ``POSITION_INDEPENDENT_CODE`` target property of SqrtLibrary to be
True no matter the build type.
+.. literalinclude:: Step10/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :lines: 37-42
+
**Exercise**: We modified ``MathFunctions.h`` to use dll export defines.
Using CMake documentation can you find a helper module to simplify this?
+
Adding Generator Expressions (Step 10)
======================================
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a35d630dce6e9da6115cc4acb3393ce62a017ad
commit 6a35d630dce6e9da6115cc4acb3393ce62a017ad
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Thu Jul 18 15:40:25 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 8
* Remove comments from CTestConfig.cmake
* Update directions
diff --git a/Help/guide/tutorial/Complete/CTestConfig.cmake b/Help/guide/tutorial/Complete/CTestConfig.cmake
new file mode 100644
index 0000000..73efdb1
--- /dev/null
+++ b/Help/guide/tutorial/Complete/CTestConfig.cmake
@@ -0,0 +1,7 @@
+set(CTEST_PROJECT_NAME "CMakeTutorial")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt
index 6a59104..34ae70c 100644
--- a/Help/guide/tutorial/Step10/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/CMakeLists.txt
@@ -38,7 +38,7 @@ install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
)
# enable testing
-enable_testing()
+include(CTest)
# does the application run
add_test(NAME Runs COMMAND Tutorial 25)
diff --git a/Help/guide/tutorial/Step10/CTestConfig.cmake b/Help/guide/tutorial/Step10/CTestConfig.cmake
new file mode 100644
index 0000000..73efdb1
--- /dev/null
+++ b/Help/guide/tutorial/Step10/CTestConfig.cmake
@@ -0,0 +1,7 @@
+set(CTEST_PROJECT_NAME "CMakeTutorial")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Help/guide/tutorial/Step11/CTestConfig.cmake b/Help/guide/tutorial/Step11/CTestConfig.cmake
new file mode 100644
index 0000000..73efdb1
--- /dev/null
+++ b/Help/guide/tutorial/Step11/CTestConfig.cmake
@@ -0,0 +1,7 @@
+set(CTEST_PROJECT_NAME "CMakeTutorial")
+set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
+
+set(CTEST_DROP_METHOD "http")
+set(CTEST_DROP_SITE "my.cdash.org")
+set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial")
+set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt
index 2859049..19b9913 100644
--- a/Help/guide/tutorial/Step8/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/CMakeLists.txt
@@ -50,7 +50,7 @@ set_tests_properties(Usage
# define a function to simplify adding tests
function(do_test target arg result)
-add_test(NAME Comp${arg} COMMAND ${target} ${arg})
+ add_test(NAME Comp${arg} COMMAND ${target} ${arg})
set_tests_properties(Comp${arg}
PROPERTIES PASS_REGULAR_EXPRESSION ${result}
)
diff --git a/Help/guide/tutorial/Step9/CTestConfig.cmake b/Help/guide/tutorial/Step9/CTestConfig.cmake
index 7a927ac..73efdb1 100644
--- a/Help/guide/tutorial/Step9/CTestConfig.cmake
+++ b/Help/guide/tutorial/Step9/CTestConfig.cmake
@@ -1,11 +1,3 @@
-## This file should be placed in the root directory of your project.
-## Then modify the CMakeLists.txt file in the root directory of your
-## project to incorporate the testing dashboard.
-##
-## # The following are required to submit to the CDash dashboard:
-## ENABLE_TESTING()
-## INCLUDE(CTest)
-
set(CTEST_PROJECT_NAME "CMakeTutorial")
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index 22f3527..f6fd580 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -578,10 +578,9 @@ Adding Support for a Dashboard (Step 8)
=======================================
Adding support for submitting our test results to a dashboard is very easy. We
-already defined a number of tests for our project in the earlier steps of this
-tutorial. We just have to run those tests and submit them to a dashboard. To
-include support for dashboards we include the CTest module in our top-level
-``CMakeLists.txt``.
+already defined a number of tests for our project in `Testing Support`_. Now we
+just have to run those tests and submit them to a dashboard. To include support
+for dashboards we include the CTest module in our top-level ``CMakeLists.txt``.
Replace:
@@ -600,21 +599,25 @@ With:
The CTest module will automatically call ``enable_testing()``, so
we can remove it from our CMake files.
-We will also need to create a ``CTestConfig.cmake`` file where we can specify
-the name of the project and where to submit the dashboard.
+We will also need to create a ``CTestConfig.cmake`` file in the top-level
+directory where we can specify the name of the project and where to submit the
+dashboard.
.. literalinclude:: Step9/CTestConfig.cmake
:language: cmake
CTest will read in this file when it runs. To create a simple dashboard you can
run **cmake** or **cmake-gui** to configure the project, but do not build it
-yet. Instead, change directory to the binary tree, and then run:
+yet. Instead, change directory to the binary tree, and then run::
-.. code-block:: console
+ ctest [-VV] –D Experimental
+
+Remember, for multi-config generators (e.g. Visual Studio), the configuration
+type must be specified::
- 'ctest [-VV] –D Experimental'
+ ctest [-VV] -C Debug –D Experimental
-On Windows, build the EXPERIMENTAL target.
+Or, from an IDE, build the ``Experimental`` target.
Ctest will build and test the project and submit the results to the Kitware
public dashboard. The results of your dashboard will be uploaded to Kitware's
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61d4d990d620815fac62ccbb28cf522703dde923
commit 61d4d990d620815fac62ccbb28cf522703dde923
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Thu Jul 18 15:40:25 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 7
* Update directions
diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt
index 78fee2f..c3b375a 100644
--- a/Help/guide/tutorial/Step7/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/CMakeLists.txt
@@ -28,7 +28,7 @@ target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
# so that we will find TutorialConfig.h
target_include_directories(Tutorial PUBLIC
"${PROJECT_BINARY_DIR}"
- )
+ )
# add the install targets
install(TARGETS Tutorial DESTINATION bin)
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index 6327c3d..22f3527 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -541,28 +541,37 @@ That is all there is to it. We start by including
``InstallRequiredSystemLibraries``. This module will include any runtime
libraries that are needed by the project for the current platform. Next we
set some CPack variables to where we have stored the license and version
-information for this project. The version information makes use of the
-variables we set earlier in this tutorial. Finally we include the CPack
-module which will use these variables and some other properties of the system
-you are on to setup an installer.
+information for this project. The version information was set earlier in this
+tutorial and the ``license.txt`` has been included in the top-level source
+directory for this step.
+
+Finally we include the CPack module which will use these variables and some
+other properties of the current system to setup an installer.
The next step is to build the project in the usual manner and then run
-CPack on it. To build a binary distribution you would run:
+CPack on it. To build a binary distribution, from the binary directory run:
.. code-block:: console
cpack
+To specify the generator, use the ``-G`` option. For multi-config builds, use
+``-C`` to specify the configuration. For example:
+
+.. code-block:: console
+
+ cpack -G ZIP -C Debug
+
To create a source distribution you would type:
.. code-block:: console
- cpack -C CPackSourceConfig.cmake
+ cpack --config CPackSourceConfig.cmake
Alternatively, run ``make package`` or right click the ``Package`` target and
``Build Project`` from an IDE.
-Run the installer executable found in the binary directory. Then run the
+Run the installer found in the binary directory. Then run the
installed executable and verify that it works.
Adding Support for a Dashboard (Step 8)
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a36731c63460a41caae596b6dcbc75771a810549
commit a36731c63460a41caae596b6dcbc75771a810549
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Fri Jul 26 12:46:08 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 6
* Print message when using the table
* Remove duplicated comment
* Remove HAVE_LOG and HAVE_EXP checks, use generated table instead
diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
index 9a3a03c..3dbf287 100644
--- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
@@ -43,10 +43,6 @@ if(USE_MYMATH)
target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
- if(HAVE_LOG AND HAVE_EXP)
- target_compile_definitions(SqrtLibrary
- PRIVATE "HAVE_LOG" "HAVE_EXP")
- endif()
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
index 386e146..ff37312 100644
--- a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
@@ -4,8 +4,6 @@
// include the generated table
#include "Table.h"
-#include <cmath>
-
namespace mathfunctions {
namespace detail {
// a hack square root calculation using simple operations
@@ -15,20 +13,13 @@ double mysqrt(double x)
return 0;
}
- // if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined(HAVE_EXP)
- double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result
- << " using log and exp" << std::endl;
-#else
// use the table to help find an initial value
double result = x;
if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
result = sqrtTable[static_cast<int>(x)];
}
- // if we have both log and exp then use them
-
// do ten iterations
for (int i = 0; i < 10; ++i) {
if (result <= 0) {
@@ -38,7 +29,7 @@ double mysqrt(double x)
result = result + 0.5 * delta / result;
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
}
-#endif
+
return result;
}
}
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
index 63c0f5f..483e20c 100644
--- a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt
@@ -13,12 +13,6 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
- # 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)
-
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
@@ -44,10 +38,6 @@ if(USE_MYMATH)
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
- target_compile_definitions(SqrtLibrary PRIVATE
- "$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>"
- "$<$<BOOL:${HAVE_EXP}>:HAVE_EXP>"
- )
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
index 386e146..4c212b3 100644
--- a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
@@ -4,8 +4,6 @@
// include the generated table
#include "Table.h"
-#include <cmath>
-
namespace mathfunctions {
namespace detail {
// a hack square root calculation using simple operations
@@ -15,12 +13,6 @@ double mysqrt(double x)
return 0;
}
- // if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined(HAVE_EXP)
- double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result
- << " using log and exp" << std::endl;
-#else
// use the table to help find an initial value
double result = x;
if (x >= 1 && x < 10) {
@@ -38,7 +30,7 @@ double mysqrt(double x)
result = result + 0.5 * delta / result;
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
}
-#endif
+
return result;
}
}
diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
index 7b6d4d4..57555d3 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
@@ -39,17 +39,6 @@ if(USE_MYMATH)
target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
- # 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)
-
- if(HAVE_LOG AND HAVE_EXP)
- target_compile_definitions(SqrtLibrary
- PRIVATE "HAVE_LOG" "HAVE_EXP")
- endif()
-
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
index 386e146..ff37312 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
@@ -4,8 +4,6 @@
// include the generated table
#include "Table.h"
-#include <cmath>
-
namespace mathfunctions {
namespace detail {
// a hack square root calculation using simple operations
@@ -15,20 +13,13 @@ double mysqrt(double x)
return 0;
}
- // if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined(HAVE_EXP)
- double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result
- << " using log and exp" << std::endl;
-#else
// use the table to help find an initial value
double result = x;
if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
result = sqrtTable[static_cast<int>(x)];
}
- // if we have both log and exp then use them
-
// do ten iterations
for (int i = 0; i < 10; ++i) {
if (result <= 0) {
@@ -38,7 +29,7 @@ double mysqrt(double x)
result = result + 0.5 * delta / result;
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
}
-#endif
+
return result;
}
}
diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
index 55a40d3..df9f4df 100644
--- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
@@ -40,10 +40,6 @@ if(USE_MYMATH)
target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
- if(HAVE_LOG AND HAVE_EXP)
- target_compile_definitions(SqrtLibrary
- PRIVATE "HAVE_LOG" "HAVE_EXP")
- endif()
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
index 436f96d..ff37312 100644
--- a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
@@ -4,8 +4,6 @@
// include the generated table
#include "Table.h"
-#include <cmath>
-
namespace mathfunctions {
namespace detail {
// a hack square root calculation using simple operations
@@ -15,20 +13,13 @@ double mysqrt(double x)
return 0;
}
- // if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined(HAVE_EXP)
- double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result
- << " using log and exp" << std::endl;
-#else
// use the table to help find an initial value
double result = x;
if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
result = sqrtTable[static_cast<int>(x)];
}
- // if we have both log and exp then use them
-
// do ten iterations
for (int i = 0; i < 10; ++i) {
if (result <= 0) {
diff --git a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
index 8cc3ae3..9ede4b3 100644
--- a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
@@ -24,17 +24,6 @@ target_include_directories(MathFunctions
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
-# 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)
-
-if(HAVE_LOG AND HAVE_EXP)
- target_compile_definitions(MathFunctions
- PRIVATE "HAVE_LOG" "HAVE_EXP")
-endif()
-
# install rules
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
index eade98c..2ae60c6 100644
--- a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
@@ -4,8 +4,6 @@
// include the generated table
#include "Table.h"
-#include <cmath>
-
// a hack square root calculation using simple operations
double mysqrt(double x)
{
@@ -16,6 +14,7 @@ double mysqrt(double x)
// use the table to help find an initial value
double result = x;
if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
result = sqrtTable[static_cast<int>(x)];
}
diff --git a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
index 8cc3ae3..9ede4b3 100644
--- a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
@@ -24,17 +24,6 @@ target_include_directories(MathFunctions
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
-# 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)
-
-if(HAVE_LOG AND HAVE_EXP)
- target_compile_definitions(MathFunctions
- PRIVATE "HAVE_LOG" "HAVE_EXP")
-endif()
-
# install rules
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
index 2b1d889..2ae60c6 100644
--- a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
@@ -4,8 +4,6 @@
// include the generated table
#include "Table.h"
-#include <cmath>
-
// a hack square root calculation using simple operations
double mysqrt(double x)
{
@@ -13,20 +11,13 @@ double mysqrt(double x)
return 0;
}
- // if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined(HAVE_EXP)
- double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result
- << " using log and exp" << std::endl;
-#else
// use the table to help find an initial value
double result = x;
if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
result = sqrtTable[static_cast<int>(x)];
}
- // if we have both log and exp then use them
-
// do ten iterations
for (int i = 0; i < 10; ++i) {
if (result <= 0) {
@@ -36,6 +27,6 @@ double mysqrt(double x)
result = result + 0.5 * delta / result;
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
}
-#endif
+
return result;
}
diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
index b4d337b..b40b464 100644
--- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
@@ -26,17 +26,6 @@ target_include_directories(MathFunctions
# and that anything that links to use will get this define
target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH")
-# 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)
-
-if(HAVE_LOG AND HAVE_EXP)
- target_compile_definitions(MathFunctions
- PRIVATE "HAVE_LOG" "HAVE_EXP")
-endif()
-
# install rules
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
index 2b1d889..2ae60c6 100644
--- a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
@@ -4,8 +4,6 @@
// include the generated table
#include "Table.h"
-#include <cmath>
-
// a hack square root calculation using simple operations
double mysqrt(double x)
{
@@ -13,20 +11,13 @@ double mysqrt(double x)
return 0;
}
- // if we have both log and exp then use them
-#if defined(HAVE_LOG) && defined(HAVE_EXP)
- double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result
- << " using log and exp" << std::endl;
-#else
// use the table to help find an initial value
double result = x;
if (x >= 1 && x < 10) {
+ std::cout << "Use the table to help find an initial value " << std::endl;
result = sqrtTable[static_cast<int>(x)];
}
- // if we have both log and exp then use them
-
// do ten iterations
for (int i = 0; i < 10; ++i) {
if (result <= 0) {
@@ -36,6 +27,6 @@ double mysqrt(double x)
result = result + 0.5 * delta / result;
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
}
-#endif
+
return result;
}
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index 2aaca77..6327c3d 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -450,27 +450,29 @@ this step.
Adding a Custom Command and Generated File (Step 6)
===================================================
-In this section, we will add a generated source file into the build process
-of an application. For this example, we will create a table of precomputed
-square roots as part of the build process, and then compile that
-table into our application.
+Suppose, for the purpose of this tutorial, we decide that we never want to use
+the platform ``log`` and ``exp`` functions and instead would like to
+generate a table of precomputed values to use in the ``mysqrt`` function.
+In this section, we will create the table as part of the build process,
+and then compile that table into our application.
-To accomplish this, we first need a program that will generate the table. In
-the MathFunctions subdirectory a new source file named ``MakeTable.cxx`` will
-do just that.
+First, let's remove the check for the ``log`` and ``exp`` functions in
+MathFunctions/CMakeLists. Then remove the check for ``HAVE_LOG`` and
+``HAVE_EXP`` from ``mysqrt.cxx``. At the same time, we can remove
+:code:`#include <cmath>`.
-.. literalinclude:: Step7/MathFunctions/MakeTable.cxx
- :language: c++
+In the MathFunctions subdirectory, a new source file named ``MakeTable.cxx``
+has been provided to generate the table.
-Note that the table is produced as valid C++ code and that the output filename
-is passed in as an argument.
+After reviewing the file, we can see that the table is produced as valid C++
+code and that the output filename is passed in as an argument.
-The next step is to add the appropriate commands to MathFunctions' CMakeLists
+The next step is to add the appropriate commands to MathFunctions CMakeLists
file to build the MakeTable executable and then run it as part of the build
process. A few commands are needed to accomplish this.
-First, the executable for ``MakeTable`` is added as any other executable would
-be added.
+First, at the top of MathFunctions/CMakeLists, the executable for ``MakeTable``
+is added as any other executable would be added.
.. literalinclude:: Step7/MathFunctions/CMakeLists.txt
:language: cmake
@@ -509,10 +511,14 @@ Now let's use the generated table. First, modify ``mysqrt.cxx`` to include
:start-after: // a hack square root calculation using simple operations
Run **cmake** or **cmake-gui** to configure the project and then build it
-with your chosen build tool. When this project is built it will first build
-the ``MakeTable`` executable. It will then run ``MakeTable`` to produce
-``Table.h``. Finally, it will compile ``mysqrt.cxx`` which includes
-``Table.h`` to produce the MathFunctions library.
+with your chosen build tool.
+
+When this project is built it will first build the ``MakeTable`` executable.
+It will then run ``MakeTable`` to produce ``Table.h``. Finally, it will
+compile ``mysqrt.cxx`` which includes ``Table.h`` to produce the MathFunctions
+library.
+
+Run the Tutorial executable and verify that it is using the table.
Building an Installer (Step 7)
==============================
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df9cdf629c5211282dcab2e4751f69032e25a244
commit df9cdf629c5211282dcab2e4751f69032e25a244
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Tue Jul 9 19:28:57 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 5
* Updated output message
* Use 'target_compile_definitions' for HAVE_LOG and HAVE_EXP
Previously, the change from using TutorialConfig.h to
target_compile_definitions happened without explanation as part of Step 8.
diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
index c12955d..9a3a03c 100644
--- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
@@ -13,12 +13,6 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
- # 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)
-
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
target_link_libraries(MakeTable tutorial_compiler_flags)
diff --git a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
index 96d9421..386e146 100644
--- a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx
@@ -18,8 +18,8 @@ double mysqrt(double x)
// if we have both log and exp then use them
#if defined(HAVE_LOG) && defined(HAVE_EXP)
double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result << " using log"
- << std::endl;
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
#else
// use the table to help find an initial value
double result = x;
diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
index 96d9421..386e146 100644
--- a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx
@@ -18,8 +18,8 @@ double mysqrt(double x)
// if we have both log and exp then use them
#if defined(HAVE_LOG) && defined(HAVE_EXP)
double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result << " using log"
- << std::endl;
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
#else
// use the table to help find an initial value
double result = x;
diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
index 0ef67f1..7b6d4d4 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
@@ -11,12 +11,6 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
- # 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)
-
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
@@ -43,6 +37,19 @@ if(USE_MYMATH)
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
+
+ # 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)
+
+ if(HAVE_LOG AND HAVE_EXP)
+ target_compile_definitions(SqrtLibrary
+ PRIVATE "HAVE_LOG" "HAVE_EXP")
+ endif()
+
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
index 96d9421..386e146 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
@@ -18,8 +18,8 @@ double mysqrt(double x)
// if we have both log and exp then use them
#if defined(HAVE_LOG) && defined(HAVE_EXP)
double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result << " using log"
- << std::endl;
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
#else
// use the table to help find an initial value
double result = x;
diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
index daaaa55..55a40d3 100644
--- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
@@ -11,12 +11,6 @@ target_include_directories(MathFunctions
option(USE_MYMATH "Use tutorial provided math implementation" ON)
if(USE_MYMATH)
- # 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)
-
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
target_link_libraries(MakeTable tutorial_compiler_flags)
diff --git a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
index 96d9421..436f96d 100644
--- a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx
@@ -18,8 +18,8 @@ double mysqrt(double x)
// if we have both log and exp then use them
#if defined(HAVE_LOG) && defined(HAVE_EXP)
double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result << " using log"
- << std::endl;
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
#else
// use the table to help find an initial value
double result = x;
@@ -38,7 +38,7 @@ double mysqrt(double x)
result = result + 0.5 * delta / result;
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
}
-#endif
+
return result;
}
}
diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt
index 2bb0859..c3b375a 100644
--- a/Help/guide/tutorial/Step6/CMakeLists.txt
+++ b/Help/guide/tutorial/Step6/CMakeLists.txt
@@ -10,12 +10,6 @@ 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)
-
# 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/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
index def1140..4bf6024 100644
--- a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
@@ -2,13 +2,21 @@ add_library(MathFunctions mysqrt.cxx)
# state that anybody linking to us needs to include the current source dir
# to find MathFunctions.h, while we don't.
-# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the
-# TutorialConfig.h include is an implementation detail
target_include_directories(MathFunctions
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${Tutorial_BINARY_DIR}
)
+# 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)
+
+if(HAVE_LOG AND HAVE_EXP)
+ target_compile_definitions(MathFunctions
+ PRIVATE "HAVE_LOG" "HAVE_EXP")
+endif()
+
# install rules
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx
index b9ad20a..3f23245 100644
--- a/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx
@@ -1,5 +1,4 @@
#include "MathFunctions.h"
-#include "TutorialConfig.h"
#include <iostream>
#include <cmath>
@@ -14,8 +13,8 @@ double mysqrt(double x)
// if we have both log and exp then use them
#if defined(HAVE_LOG) && defined(HAVE_EXP)
double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result << " using log"
- << std::endl;
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
#else
double result = x;
diff --git a/Help/guide/tutorial/Step6/TutorialConfig.h.in b/Help/guide/tutorial/Step6/TutorialConfig.h.in
index e97ce24..e23f521 100644
--- a/Help/guide/tutorial/Step6/TutorialConfig.h.in
+++ b/Help/guide/tutorial/Step6/TutorialConfig.h.in
@@ -2,7 +2,3 @@
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
#cmakedefine USE_MYMATH
-
-// does the platform provide exp and log functions?
-#cmakedefine HAVE_LOG
-#cmakedefine HAVE_EXP
diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt
index dada2d3..78fee2f 100644
--- a/Help/guide/tutorial/Step7/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/CMakeLists.txt
@@ -10,12 +10,6 @@ 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)
-
# 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/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
index 3c3a816..8cc3ae3 100644
--- a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
@@ -21,10 +21,20 @@ add_library(MathFunctions
# state that we depend on our binary dir to find Table.h
target_include_directories(MathFunctions
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${Tutorial_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
+# 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)
+
+if(HAVE_LOG AND HAVE_EXP)
+ target_compile_definitions(MathFunctions
+ PRIVATE "HAVE_LOG" "HAVE_EXP")
+endif()
+
# install rules
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
index 5272f56..eade98c 100644
--- a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx
@@ -1,5 +1,4 @@
#include "MathFunctions.h"
-#include "TutorialConfig.h"
#include <iostream>
// include the generated table
diff --git a/Help/guide/tutorial/Step7/TutorialConfig.h.in b/Help/guide/tutorial/Step7/TutorialConfig.h.in
index e97ce24..e23f521 100644
--- a/Help/guide/tutorial/Step7/TutorialConfig.h.in
+++ b/Help/guide/tutorial/Step7/TutorialConfig.h.in
@@ -2,7 +2,3 @@
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
#cmakedefine USE_MYMATH
-
-// does the platform provide exp and log functions?
-#cmakedefine HAVE_LOG
-#cmakedefine HAVE_EXP
diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt
index 4d62cd1..2859049 100644
--- a/Help/guide/tutorial/Step8/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/CMakeLists.txt
@@ -10,12 +10,6 @@ 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)
-
# 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/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
index 3c3a816..8cc3ae3 100644
--- a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
@@ -21,10 +21,20 @@ add_library(MathFunctions
# state that we depend on our binary dir to find Table.h
target_include_directories(MathFunctions
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
- PRIVATE ${Tutorial_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}
+ PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
+# 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)
+
+if(HAVE_LOG AND HAVE_EXP)
+ target_compile_definitions(MathFunctions
+ PRIVATE "HAVE_LOG" "HAVE_EXP")
+endif()
+
# install rules
install(TARGETS MathFunctions DESTINATION lib)
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
index 5b862fb..2b1d889 100644
--- a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx
@@ -1,5 +1,4 @@
#include "MathFunctions.h"
-#include "TutorialConfig.h"
#include <iostream>
// include the generated table
@@ -17,8 +16,8 @@ double mysqrt(double x)
// if we have both log and exp then use them
#if defined(HAVE_LOG) && defined(HAVE_EXP)
double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result << " using log"
- << std::endl;
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
#else
// use the table to help find an initial value
double result = x;
diff --git a/Help/guide/tutorial/Step8/TutorialConfig.h.in b/Help/guide/tutorial/Step8/TutorialConfig.h.in
index e97ce24..e23f521 100644
--- a/Help/guide/tutorial/Step8/TutorialConfig.h.in
+++ b/Help/guide/tutorial/Step8/TutorialConfig.h.in
@@ -2,7 +2,3 @@
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
#cmakedefine USE_MYMATH
-
-// does the platform provide exp and log functions?
-#cmakedefine HAVE_LOG
-#cmakedefine HAVE_EXP
diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt
index f88976f..f437053 100644
--- a/Help/guide/tutorial/Step9/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/CMakeLists.txt
@@ -10,12 +10,6 @@ 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)
-
# configure a header file to pass the version number only
configure_file(TutorialConfig.h.in TutorialConfig.h)
diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
index c8cd1dd..b4d337b 100644
--- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
@@ -26,6 +26,12 @@ target_include_directories(MathFunctions
# and that anything that links to use will get this define
target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH")
+# 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)
+
if(HAVE_LOG AND HAVE_EXP)
target_compile_definitions(MathFunctions
PRIVATE "HAVE_LOG" "HAVE_EXP")
diff --git a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
index 8b82141..2b1d889 100644
--- a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx
@@ -16,8 +16,8 @@ double mysqrt(double x)
// if we have both log and exp then use them
#if defined(HAVE_LOG) && defined(HAVE_EXP)
double result = exp(log(x) * 0.5);
- std::cout << "Computing sqrt of " << x << " to be " << result << " using log"
- << std::endl;
+ std::cout << "Computing sqrt of " << x << " to be " << result
+ << " using log and exp" << std::endl;
#else
// use the table to help find an initial value
double result = x;
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index 9118c4f..2aaca77 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -371,43 +371,81 @@ tutorial assume that they are not common.
If the platform has ``log`` and ``exp`` then we will use them to compute the
square root in the ``mysqrt`` function. We first test for the availability of
these functions using the ``CheckSymbolExists.cmake`` macro in the top-level
-CMakeLists file as follows:
+CMakeLists. We're going to use the new defines in ``TutorialConfig.h.in``,
+so be sure to set them before that file is configured.
-.. literalinclude:: Step6/CMakeLists.txt
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
:language: cmake
:start-after: # does this system provide the log and exp functions?
- :end-before: # configure a header file to pass some of the CMake settings
+ :end-before: if(HAVE_LOG AND HAVE_EXP)
Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them
from ``mysqrt.cxx``:
-.. literalinclude:: Step6/TutorialConfig.h.in
- :language: c
- :start-after: // does the platform provide exp and log functions?
+.. code-block:: console
-Finally, in the ``mysqrt`` function we can provide an alternate implementation
-based on ``log`` and ``exp`` if they are available on the system using the
-following code:
+ // does the platform provide exp and log functions?
+ #cmakedefine HAVE_LOG
+ #cmakedefine HAVE_EXP
+
+Modify ``mysqrt.cxx`` to include cmath. Next, in that same file in the
+``mysqrt`` function we can provide an alternate implementation based on
+``log`` and ``exp`` if they are available on the system using the following
+code (don't forget the ``#endif`` before returning the result!):
.. literalinclude:: Step6/MathFunctions/mysqrt.cxx
:language: c++
:start-after: // if we have both log and exp then use them
- :end-before: #else
+ :end-before: // do ten iterations
Run **cmake** or **cmake-gui** to configure the project and then build it
-with your chosen build tool.
+with your chosen build tool and run the Tutorial executable.
+
+You will notice that we're not using ``log`` and ``exp``, even if we think they
+should be available. We should realize quickly that we have forgotten to include
+``TutorialConfig.h`` in ``mysqrt.cxx``.
+
+We will also need to update MathFunctions/CMakeLists so ``mysqrt.cxx`` knows
+where this file is located:
+
+
+.. code-block:: cmake
+
+ target_include_directories(MathFunctions
+ INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_BINARY_DIR}
+ )
+
+After making this update, go ahead and build the project again and run the built
+Tutorial executable. If ``log`` and ``exp`` are still not being used, open the
+generated ``TutorialConfig.h`` file from the build directory. Maybe they aren't
+available on the current system?
+
+Which function gives better results now, sqrt or mysqrt?
+
+Specify Compile Definition
+--------------------------
-You will notice that even though ``HAVE_LOG`` and ``HAVE_EXP`` are both
-defined ``mysqrt`` isn't using them. We should realize quickly that we have
-forgotten to include ``TutorialConfig.h`` in ``mysqrt.cxx``.
+Is there a better place for us to save the ``HAVE_LOG`` and ``HAVE_EXP`` values
+other than in ``TutorialConfig.h``? Let's try to use
+``target_compile_definitions``.
-After making this update, go ahead and build the project again.
+First, remove the defines from ``TutorialConfig.h.in``. We no longer need to
+include ``TutorialConfig.h`` from ``mysqrt.cxx`` or the extra include in
+MathFunctions/CMakeLists.
-Run the built Tutorial executable. Which function gives better results now,
-Step1’s sqrt or Step5’s mysqrt?
+Next, we can move the check for ``HAVE_LOG`` and ``HAVE_EXP`` to
+MathFunctions/CMakeLists and then add specify those values as ``PRIVATE``
+compile definitions.
+
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
+ :language: cmake
+ :start-after: # does this system provide the log and exp functions?
+ :end-before: # install rules
-**Exercise**: Is there a better place for us to save the ``HAVE_LOG`` and
-``HAVE_EXP`` values other than in ``TutorialConfig.h``?
+After making these updates, go ahead and build the project again. Run the
+built Tutorial executable and verify that the results are same as earlier in
+this step.
Adding a Custom Command and Generated File (Step 6)
===================================================
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=442c0f0d463d8f08a6c47b371cdb13a9ec4cea41
commit 442c0f0d463d8f08a6c47b371cdb13a9ec4cea41
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Thu Jul 18 15:40:25 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 4
* Clarify directions
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index cbeec4d..9118c4f 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -293,17 +293,17 @@ Now we can start adding install rules and testing support to our project.
Install Rules
-------------
-The install rules are fairly simple for MathFunctions we want to install the
+The install rules are fairly simple: for MathFunctions we want to install the
library and header file and for the application we want to install the
executable and configured header.
-So to ``MathFunctions/CMakeLists.txt`` we add:
+So to the end of ``MathFunctions/CMakeLists.txt`` we add:
.. literalinclude:: Step5/MathFunctions/CMakeLists.txt
:language: cmake
:start-after: # install rules
-And the to top-level ``CMakeLists.txt`` we add:
+And to the end of the top-level ``CMakeLists.txt`` we add:
.. literalinclude:: Step5/CMakeLists.txt
:language: cmake
@@ -314,21 +314,25 @@ That is all that is needed to create a basic local install of the tutorial.
Run **cmake** or **cmake-gui** to configure the project and then build it
with your chosen build tool. Run the install step by typing
-``cmake --install .`` or from the command line, or build the ``INSTALL``
-target from an IDE. This will install the appropriate header files, libraries,
-and executables.
+``cmake --install .`` (introduced in 3.15, older versions of CMake must use
+``make install``) from the command line, or build the ``INSTALL`` target from
+an IDE. This will install the appropriate header files, libraries, and
+executables.
-Verify that the installed Tutorial runs. Note: The CMake variable
-``CMAKE_INSTALL_PREFIX`` is used to determine the root of where the files will
-be installed. If using ``cmake --install`` a custom installation directory can
-be given via ``--prefix`` argument.
+The CMake variable ``CMAKE_INSTALL_PREFIX`` is used to determine the root of
+where the files will be installed. If using ``cmake --install`` a custom
+installation directory can be given via ``--prefix`` argument. For
+multi-configuration tools, use the ``--config`` argument to specify the
+configuration.
+
+Verify that the installed Tutorial runs.
Testing Support
---------------
Next let's test our application. At the end of the top-level CMakeLists file we
-can add a number of basic tests to verify that the application is
-working correctly.
+can enable testing and then add a number of basic tests to verify that the
+application is working correctly.
.. literalinclude:: Step5/CMakeLists.txt
:language: cmake
@@ -339,7 +343,7 @@ otherwise crash, and has a zero return value. This is the basic form of a CTest
test.
The next test makes use of the ``PASS_REGULAR_EXPRESSION`` test property to
-verify that the output of the test contains certain strings, in this case:
+verify that the output of the test contains certain strings. In this case,
verifying that the the usage message is printed when an incorrect number of
arguments are provided.
@@ -349,7 +353,11 @@ invocation of ``do_test``, another test is added to the project with a name,
input, and expected results based on the passed arguments.
Rebuild the application and then cd to the binary directory and run
-``ctest -N`` and ``ctest -VV``.
+``ctest -N`` and ``ctest -VV``. For multi-config generators (e.g. Visual
+Studio), the configuration type must be specified. To run tests in Debug mode,
+for example, use ``ctest -C Debug -VV`` from the build directory (not the
+Debug subdirectory!). Alternatively, build the ``RUN_TESTS`` target from the
+IDE.
Adding System Introspection (Step 5)
====================================
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc64401c3d9355f3c8fd6a205b8ef9d24a795204
commit bc64401c3d9355f3c8fd6a205b8ef9d24a795204
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Tue Jul 9 13:36:53 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 3
* Move `option(USE_MYMATH...` to the same location in all CMakeLists files
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``:
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49ce4d6ff4e70026ab1da6da91d7965ef61863ab
commit 49ce4d6ff4e70026ab1da6da91d7965ef61863ab
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Mon Jul 1 20:58:32 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:49:05 2019 -0400
Tutorial: Improve Step 2
* Fix typo in #include
* Remove CMakeLists file that users should create
* Clarify which files users are expected to create
* Highlight the importance of configuring TutorialConfig.h.in after
the MY_MATH option has been set
diff --git a/Help/guide/tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt
index 26073bd..eca79d9 100644
--- a/Help/guide/tutorial/Complete/CMakeLists.txt
+++ b/Help/guide/tutorial/Complete/CMakeLists.txt
@@ -37,7 +37,7 @@ add_subdirectory(MathFunctions)
# add the executable
add_executable(Tutorial tutorial.cxx)
-target_link_libraries(Tutorial MathFunctions)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
diff --git a/Help/guide/tutorial/Complete/TutorialConfig.h.in b/Help/guide/tutorial/Complete/TutorialConfig.h.in
index 8cd2fc9..7e4d7fa 100644
--- a/Help/guide/tutorial/Complete/TutorialConfig.h.in
+++ b/Help/guide/tutorial/Complete/TutorialConfig.h.in
@@ -1,3 +1,3 @@
-// the configured version number
+// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/MultiPackage/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/CMakeLists.txt
index f588820..01d417a 100644
--- a/Help/guide/tutorial/MultiPackage/CMakeLists.txt
+++ b/Help/guide/tutorial/MultiPackage/CMakeLists.txt
@@ -29,7 +29,7 @@ add_subdirectory(MathFunctions)
# add the executable
add_executable(Tutorial tutorial.cxx)
-target_link_libraries(Tutorial MathFunctions)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt
index d163936..6a59104 100644
--- a/Help/guide/tutorial/Step10/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/CMakeLists.txt
@@ -23,7 +23,7 @@ add_subdirectory(MathFunctions)
# add the executable
add_executable(Tutorial tutorial.cxx)
-target_link_libraries(Tutorial MathFunctions)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
index aafd090..0ef67f1 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
@@ -43,12 +43,6 @@ if(USE_MYMATH)
POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
)
- target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
- if(HAVE_LOG AND HAVE_EXP)
- target_compile_definitions(SqrtLibrary
- PRIVATE "HAVE_LOG" "HAVE_EXP")
- endif()
-
target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
endif()
diff --git a/Help/guide/tutorial/Step10/TutorialConfig.h.in b/Help/guide/tutorial/Step10/TutorialConfig.h.in
index 8cd2fc9..7e4d7fa 100644
--- a/Help/guide/tutorial/Step10/TutorialConfig.h.in
+++ b/Help/guide/tutorial/Step10/TutorialConfig.h.in
@@ -1,3 +1,3 @@
-// the configured version number
+// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/Step11/CMakeLists.txt b/Help/guide/tutorial/Step11/CMakeLists.txt
index 5ca2444..4763951 100644
--- a/Help/guide/tutorial/Step11/CMakeLists.txt
+++ b/Help/guide/tutorial/Step11/CMakeLists.txt
@@ -31,7 +31,7 @@ add_subdirectory(MathFunctions)
# add the executable
add_executable(Tutorial tutorial.cxx)
-target_link_libraries(Tutorial MathFunctions)
+target_link_libraries(Tutorial PUBLIC MathFunctions)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
diff --git a/Help/guide/tutorial/Step11/TutorialConfig.h.in b/Help/guide/tutorial/Step11/TutorialConfig.h.in
index 8cd2fc9..7e4d7fa 100644
--- a/Help/guide/tutorial/Step11/TutorialConfig.h.in
+++ b/Help/guide/tutorial/Step11/TutorialConfig.h.in
@@ -1,3 +1,3 @@
-// the configured version number
+// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt
deleted file mode 100644
index 8b443a6..0000000
--- a/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_library(MathFunctions mysqrt.cxx)
diff --git a/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx
index 7d9379e..1e4d97a 100644
--- a/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx
+++ b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx
@@ -1,4 +1,3 @@
-#include "MathFunctions.h"
#include <iostream>
// a hack square root calculation using simple operations
diff --git a/Help/guide/tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt
index 4d7a6e7..1c12816 100644
--- a/Help/guide/tutorial/Step3/CMakeLists.txt
+++ b/Help/guide/tutorial/Step3/CMakeLists.txt
@@ -14,7 +14,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON)
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
-# add the MathFunctions library?
+# add the MathFunctions library
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
@@ -24,7 +24,7 @@ endif()
# add the executable
add_executable(Tutorial tutorial.cxx)
-target_link_libraries(Tutorial ${EXTRA_LIBS})
+target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
diff --git a/Help/guide/tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt
index 0f24549..38e9b1f 100644
--- a/Help/guide/tutorial/Step4/CMakeLists.txt
+++ b/Help/guide/tutorial/Step4/CMakeLists.txt
@@ -14,7 +14,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON)
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
-# add the MathFunctions library?
+# add the MathFunctions library
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt
index 59e575f..c3b375a 100644
--- a/Help/guide/tutorial/Step5/CMakeLists.txt
+++ b/Help/guide/tutorial/Step5/CMakeLists.txt
@@ -14,7 +14,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON)
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
-# add the MathFunctions library?
+# add the MathFunctions library
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt
index fe4728a..175f99f 100644
--- a/Help/guide/tutorial/Step6/CMakeLists.txt
+++ b/Help/guide/tutorial/Step6/CMakeLists.txt
@@ -20,7 +20,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON)
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
-# add the MathFunctions library?
+# add the MathFunctions library
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt
index b251aaf..d1c0d1f 100644
--- a/Help/guide/tutorial/Step7/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/CMakeLists.txt
@@ -20,7 +20,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON)
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
-# add the MathFunctions library?
+# add the MathFunctions library
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt
index 0c91dab..d8e9145 100644
--- a/Help/guide/tutorial/Step8/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/CMakeLists.txt
@@ -20,7 +20,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON)
# to the source code
configure_file(TutorialConfig.h.in TutorialConfig.h)
-# add the MathFunctions library?
+# add the MathFunctions library
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt
index 5822f89..62bf1c8 100644
--- a/Help/guide/tutorial/Step9/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/CMakeLists.txt
@@ -19,7 +19,7 @@ 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)
-# add the MathFunctions library?
+# add the MathFunctions library
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index df65123..d893090 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -145,18 +145,22 @@ then use this library instead of the standard square root function provided by
the compiler.
For this tutorial we will put the library into a subdirectory
-called MathFunctions. It will have the following one line CMakeLists file:
+called MathFunctions. This directory already contains a header file,
+``MathFunctions.h``, and a source file ``mysqrt.cxx``. The source file has one
+function called ``mysqrt`` that provides similar functionality to the
+compiler's ``sqrt`` function.
-.. literalinclude:: Step2/MathFunctions/CMakeLists.txt
+Add the following one line ``CMakeLists.txt`` file to the MathFunctions
+directory:
+
+.. literalinclude:: Step3/MathFunctions/CMakeLists.txt
:language: cmake
-The source file ``mysqrt.cxx`` has one function called ``mysqrt`` that
-provides similar functionality to the compiler’s ``sqrt`` function. To make use
-of the new library we add an ``add_subdirectory`` call in the top-level
-CMakeLists file so that the library will get built. We add the new library to
-the executable, and add MathFunctions as an include directory so that the
-``mqsqrt.h`` header file can be found. The last few lines of the top-level
-CMakeLists file now look like:
+To make use of the new library we will add an ``add_subdirectory`` call in the
+top-level CMakeLists file so that the library will get built. We add the new
+library to the executable, and add MathFunctions as an include directory so
+that the ``mqsqrt.h`` header file can be found. The last few lines of the
+top-level CMakeLists file should now look like:
.. code-block:: cmake
@@ -166,7 +170,7 @@ CMakeLists file now look like:
# add the executable
add_executable(Tutorial tutorial.cxx)
- target_link_libraries(Tutorial MathFunctions)
+ target_link_libraries(Tutorial PUBLIC MathFunctions)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
@@ -183,12 +187,12 @@ file.
.. literalinclude:: Step3/CMakeLists.txt
:language: cmake
:start-after: # should we use our own math functions
- :end-before: # configure a header file to pass some of the CMake settings
+ :end-before: # add the MathFunctions library
-This will show up in the CMake GUI and ccmake with a default value of ON
-that can be changed by the user. This setting will be stored in the cache so
-that the user does not need to set the value each time they run CMake on this
-build directory.
+This option will be displayed in the CMake GUI and ccmake with a default
+value of ON that can be changed by the user. This setting will be stored in
+the cache so that the user does not need to set the value each time they run
+CMake on a build directory.
The next change is to make building and linking the MathFunctions library
conditional. To do this we change the end of the top-level CMakeLists file to
@@ -196,22 +200,24 @@ look like the following:
.. literalinclude:: Step3/CMakeLists.txt
:language: cmake
- :start-after: # add the MathFunctions library?
+ :start-after: # add the MathFunctions library
-Note the use of the variables ``EXTRA_LIBS`` and ``EXTRA_INCLUDES`` to collect
-up any optional libraries to later be linked into the executable. This is a
-classic approach when dealing with many optional components, we will cover the
-modern approach in the next step.
+Note the use of the variable ``EXTRA_LIBS`` to collect up any optional
+libraries to later be linked into the executable. The variable
+``EXTRA_INCLUDES`` is used similarly for optional header files. This is a
+classic approach when dealing with many optional components, we will cover
+the modern approach in the next step.
The corresponding changes to the source code are fairly straightforward. First,
-include the MathFunctions header if we need it:
+in ``tutorial.cxx``, include the MathFunctions header if we need it:
.. literalinclude:: Step3/tutorial.cxx
:language: c++
:start-after: // should we include the MathFunctions header
:end-before: int main
-Then make which square root function is used dependent on ``USE_MYMATH``:
+Then, in the same file, make which square root function is used dependent on
+``USE_MYMATH``:
.. literalinclude:: Step3/tutorial.cxx
:language: c++
@@ -225,10 +231,14 @@ Since the source code now requires ``USE_MYMATH`` we can add it to
:language: c
:lines: 4
+**Exercise**: Why is it important that we configure ``TutorialConfig.h.in``
+after the option for ``USE_MYMATH``? What would happen if we inverted the two?
+
Run **cmake** or **cmake-gui** to configure the project and then build it
with your chosen build tool. Then run the built Tutorial executable.
-Which function gives better results, Step1’s sqrt or Step2’s mysqrt?
+Use ccmake or the CMake GUI to update the value of ``USE_MYMATH``. Rebuild and
+run the tutorial again. Which function gives better results, sqrt or mysqrt?
Adding Usage Requirements for Library (Step 3)
==============================================
@@ -375,10 +385,6 @@ After making this update, go ahead and build the project again.
Run the built Tutorial executable. Which function gives better results now,
Step1’s sqrt or Step5’s mysqrt?
-**Exercise**: Why is it important that we configure ``TutorialConfig.h.in``
-after the checks for ``HAVE_LOG`` and ``HAVE_EXP``? What would happen if we
-inverted the two?
-
**Exercise**: Is there a better place for us to save the ``HAVE_LOG`` and
``HAVE_EXP`` values other than in ``TutorialConfig.h``?
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82332f81bbb0609bf521d29c36b3ecf1566be892
commit 82332f81bbb0609bf521d29c36b3ecf1566be892
Author: Betsy McPhail <betsy.mcphail at kitware.com>
AuthorDate: Tue Jul 9 13:21:40 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:48:58 2019 -0400
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.
diff --git a/Help/guide/tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt
index 4541392..26073bd 100644
--- a/Help/guide/tutorial/Complete/CMakeLists.txt
+++ b/Help/guide/tutorial/Complete/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}")
@@ -32,10 +30,7 @@ elseif(UNIX)
endif()
# 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/Complete/tutorial.cxx b/Help/guide/tutorial/Complete/tutorial.cxx
index 4451cbd..586d183 100644
--- a/Help/guide/tutorial/Complete/tutorial.cxx
+++ b/Help/guide/tutorial/Complete/tutorial.cxx
@@ -15,10 +15,11 @@ 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]);
+ // calculate square root
const double outputValue = mathfunctions::sqrt(inputValue);
-
std::cout << "The square root of " << inputValue << " is " << outputValue
<< std::endl;
return 0;
diff --git a/Help/guide/tutorial/Consumer/CMakeLists.txt b/Help/guide/tutorial/Consumer/CMakeLists.txt
index 4033b4d..a0e4598 100644
--- a/Help/guide/tutorial/Consumer/CMakeLists.txt
+++ b/Help/guide/tutorial/Consumer/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.3)
+cmake_minimum_required(VERSION 3.10)
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
diff --git a/Help/guide/tutorial/MultiPackage/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/CMakeLists.txt
index bea611c..f588820 100644
--- a/Help/guide/tutorial/MultiPackage/CMakeLists.txt
+++ b/Help/guide/tutorial/MultiPackage/CMakeLists.txt
@@ -1,12 +1,11 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+
+# set the project name and version
+project(Tutorial VERSION 1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
-# 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
@@ -23,10 +22,7 @@ elseif(UNIX)
endif()
# 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/MultiPackage/tutorial.cxx b/Help/guide/tutorial/MultiPackage/tutorial.cxx
index 4451cbd..ddc6364 100644
--- a/Help/guide/tutorial/MultiPackage/tutorial.cxx
+++ b/Help/guide/tutorial/MultiPackage/tutorial.cxx
@@ -15,6 +15,7 @@ int main(int argc, char* argv[])
return 1;
}
+ // convert input to double
double inputValue = std::stod(argv[1]);
const double outputValue = mathfunctions::sqrt(inputValue);
diff --git a/Help/guide/tutorial/Step1/CMakeLists.txt b/Help/guide/tutorial/Step1/CMakeLists.txt
deleted file mode 100644
index 141f0c2..0000000
--- a/Help/guide/tutorial/Step1/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-project(Tutorial)
-
-add_executable(Tutorial tutorial.cxx)
diff --git a/Help/guide/tutorial/Step1/TutorialConfig.h.in b/Help/guide/tutorial/Step1/TutorialConfig.h.in
deleted file mode 100644
index 7e4d7fa..0000000
--- a/Help/guide/tutorial/Step1/TutorialConfig.h.in
+++ /dev/null
@@ -1,3 +0,0 @@
-// the configured options and settings for Tutorial
-#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
-#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
diff --git a/Help/guide/tutorial/Step1/tutorial.cxx b/Help/guide/tutorial/Step1/tutorial.cxx
index f8dd0c6..08323bf 100644
--- a/Help/guide/tutorial/Step1/tutorial.cxx
+++ b/Help/guide/tutorial/Step1/tutorial.cxx
@@ -11,9 +11,11 @@ int main(int argc, char* argv[])
return 1;
}
- double inputValue = atof(argv[1]);
+ // convert input to double
+ const double inputValue = atof(argv[1]);
- double outputValue = sqrt(inputValue);
+ // calculate square root
+ const double outputValue = sqrt(inputValue);
std::cout << "The square root of " << inputValue << " is " << outputValue
<< std::endl;
return 0;
diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt
index 25bc0c1..d163936 100644
--- a/Help/guide/tutorial/Step10/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/CMakeLists.txt
@@ -1,13 +1,12 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
-# 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}")
@@ -17,10 +16,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/Step10/tutorial.cxx b/Help/guide/tutorial/Step10/tutorial.cxx
index 42eaab9..37a0333 100644
--- a/Help/guide/tutorial/Step10/tutorial.cxx
+++ b/Help/guide/tutorial/Step10/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);
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);
diff --git a/Help/guide/tutorial/Step2/CMakeLists.txt b/Help/guide/tutorial/Step2/CMakeLists.txt
index 059b89a..7aa59e9 100644
--- a/Help/guide/tutorial/Step2/CMakeLists.txt
+++ b/Help/guide/tutorial/Step2/CMakeLists.txt
@@ -1,19 +1,15 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# configure a header file to pass some of the CMake settings
# to the source code
-configure_file(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the executable
add_executable(Tutorial tutorial.cxx)
diff --git a/Help/guide/tutorial/Step2/tutorial.cxx b/Help/guide/tutorial/Step2/tutorial.cxx
index f2ab446..53b0810 100644
--- a/Help/guide/tutorial/Step2/tutorial.cxx
+++ b/Help/guide/tutorial/Step2/tutorial.cxx
@@ -15,9 +15,11 @@ 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]);
- double outputValue = sqrt(inputValue);
+ // calculate square root
+ const double outputValue = sqrt(inputValue);
std::cout << "The square root of " << inputValue << " is " << outputValue
<< std::endl;
return 0;
diff --git a/Help/guide/tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt
index 9804abf..4d7a6e7 100644
--- a/Help/guide/tutorial/Step3/CMakeLists.txt
+++ b/Help/guide/tutorial/Step3/CMakeLists.txt
@@ -1,29 +1,25 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
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)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# configure a header file to pass some of the CMake settings
# to the source code
-configure_file(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library?
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions")
-endif(USE_MYMATH)
+endif()
# add the executable
add_executable(Tutorial tutorial.cxx)
diff --git a/Help/guide/tutorial/Step3/tutorial.cxx b/Help/guide/tutorial/Step3/tutorial.cxx
index 8156a9c..b3c6a4f 100644
--- a/Help/guide/tutorial/Step3/tutorial.cxx
+++ b/Help/guide/tutorial/Step3/tutorial.cxx
@@ -20,13 +20,14 @@ 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]);
// which square root function should we use?
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ const double outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
diff --git a/Help/guide/tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt
index 0ae2648..0f24549 100644
--- a/Help/guide/tutorial/Step4/CMakeLists.txt
+++ b/Help/guide/tutorial/Step4/CMakeLists.txt
@@ -1,28 +1,24 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
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)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# configure a header file to pass some of the CMake settings
# to the source code
-configure_file(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library?
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
-endif(USE_MYMATH)
+endif()
# add the executable
add_executable(Tutorial tutorial.cxx)
diff --git a/Help/guide/tutorial/Step4/tutorial.cxx b/Help/guide/tutorial/Step4/tutorial.cxx
index 8156a9c..b3c6a4f 100644
--- a/Help/guide/tutorial/Step4/tutorial.cxx
+++ b/Help/guide/tutorial/Step4/tutorial.cxx
@@ -20,13 +20,14 @@ 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]);
// which square root function should we use?
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ const double outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt
index dac9b45..59e575f 100644
--- a/Help/guide/tutorial/Step5/CMakeLists.txt
+++ b/Help/guide/tutorial/Step5/CMakeLists.txt
@@ -1,22 +1,18 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
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)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# configure a header file to pass some of the CMake settings
# to the source code
-configure_file(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library?
if(USE_MYMATH)
diff --git a/Help/guide/tutorial/Step5/tutorial.cxx b/Help/guide/tutorial/Step5/tutorial.cxx
index 8156a9c..b3c6a4f 100644
--- a/Help/guide/tutorial/Step5/tutorial.cxx
+++ b/Help/guide/tutorial/Step5/tutorial.cxx
@@ -20,13 +20,14 @@ 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]);
// which square root function should we use?
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ const double outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt
index 1465e46..fe4728a 100644
--- a/Help/guide/tutorial/Step6/CMakeLists.txt
+++ b/Help/guide/tutorial/Step6/CMakeLists.txt
@@ -1,13 +1,12 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
@@ -19,10 +18,7 @@ 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(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library?
if(USE_MYMATH)
diff --git a/Help/guide/tutorial/Step6/tutorial.cxx b/Help/guide/tutorial/Step6/tutorial.cxx
index 8156a9c..b3c6a4f 100644
--- a/Help/guide/tutorial/Step6/tutorial.cxx
+++ b/Help/guide/tutorial/Step6/tutorial.cxx
@@ -20,13 +20,14 @@ 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]);
// which square root function should we use?
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ const double outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt
index a1efa77..b251aaf 100644
--- a/Help/guide/tutorial/Step7/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/CMakeLists.txt
@@ -1,13 +1,12 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
@@ -19,16 +18,13 @@ 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(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library?
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
-endif(USE_MYMATH)
+endif()
# add the executable
add_executable(Tutorial tutorial.cxx)
diff --git a/Help/guide/tutorial/Step7/tutorial.cxx b/Help/guide/tutorial/Step7/tutorial.cxx
index 8156a9c..b3c6a4f 100644
--- a/Help/guide/tutorial/Step7/tutorial.cxx
+++ b/Help/guide/tutorial/Step7/tutorial.cxx
@@ -20,13 +20,14 @@ 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]);
// which square root function should we use?
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ const double outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt
index a0316a0..0c91dab 100644
--- a/Help/guide/tutorial/Step8/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/CMakeLists.txt
@@ -1,13 +1,12 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
@@ -19,16 +18,13 @@ 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(
- "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
- "${PROJECT_BINARY_DIR}/TutorialConfig.h"
- )
+configure_file(TutorialConfig.h.in TutorialConfig.h)
# add the MathFunctions library?
if(USE_MYMATH)
add_subdirectory(MathFunctions)
list(APPEND EXTRA_LIBS MathFunctions)
-endif(USE_MYMATH)
+endif()
# add the executable
add_executable(Tutorial tutorial.cxx)
diff --git a/Help/guide/tutorial/Step8/tutorial.cxx b/Help/guide/tutorial/Step8/tutorial.cxx
index 8156a9c..b3c6a4f 100644
--- a/Help/guide/tutorial/Step8/tutorial.cxx
+++ b/Help/guide/tutorial/Step8/tutorial.cxx
@@ -20,13 +20,14 @@ 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]);
// which square root function should we use?
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ const double outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt
index e610b99..5822f89 100644
--- a/Help/guide/tutorial/Step9/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/CMakeLists.txt
@@ -1,13 +1,12 @@
-cmake_minimum_required(VERSION 3.3)
-project(Tutorial)
+cmake_minimum_required(VERSION 3.10)
+# set the project name and version
+project(Tutorial VERSION 1.0)
+
+# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
-# set the version number
-set(Tutorial_VERSION_MAJOR 1)
-set(Tutorial_VERSION_MINOR 0)
-
# does this system provide the log and exp functions?
include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES "m")
@@ -18,10 +17,7 @@ check_symbol_exists(exp "math.h" HAVE_EXP)
option(USE_MYMATH "Use tutorial provided math implementation" 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?
if(USE_MYMATH)
diff --git a/Help/guide/tutorial/Step9/tutorial.cxx b/Help/guide/tutorial/Step9/tutorial.cxx
index 3286bc8..779fbca 100644
--- a/Help/guide/tutorial/Step9/tutorial.cxx
+++ b/Help/guide/tutorial/Step9/tutorial.cxx
@@ -21,13 +21,14 @@ 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]);
// which square root function should we use?
#ifdef USE_MYMATH
- double outputValue = mysqrt(inputValue);
+ const double outputValue = mysqrt(inputValue);
#else
- double outputValue = sqrt(inputValue);
+ const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index 068499e..df65123 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -5,33 +5,38 @@ CMake Tutorial
.. contents::
-This tutorial provides a step-by-step guide that covers common build
+The CMake 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
+work together in an example project can be very helpful. The tutorial
+documentation and source code for examples can be found in the
+``Help/guide/tutorial`` directory of the CMake source code tree. Each step has
+its own subdirectory containing code that may be used as a starting point. 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:
+For simple projects, a three line CMakeLists file is all that is required.
+This will be the starting point for our tutorial. Create a ``CMakeLists.txt``
+file in the ``Step1`` directory that looks like:
+
+.. code-block:: cmake
+
+ cmake_minimum_required(VERSION 3.10)
+
+ # set the project name
+ project(Tutorial)
+
+ # add the executable
+ add_executable(Tutorial tutorial.cxx)
-.. 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++
+code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be
+used to compute the square root of a number.
Adding a Version Number and Configured Header File
--------------------------------------------------
@@ -40,55 +45,70 @@ The first feature we will add is to provide our executable and project with a
version number. While we could do this exclusively in the source code, using
CMakeLists provides more flexibility.
-To add a version number we modify the CMakeLists file as follows:
+First, modify the CMakeLists file to set the version number.
+
+.. literalinclude:: Step2/CMakeLists.txt
+ :language: cmake
+ :end-before: # specify the C++ standard
+
+Then, configure a header file to pass the version number to the source
+code:
.. literalinclude:: Step2/CMakeLists.txt
:language: cmake
- :start-after: # set the version number
- :end-before: # configure a header file
+ :start-after: # to the source code
+ :end-before: # add the executable
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.
+files. Add the following lines to the end of the CMakeLists file:
.. 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:
+Using your favorite editor, create ``TutorialConfig.h.in`` in the source
+directory with the following contents:
-.. literalinclude:: Step1/TutorialConfig.h.in
+.. literalinclude:: Step2/TutorialConfig.h.in
:language: cmake
When CMake configures this header file the values for
``@Tutorial_VERSION_MAJOR@`` and ``@Tutorial_VERSION_MINOR@`` will be
-replaced by the values from the CMakeLists file. Next we modify
-``tutorial.cxx`` to include the configured header file and to make use of the
-version numbers. The updated source code is listed below.
+replaced.
+
+Next modify ``tutorial.cxx`` to include the configured header file,
+``TutorialConfig.h``.
+
+Finally, let's print out the version number by updating ``tutorial.cxx`` as
+follows:
.. literalinclude:: Step2/tutorial.cxx
:language: c++
- :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.
+ :start-after: {
+ :end-before: // convert input to double
Specify the C++ Standard
-------------------------
-Next let's add some C++11 features to our project. We will need to explicitly
-state in the CMake code that it should use the correct flags. The easiest way
-to enable C++11 support for CMake is by using the ``CMAKE_CXX_STANDARD``
-variable.
+Next let's add some C++11 features to our project by replacing ``atof`` with
+``std::stod`` in ``tutorial.cxx``. At the same time, remove
+``#include <cstdlib>``.
-First, replace ``atof`` with ``std::stod`` in ``tutorial.cxx``.
+.. literalinclude:: Step2/tutorial.cxx
+ :language: c++
+ :start-after: // convert input to double
+ :end-before: // calculate square root
-Then, set the ``CMAKE_CXX_STANDARD`` variable in the CMakeLists file.
+We will need to explicitly state in the CMake code that it should use the
+correct flags. The easiest way to enable support for a specific C++ standard
+in CMake is by using the ``CMAKE_CXX_STANDARD`` variable. For this tutorial,
+set the ``CMAKE_CXX_STANDARD`` variable in the CMakeLists file to 11 and
+``CMAKE_CXX_STANDARD_REQUIRED`` to True:
-Which variable can we set in the CMakeLists file to treat the
-``CMAKE_CXX_STANDARD`` value as a requirement?
+.. literalinclude:: Step2/CMakeLists.txt
+ :language: cmake
+ :end-before: # configure a header file to pass some of the CMake settings
Build and Test
--------------
@@ -96,8 +116,19 @@ Build and Test
Run **cmake** or **cmake-gui** to configure the project and then build it
with your chosen build tool.
-cd to the directory where Tutorial was built (likely the make directory or
-a Debug or Release build configuration subdirectory) and run these commands:
+For example, from the command line we could navigate to the
+``Help/guide/tutorial`` directory of the CMake source code tree and run the
+following commands:
+
+.. code-block:: console
+
+ mkdir Step1_build
+ cd Step1_build
+ cmake ../Step1
+ cmake --build .
+
+Navigate to the directory where Tutorial was built (likely the make directory
+or a Debug or Release build configuration subdirectory) and run these commands:
.. code-block:: console
@@ -152,7 +183,7 @@ file.
.. literalinclude:: Step3/CMakeLists.txt
:language: cmake
:start-after: # should we use our own math functions
- :end-before: # set the version number
+ :end-before: # configure a header file to pass some of the CMake settings
This will show up in the CMake GUI and ccmake with a default value of ON
that can be changed by the user. This setting will be stored in the cache so
@@ -531,7 +562,7 @@ The first step is to update the starting section of the top-level
.. literalinclude:: Step10/CMakeLists.txt
:language: cmake
- :start-after: set(Tutorial_VERSION_MINOR
+ :start-after: set(CMAKE_CXX_STANDARD 14)
:end-before: # add the binary tree
Now that we have made MathFunctions always be used, we will need to update
@@ -609,14 +640,14 @@ So the following code:
.. literalinclude:: Step10/CMakeLists.txt
:language: cmake
- :start-after: project(Tutorial)
- :end-before: # Set the version number
+ :start-after: project(Tutorial VERSION 1.0)
+ :end-before: # control where the static and shared libraries are built so that on windows
Would be replaced with:
.. literalinclude:: Step11/CMakeLists.txt
:language: cmake
- :start-after: project(Tutorial)
+ :start-after: project(Tutorial VERSION 1.0)
:end-before: # add compiler warning flags just when building this project via
@@ -629,7 +660,7 @@ below:
.. literalinclude:: Step11/CMakeLists.txt
:language: cmake
:start-after: # the BUILD_INTERFACE genex
- :end-before: # set the version number
+ :end-before: # control where the static and shared libraries are built so that on windows
Looking at this we see that the warning flags are encapsulated inside a
``BUILD_INTERFACE`` condition. This is done so that consumers of our installed
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 5b8f255..0354666 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1597,7 +1597,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
endfunction()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
- foreach(STP RANGE 1 11)
+ foreach(STP RANGE 2 11)
add_tutorial_test(Step${STP} TRUE)
endforeach()
add_tutorial_test(Complete TRUE)
@@ -2129,8 +2129,8 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
macro(add_test_VSWinCE name generator systemName systemVersion generatorPlatform)
# TODO: Fix the tutorial to make it work in cross compile
# currently the MakeTable is build for target and can not be used on the host
- # This happens in part 5 so we build only part 1-4 of the tutorial
- foreach(STP RANGE 1 4)
+ # This happens in part 5 so we build only through part 4 of the tutorial.
+ foreach(STP RANGE 2 4)
add_test(NAME "TutorialStep${STP}.${name}" COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Help/guide/tutorial/Step${STP}"
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d56a4b16ca6f09d099c2ec832b11708f9b4b9819
commit d56a4b16ca6f09d099c2ec832b11708f9b4b9819
Author: Brad King <brad.king at kitware.com>
AuthorDate: Mon Aug 19 11:41:32 2019 -0400
Commit: Brad King <brad.king at kitware.com>
CommitDate: Mon Aug 19 11:41:32 2019 -0400
Help: Restore installation of top-level index
We removed installation of `Help/index.rst` in commit d2fde94809 (Help:
Add infrastructure for guide-level documentation, 2019-05-30), but the
file is required for `--help-full` to work. Restore installation of the
file and update it to avoid referencing the `Help/guide` directory in
its toctree during processing by `cmRST`.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75ac8bf..5e3d39d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -813,7 +813,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE)
PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
- REGEX "Help/(dev|guide|index.rst)($|/)" EXCLUDE
+ REGEX "Help/(dev|guide)($|/)" EXCLUDE
)
# Install auxiliary files integrating with other tools.
diff --git a/Help/index.rst b/Help/index.rst
index cf1d2f1..cc6cee6 100644
--- a/Help/index.rst
+++ b/Help/index.rst
@@ -44,13 +44,15 @@ Reference Manuals
/manual/cmake-variables.7
/manual/cpack-generators.7
-Guides
-######
+.. only:: not man
-.. toctree::
- :maxdepth: 1
+ Guides
+ ######
+
+ .. toctree::
+ :maxdepth: 1
- /guide/tutorial/index
+ /guide/tutorial/index
.. only:: html or text
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c94069660112f841df3bae66891e05bfc7bad00
commit 3c94069660112f841df3bae66891e05bfc7bad00
Author: Igor Ivanov <artalus-mail at yandex.ru>
AuthorDate: Sat Aug 10 11:41:53 2019 +0300
Commit: Igor Ivanov <artalus-mail at yandex.ru>
CommitDate: Sat Aug 10 11:41:53 2019 +0300
Add --trace-redirect parameter to redirect trace output to a file
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 68d88e7..26ef904 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -238,6 +238,9 @@ Options
Multiple options are allowed.
+``--trace-redirect=<file>``
+ Put cmake in trace mode and redirect trace output to a file instead of stderr.
+
``--warn-uninitialized``
Warn about uninitialized values.
diff --git a/Help/release/dev/trace-redirect.rst b/Help/release/dev/trace-redirect.rst
new file mode 100644
index 0000000..410021e
--- /dev/null
+++ b/Help/release/dev/trace-redirect.rst
@@ -0,0 +1,6 @@
+trace-redirect
+--------------
+
+* :manual:`cmake(1)` gained a ``--trace-redirect=<file>`` command line option
+ that can be used to redirect ``--trace`` output to a file instead
+ of ``stderr``.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 015453a..ea42289 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -23,6 +23,7 @@
#include "cmExpandedCommandArgument.h" // IWYU pragma: keep
#include "cmFileLockPool.h"
#include "cmFunctionBlocker.h"
+#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmGlobalGenerator.h"
@@ -321,7 +322,13 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
msg << " ";
}
msg << ")";
- cmSystemTools::Message(msg.str());
+
+ auto& f = this->GetCMakeInstance()->GetTraceFile();
+ if (f) {
+ f << msg.str() << '\n';
+ } else {
+ cmSystemTools::Message(msg.str());
+ }
}
// Helper class to make sure the call stack is valid.
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index a81b7e4..98dfd21 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -140,6 +140,7 @@ cmake::cmake(Role role, cmState::Mode mode)
, State(cm::make_unique<cmState>())
, Messenger(cm::make_unique<cmMessenger>())
{
+ this->TraceFile.close();
this->State->SetMode(mode);
this->CurrentSnapshot = this->State->CreateBaseSnapshot();
@@ -740,6 +741,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
cmSystemTools::ConvertToUnixSlashes(file);
this->AddTraceSource(file);
this->SetTrace(true);
+ } else if (arg.find("--trace-redirect=", 0) == 0) {
+ std::string file = arg.substr(strlen("--trace-redirect="));
+ cmSystemTools::ConvertToUnixSlashes(file);
+ this->SetTraceFile(file);
+ this->SetTrace(true);
} else if (arg.find("--trace", 0) == 0) {
std::cout << "Running with trace output on.\n";
this->SetTrace(true);
@@ -870,6 +876,20 @@ cmake::LogLevel cmake::StringToLogLevel(const std::string& levelStr)
return (it != levels.cend()) ? it->second : LogLevel::LOG_UNDEFINED;
}
+void cmake::SetTraceFile(const std::string& file)
+{
+ this->TraceFile.close();
+ this->TraceFile.open(file.c_str());
+ if (!this->TraceFile) {
+ std::stringstream ss;
+ ss << "Error opening trace file " << file << ": "
+ << cmSystemTools::GetLastSystemError();
+ cmSystemTools::Error(ss.str());
+ return;
+ }
+ std::cout << "Trace will be written to " << file << "\n";
+}
+
void cmake::SetDirectoriesFromFile(const std::string& arg)
{
// Check if the argument refers to a CMakeCache.txt or
diff --git a/Source/cmake.h b/Source/cmake.h
index 92494ae..fdcf50f 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -13,6 +13,7 @@
#include <unordered_set>
#include <vector>
+#include "cmGeneratedFileStream.h"
#include "cmInstalledFile.h"
#include "cmListFileCache.h"
#include "cmMessageType.h"
@@ -401,6 +402,9 @@ public:
{
return this->TraceOnlyThisSources;
}
+ cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; }
+ void SetTraceFile(std::string const& file);
+
bool GetWarnUninitialized() { return this->WarnUninitialized; }
void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
bool GetWarnUnused() { return this->WarnUnused; }
@@ -547,6 +551,7 @@ private:
bool DebugOutput = false;
bool Trace = false;
bool TraceExpand = false;
+ cmGeneratedFileStream TraceFile;
bool WarnUninitialized = false;
bool WarnUnused = false;
bool WarnUnusedCli = true;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 10a6825..1fe6439 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -80,6 +80,8 @@ const char* cmDocumentationOptions[][2] = {
{ "--trace-expand", "Put cmake in trace mode with variable expansion." },
{ "--trace-source=<file>",
"Trace only this CMake file/module. Multiple options allowed." },
+ { "--trace-redirect=<file>",
+ "Redirect trace output to a file instead of stderr." },
{ "--warn-uninitialized", "Warn about uninitialized values." },
{ "--warn-unused-vars", "Warn about unused variables." },
{ "--no-warn-unused-cli", "Don't warn about command line options." },
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index 4e19871..dd49423 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -484,6 +484,14 @@ set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized)
run_cmake(trace-expand-warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
+set(RunCMake_TEST_OPTIONS --trace-redirect=${RunCMake_BINARY_DIR}/redirected.trace)
+run_cmake(trace-redirect)
+unset(RunCMake_TEST_OPTIONS)
+
+set(RunCMake_TEST_OPTIONS --trace-redirect=/no/such/file.txt)
+run_cmake(trace-redirect-nofile)
+unset(RunCMake_TEST_OPTIONS)
+
set(RunCMake_TEST_OPTIONS -Wno-deprecated --warn-uninitialized)
run_cmake(warn-uninitialized)
unset(RunCMake_TEST_OPTIONS)
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-check.cmake b/Tests/RunCMake/CommandLine/trace-redirect-check.cmake
new file mode 100644
index 0000000..1ee0e0d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-check.cmake
@@ -0,0 +1,13 @@
+file(READ ${RunCMake_SOURCE_DIR}/trace-stderr.txt expected_content)
+string(REGEX REPLACE "\n+$" "" expected_content "${expected_content}")
+
+file(READ ${RunCMake_BINARY_DIR}/redirected.trace actual_content)
+string(REGEX REPLACE "\r\n" "\n" actual_content "${actual_content}")
+string(REGEX REPLACE "\n+$" "" actual_content "${actual_content}")
+if(NOT "${actual_content}" MATCHES "${expected_content}")
+ set(RunCMake_TEST_FAILED
+ "Trace file content does not match that expected."
+ "Expected to match:\n${expected_content}\n"
+ "Actual content:\n${actual_content}\n"
+ )
+endif()
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt b/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt b/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt
new file mode 100644
index 0000000..edb0c8e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: Error opening trace file /no/such/file.txt: .+$
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake b/Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake
new file mode 100644
index 0000000..e69de29
diff --git a/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt b/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt
new file mode 100644
index 0000000..775f2b5
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt
@@ -0,0 +1 @@
+^.*Trace will be written to .+redirected.trace.*$
diff --git a/Tests/RunCMake/CommandLine/trace-redirect.cmake b/Tests/RunCMake/CommandLine/trace-redirect.cmake
new file mode 100644
index 0000000..e69de29
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9460501ad7353e6eecdf42d56568c1f909f64e27
commit 9460501ad7353e6eecdf42d56568c1f909f64e27
Author: Robert Maynard <robert.maynard at kitware.com>
AuthorDate: Fri Aug 9 14:49:34 2019 -0400
Commit: Robert Maynard <robert.maynard at kitware.com>
CommitDate: Fri Aug 9 14:54:16 2019 -0400
FindOpenACC: Provide a Fortran snippet that compiles with gfortran
The original Fortran snippet would fail to compile with the error
message of:
```
return 0;
1
Error: Alternate RETURN statement at (1) is only allowed within a SUBROUTINE
```
We solve this by removing the early termination logic.
diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake
index dc8321d..1f0238e 100644
--- a/Modules/FindOpenACC.cmake
+++ b/Modules/FindOpenACC.cmake
@@ -60,9 +60,7 @@ int main(){
set(OpenACC_Fortran_TEST_SOURCE
"
program test
-#ifdef _OPENACC
- return 0;
-#else
+#ifndef _OPENACC
breaks_on_purpose
#endif
endprogram test
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 2 +-
Help/guide/tutorial/Complete/CMakeLists.txt | 15 +-
Help/guide/tutorial/Complete/CTestConfig.cmake | 7 +
.../tutorial/Complete/MathFunctions/CMakeLists.txt | 14 +-
.../tutorial/Complete/MathFunctions/mysqrt.cxx | 13 +-
Help/guide/tutorial/Complete/TutorialConfig.h.in | 2 +-
Help/guide/tutorial/Complete/tutorial.cxx | 5 +-
Help/guide/tutorial/Consumer/CMakeLists.txt | 2 +-
Help/guide/tutorial/MultiPackage/CMakeLists.txt | 16 +-
.../MultiPackage/MathFunctions/CMakeLists.txt | 13 +-
.../tutorial/MultiPackage/MathFunctions/mysqrt.cxx | 10 +-
Help/guide/tutorial/MultiPackage/tutorial.cxx | 2 +-
Help/guide/tutorial/Step1/CMakeLists.txt | 3 -
Help/guide/tutorial/Step1/TutorialConfig.h.in | 3 -
Help/guide/tutorial/Step1/tutorial.cxx | 6 +-
Help/guide/tutorial/Step10/CMakeLists.txt | 20 +-
Help/guide/tutorial/Step10/CTestConfig.cmake | 7 +
.../tutorial/Step10/MathFunctions/CMakeLists.txt | 12 +-
.../guide/tutorial/Step10/MathFunctions/mysqrt.cxx | 13 +-
Help/guide/tutorial/Step10/TutorialConfig.h.in | 2 +-
Help/guide/tutorial/Step10/tutorial.cxx | 3 +-
Help/guide/tutorial/Step11/CMakeLists.txt | 15 +-
Help/guide/tutorial/Step11/CTestConfig.cmake | 7 +
.../tutorial/Step11/MathFunctions/CMakeLists.txt | 13 +-
.../guide/tutorial/Step11/MathFunctions/mysqrt.cxx | 13 +-
Help/guide/tutorial/Step11/TutorialConfig.h.in | 2 +-
Help/guide/tutorial/Step11/tutorial.cxx | 4 +-
Help/guide/tutorial/Step2/CMakeLists.txt | 16 +-
.../tutorial/Step2/MathFunctions/CMakeLists.txt | 1 -
Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx | 1 -
Help/guide/tutorial/Step2/tutorial.cxx | 6 +-
Help/guide/tutorial/Step3/CMakeLists.txt | 22 +-
Help/guide/tutorial/Step3/tutorial.cxx | 7 +-
Help/guide/tutorial/Step4/CMakeLists.txt | 20 +-
Help/guide/tutorial/Step4/tutorial.cxx | 7 +-
Help/guide/tutorial/Step5/CMakeLists.txt | 18 +-
Help/guide/tutorial/Step5/tutorial.cxx | 7 +-
Help/guide/tutorial/Step6/CMakeLists.txt | 24 +-
.../tutorial/Step6/MathFunctions/CMakeLists.txt | 14 +-
Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx | 5 +-
Help/guide/tutorial/Step6/TutorialConfig.h.in | 4 -
Help/guide/tutorial/Step6/tutorial.cxx | 7 +-
Help/guide/tutorial/Step7/CMakeLists.txt | 28 +-
.../tutorial/Step7/MathFunctions/CMakeLists.txt | 3 +-
Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx | 4 +-
Help/guide/tutorial/Step7/TutorialConfig.h.in | 4 -
Help/guide/tutorial/Step7/tutorial.cxx | 7 +-
Help/guide/tutorial/Step8/CMakeLists.txt | 28 +-
.../tutorial/Step8/MathFunctions/CMakeLists.txt | 3 +-
Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx | 14 +-
Help/guide/tutorial/Step8/TutorialConfig.h.in | 4 -
Help/guide/tutorial/Step8/tutorial.cxx | 7 +-
Help/guide/tutorial/Step9/CMakeLists.txt | 27 +-
Help/guide/tutorial/Step9/CTestConfig.cmake | 8 -
.../tutorial/Step9/MathFunctions/CMakeLists.txt | 9 -
Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx | 13 +-
Help/guide/tutorial/Step9/TutorialConfig.h.in | 3 +-
Help/guide/tutorial/Step9/tutorial.cxx | 8 +-
Help/guide/tutorial/index.rst | 411 +++++++++++++--------
Help/index.rst | 12 +-
Help/manual/cmake.1.rst | 3 +
Help/release/dev/trace-redirect.rst | 6 +
Modules/FindOpenACC.cmake | 32 +-
Source/cmMakefile.cxx | 9 +-
Source/cmake.cxx | 20 +
Source/cmake.h | 5 +
Source/cmakemain.cxx | 2 +
Tests/CMakeLists.txt | 7 +-
Tests/FindOpenACC/CMakeLists.txt | 20 +
Tests/FindOpenACC/CTest/CMakeLists.txt | 13 +
Tests/FindOpenACC/CTest/main.c | 44 +++
Tests/FindOpenACC/CXXTest/CMakeLists.txt | 13 +
Tests/FindOpenACC/CXXTest/main.cxx | 43 +++
Tests/FindOpenACC/FortranTest/CMakeLists.txt | 11 +
Tests/FindOpenACC/FortranTest/main.f90 | 9 +
Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 8 +
.../CommandLine/trace-redirect-check.cmake | 13 +
.../trace-redirect-nofile-result.txt} | 0
.../CommandLine/trace-redirect-nofile-stderr.txt | 1 +
.../CommandLine/trace-redirect-nofile.cmake} | 0
.../RunCMake/CommandLine/trace-redirect-stdout.txt | 1 +
.../CommandLine/trace-redirect.cmake} | 0
82 files changed, 719 insertions(+), 517 deletions(-)
create mode 100644 Help/guide/tutorial/Complete/CTestConfig.cmake
delete mode 100644 Help/guide/tutorial/Step1/CMakeLists.txt
delete mode 100644 Help/guide/tutorial/Step1/TutorialConfig.h.in
create mode 100644 Help/guide/tutorial/Step10/CTestConfig.cmake
create mode 100644 Help/guide/tutorial/Step11/CTestConfig.cmake
delete mode 100644 Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt
create mode 100644 Help/release/dev/trace-redirect.rst
create mode 100644 Tests/FindOpenACC/CMakeLists.txt
create mode 100644 Tests/FindOpenACC/CTest/CMakeLists.txt
create mode 100644 Tests/FindOpenACC/CTest/main.c
create mode 100644 Tests/FindOpenACC/CXXTest/CMakeLists.txt
create mode 100644 Tests/FindOpenACC/CXXTest/main.cxx
create mode 100644 Tests/FindOpenACC/FortranTest/CMakeLists.txt
create mode 100644 Tests/FindOpenACC/FortranTest/main.f90
create mode 100644 Tests/RunCMake/CommandLine/trace-redirect-check.cmake
copy Tests/RunCMake/{while/MissingArgument-result.txt => CommandLine/trace-redirect-nofile-result.txt} (100%)
create mode 100644 Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt
copy Tests/{Wrapping/vtkIncluded.cxx => RunCMake/CommandLine/trace-redirect-nofile.cmake} (100%)
create mode 100644 Tests/RunCMake/CommandLine/trace-redirect-stdout.txt
copy Tests/{Wrapping/vtkIncluded.cxx => RunCMake/CommandLine/trace-redirect.cmake} (100%)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list