simplify log2 check; currently we rely more on compiler than build system

PiperOrigin-RevId: 598794971
This commit is contained in:
Evgenii Kliuchnikov 2024-01-16 04:01:35 -08:00 committed by Copybara-Service
parent 02458f3443
commit adbc354d23

View File

@ -78,27 +78,12 @@ if (ENABLE_SANITIZER)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
endif ()
include(CheckFunctionExists)
include(CheckLibraryExists)
set(LIBM_LIBRARY)
CHECK_FUNCTION_EXISTS(log2 LOG2_RES)
if(NOT LOG2_RES)
set(_ORIG_REQ_LIBS "${CMAKE_REQUIRED_LIBRARIES}")
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};m")
CHECK_FUNCTION_EXISTS(log2 LOG2_LIBM_RES)
if(LOG2_LIBM_RES)
CHECK_LIBRARY_EXISTS(m log2 "" HAVE_LIB_M)
if(HAVE_LIB_M)
set(LIBM_LIBRARY "m")
add_definitions(-DBROTLI_HAVE_LOG2=1)
else()
add_definitions(-DBROTLI_HAVE_LOG2=0)
endif()
set(CMAKE_REQUIRED_LIBRARIES "${_ORIG_REQ_LIBS}")
unset(LOG2_LIBM_RES)
unset(_ORIG_REQ_LIBS)
else()
add_definitions(-DBROTLI_HAVE_LOG2=1)
endif()
unset(LOG2_RES)
set(BROTLI_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/c/include")
mark_as_advanced(BROTLI_INCLUDE_DIRS)