diff options
author | Brad King <brad.king@kitware.com> | 2022-06-01 17:30:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-06-01 17:57:47 (GMT) |
commit | 5c84eca2108c8b47a74391c732710c67e23adfa3 (patch) | |
tree | 2745fa69ace38875fcddc451e503d18be0a9ca0b /Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx | |
parent | 18be0f926789ad47d70e54e57f34b2ee4f297307 (diff) | |
download | CMake-5c84eca2108c8b47a74391c732710c67e23adfa3.zip CMake-5c84eca2108c8b47a74391c732710c67e23adfa3.tar.gz CMake-5c84eca2108c8b47a74391c732710c67e23adfa3.tar.bz2 |
Tutorial: Simplify logic checking for cmath functions
Since commit 07223c5c27 (Tutorial: Update Step 5 to work on Windows,
2020-02-18, v3.18.0-rc1~655^2) the logic does not work on non-Windows
platforms when cmake is re-run on an existing build tree. It is also
more complicated than we'd like for a tutorial example. Avoid the need
to consider the `m` library case by performing the check as C++.
Since `check_cxx_symbol_exists` cannot handle overloaded functions
like `exp` and `log`, check with `check_cxx_source_compiles` instead.
This also presents a more general-purpose example in the tutorial.
Fixes: #23524
Diffstat (limited to 'Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx')
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx index 0637063..7eecd26 100644 --- a/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx @@ -12,7 +12,7 @@ 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); + double result = std::exp(std::log(x) * 0.5); std::cout << "Computing sqrt of " << x << " to be " << result << " using log and exp" << std::endl; #else |