From dc0a337aeae304922e89d5dd868cf09e92b1f56d Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Tue, 5 Jul 2016 21:41:49 +0200 Subject: [PATCH] CMake: Check if we need libm for round() Fixes: https://github.com/awesomeWM/awesome/issues/969 Signed-off-by: Uli Schlachter --- awesomeConfig.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 659d019ab..1771daa5e 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -199,6 +199,20 @@ else() message(STATUS "checking for execinfo -- not found") endif() +# Do we need libm for round()? +check_function_exists(round HAS_ROUND_WITHOUT_LIBM) +if(NOT HAS_ROUND_WITHOUT_LIBM) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) + set(AWESOME_REQUIRED_LDFLAGS ${AWESOME_REQUIRED_LDFLAGS} m) + check_function_exists(round HAS_ROUND_WITH_LIBM) + if(NOT HAS_ROUND_WITH_LIBM) + message(FATAL_ERROR "Did not find round()") + endif() + message(STATUS "checking for round -- in libm") +else() + message(STATUS "checking for round -- builtin") +endif() + set(AWESOME_REQUIRED_LDFLAGS ${AWESOME_COMMON_REQUIRED_LDFLAGS} ${AWESOME_REQUIRED_LDFLAGS}