diff options
author | Susi Lehtola <susi.lehtola@gmail.com> | 2020-10-24 06:16:50 +0000 |
---|---|---|
committer | David Tellenbach <david.tellenbach@me.com> | 2020-10-24 06:16:50 +0000 |
commit | 09f595a269b43896b4de400447a2e253fc87d4d3 (patch) | |
tree | aebd3dede6ace72d76b6a7f13142a34d4118d6fa | |
parent | 28aef8e816faadc0e51afbfe3fa91f10f477535d (diff) |
Make sure compiler does not optimize away calls to math functions
-rw-r--r-- | cmake/FindStandardMathLibrary.cmake | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cmake/FindStandardMathLibrary.cmake b/cmake/FindStandardMathLibrary.cmake index fc4728a82..b174cbb4f 100644 --- a/cmake/FindStandardMathLibrary.cmake +++ b/cmake/FindStandardMathLibrary.cmake @@ -10,6 +10,7 @@ # pass the "-lm" linker flag. # # Copyright (c) 2010 Benoit Jacob <jacob.benoit.1@gmail.com> +# 2020 Susi Lehtola <susi.lehtola@gmail.com> # Redistribution and use is allowed according to the terms of the 2-clause BSD license. @@ -19,9 +20,15 @@ include(CheckCXXSourceCompiles) # notice the std:: is required on some platforms such as QNX # notice the (void) is required if -Wall (-Wunused-value) is added to CMAKE_CXX_FLAG +# We read in the arguments from standard input to avoid the compiler optimizing away the calls set(find_standard_math_library_test_program -"#include<cmath> -int main() { (void)std::sin(0.0); (void)std::log(0.0f); }") +" +#include<cmath> +int main(int argc, char **argv) { + (void)std::sin(argc)); + (void)std::log(argc)); + return 0; +}") # first try compiling/linking the test program without any linker flags |