Skip to content

Commit

Permalink
simplify log2 check; currently we rely more on compiler than build sy…
Browse files Browse the repository at this point in the history
…stem

PiperOrigin-RevId: 598794971
  • Loading branch information
eustas authored and copybara-github committed Jan 16, 2024
1 parent 02458f3 commit adbc354
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)
CHECK_LIBRARY_EXISTS(m log2 "" HAVE_LIB_M)
if(HAVE_LIB_M)
set(LIBM_LIBRARY "m")
endif()
unset(LOG2_RES)

set(BROTLI_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/c/include")
mark_as_advanced(BROTLI_INCLUDE_DIRS)
Expand Down

0 comments on commit adbc354

Please sign in to comment.