cmake: use a different variable for testing with and without libm

CMake seems to cache the result when using the same variable, at least
with some versions, so previously systems requiring libm for log2 may
not have worked as expected.
This commit is contained in:
Evan Nemerson 2016-08-04 18:51:20 -07:00
parent c1ec7ba292
commit fe0e153cb8

View File

@ -48,17 +48,17 @@ include(CheckFunctionExists)
set(LIBM_LIBRARY)
CHECK_FUNCTION_EXISTS(log2 LOG2_RES)
if(NOT LOG2_RES)
unset(LOG2_RES)
set(orig_req_libs "${CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};m")
CHECK_FUNCTION_EXISTS(log2 LOG2_RES)
if(LOG2_RES)
CHECK_FUNCTION_EXISTS(log2 LOG2_LIBM_RES)
if(LOG2_LIBM_RES)
set(LIBM_LIBRARY "m")
else()
message(FATAL_ERROR "log2() not found")
endif()
set(CMAKE_REQUIRED_LIBRARIES "${orig_req_libs}")
unset(LOG2_LIBM_RES)
unset(orig_req_libs)
endif()
unset(LOG2_RES)