summaryrefslogtreecommitdiffstats
path: root/Help/guide/tutorial/Complete
diff options
context:
space:
mode:
Diffstat (limited to 'Help/guide/tutorial/Complete')
-rw-r--r--Help/guide/tutorial/Complete/CMakeLists.txt15
-rw-r--r--Help/guide/tutorial/Complete/CTestConfig.cmake7
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt14
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx13
-rw-r--r--Help/guide/tutorial/Complete/TutorialConfig.h.in2
-rw-r--r--Help/guide/tutorial/Complete/tutorial.cxx5
6 files changed, 20 insertions, 36 deletions
diff --git a/Help/guide/tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt
index 4541392..eca79d9 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,17 +30,14 @@ 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)
# 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/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/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
index c12955d..dfa84c9 100644
--- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
@@ -13,11 +13,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)
@@ -41,18 +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")
- 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 96d9421..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"
- << 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/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/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;