summaryrefslogtreecommitdiffstats
path: root/Help/guide/tutorial/Step10
diff options
context:
space:
mode:
Diffstat (limited to 'Help/guide/tutorial/Step10')
-rw-r--r--Help/guide/tutorial/Step10/CMakeLists.txt20
-rw-r--r--Help/guide/tutorial/Step10/CTestConfig.cmake7
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt12
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx13
-rw-r--r--Help/guide/tutorial/Step10/TutorialConfig.h.in2
-rw-r--r--Help/guide/tutorial/Step10/tutorial.cxx3
6 files changed, 21 insertions, 36 deletions
diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt
index 25bc0c1..34ae70c 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,17 +16,14 @@ 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)
# 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
@@ -42,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/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
index aafd090..e0c0621 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
@@ -11,11 +11,7 @@ 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)
+ target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
# first we add the executable that generates the table
add_executable(MakeTable MakeTable.cxx)
@@ -43,12 +39,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/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx
index 96d9421..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"
- << 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/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/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);