From f49ab8e4a9012cb2fd6554464084d291bac83029 Mon Sep 17 00:00:00 2001 From: vitaut Date: Thu, 19 Mar 2015 07:34:50 -0700 Subject: [PATCH] Detect broken cmath --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad689688..1844680b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,17 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-std=c++11 HAVE_STD_CPP11_FLAG) if (HAVE_STD_CPP11_FLAG) - set(CPP11_FLAG -std=c++11) + # Check if including cmath works with -std=c++11 and -O3. + # It may not in MinGW due to bug http://ehc.ac/p/mingw/bugs/2250/. + set(CMAKE_REQUIRED_FLAGS "-std=c++11 -O3") + check_cxx_source_compiles(" + #include + int main() {}" FMT_CPP11_CMATH) + if (FMT_CPP11_CMATH) + set(CPP11_FLAG -std=c++11) + else () + set(CMAKE_REQUIRED_FLAGS "") + endif () else () check_cxx_compiler_flag(-std=c++0x HAVE_STD_CPP0X_FLAG) if (HAVE_STD_CPP0X_FLAG)