diff options
author | Brad King <brad.king@kitware.com> | 2019-08-20 13:16:35 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-08-20 13:19:22 (GMT) |
commit | b80417f0fd1491d1c0f5d57019b47d4c13729545 (patch) | |
tree | e55ae56966bd154cec46c56184a9f4a6f1b09d7e /Help/guide/tutorial/Step6/MathFunctions | |
parent | 8c1d3e3b79fb921bfada3b19e6bb4115da4a4e6e (diff) | |
parent | 6f6a32a0f601688da24e1737509a0b6e1ed4f63f (diff) | |
download | CMake-b80417f0fd1491d1c0f5d57019b47d4c13729545.zip CMake-b80417f0fd1491d1c0f5d57019b47d4c13729545.tar.gz CMake-b80417f0fd1491d1c0f5d57019b47d4c13729545.tar.bz2 |
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@kitware.com>
Merge-request: !3528
Diffstat (limited to 'Help/guide/tutorial/Step6/MathFunctions')
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx | 5 |
2 files changed, 13 insertions, 6 deletions
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; |