aboutsummaryrefslogtreecommitdiff
path: root/cmake/FindStandardMathLibrary.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/FindStandardMathLibrary.cmake')
-rw-r--r--cmake/FindStandardMathLibrary.cmake10
1 files changed, 8 insertions, 2 deletions
diff --git a/cmake/FindStandardMathLibrary.cmake b/cmake/FindStandardMathLibrary.cmake
index 711b0e4b4..1d1e5b3a9 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.
@@ -17,10 +18,15 @@ include(CheckCXXSourceCompiles)
# a little test program for c++ math functions.
# 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() { std::sin(0.0); std::log(0.0f); }")
+"
+#include<cmath>
+int main(int argc, char **){
+ return int(std::sin(double(argc)) + std::log(double(argc)));
+}")
# first try compiling/linking the test program without any linker flags