diff options
author | Brad King <brad.king@kitware.com> | 2022-06-02 13:20:52 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-06-02 13:21:06 (GMT) |
commit | dbb6e04b5fe45c413fb3a06b52ffceb5e86bf60c (patch) | |
tree | 24135a7724cfe50b036521f67ebb1d878d827ee7 /Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt | |
parent | 4c9aa6c4256bc78ffd4c5fb3e7fe8adc6533dc46 (diff) | |
parent | 5c84eca2108c8b47a74391c732710c67e23adfa3 (diff) | |
download | CMake-dbb6e04b5fe45c413fb3a06b52ffceb5e86bf60c.zip CMake-dbb6e04b5fe45c413fb3a06b52ffceb5e86bf60c.tar.gz CMake-dbb6e04b5fe45c413fb3a06b52ffceb5e86bf60c.tar.bz2 |
Merge topic 'tutorial-cmath'
5c84eca210 Tutorial: Simplify logic checking for cmath functions
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7314
Diffstat (limited to 'Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt')
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt index f64c6ac..42e098a 100644 --- a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt @@ -7,19 +7,21 @@ target_include_directories(MathFunctions ) # does this system provide the log and exp functions? -include(CheckSymbolExists) -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) -if(NOT (HAVE_LOG AND HAVE_EXP)) - unset(HAVE_LOG CACHE) - unset(HAVE_EXP CACHE) - 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_link_libraries(MathFunctions PRIVATE m) - endif() -endif() +include(CheckCXXSourceCompiles) +check_cxx_source_compiles(" + #include <cmath> + int main() { + std::log(1.0); + return 0; + } +" HAVE_LOG) +check_cxx_source_compiles(" + #include <cmath> + int main() { + std::exp(1.0); + return 0; + } +" HAVE_EXP) # add compile definitions if(HAVE_LOG AND HAVE_EXP) |