CMakeLists: Fix detection of libm

Only use libm on Unix and Unix-like systems, except for Apple (where
it's unnecessary), and BeOS and Haiku (where it's unavailable).

Avoid searching for libm at explicit locations. They may be incorrect,
especially for cross-platform builds.
This commit is contained in:
Cosmin Truta 2018-11-17 21:31:55 -05:00
parent a54a0562c5
commit ee7967eea4

View File

@ -59,16 +59,10 @@ if(NOT PNG_BUILD_ZLIB)
include_directories(${ZLIB_INCLUDE_DIR}) include_directories(${ZLIB_INCLUDE_DIR})
endif() endif()
if(NOT WIN32) if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
find_library(M_LIBRARY find_library(M_LIBRARY m)
NAMES m
PATHS /usr/lib /usr/local/lib)
if(NOT M_LIBRARY)
message(STATUS "math lib 'libm' not found; floating point support disabled")
set(M_LIBRARY "")
endif()
else() else()
# not needed on windows # libm is not needed and/or not available
set(M_LIBRARY "") set(M_LIBRARY "")
endif() endif()