mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
make rocksdb cmake checks less verbose on repeat
* fix FindLZ4 to follow convention (LIBRARIES, not LIBRARY) * remove redundant checks from rocksdb/CMakeLists.txt * put all checks through the same macro that uniformly checks for a package, prints the message, adds definition
This commit is contained in:
parent
2ed415765a
commit
6d3747a294
4 changed files with 42 additions and 61 deletions
|
@ -1,9 +1,9 @@
|
|||
find_path(LZ4_INCLUDE_DIR NAMES lz4.h)
|
||||
find_library(LZ4_LIBRARY NAMES lz4)
|
||||
find_library(LZ4_LIBRARIES NAMES lz4)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||
LZ4 DEFAULT_MSG
|
||||
LZ4_LIBRARY LZ4_INCLUDE_DIR)
|
||||
LZ4_LIBRARIES LZ4_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY)
|
||||
mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARIES)
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
# ZSTD_LIBRARIES - List of libraries when using zstd.
|
||||
# ZSTD_FOUND - True if zstd found.
|
||||
|
||||
if (DEFINED ZSTD_LIBRARIES)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_path(ZSTD_INCLUDE_DIR
|
||||
NAMES zstd.h
|
||||
HINTS ${ZSTD_ROOT_DIR}/include)
|
||||
|
@ -18,7 +14,7 @@ find_library(ZSTD_LIBRARIES
|
|||
HINTS ${ZSTD_ROOT_DIR}/lib)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(zstd DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIR)
|
||||
find_package_handle_standard_args(ZSTD DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(
|
||||
ZSTD_LIBRARIES
|
||||
|
|
|
@ -188,9 +188,6 @@ endif()
|
|||
|
||||
|
||||
TARGET_LINK_LIBRARIES(rocksdb rocksdb_aux_lib)
|
||||
FIND_LIBRARY(LZ4_LIBRARY
|
||||
NAMES liblz4${PIC_EXT}.a lz4
|
||||
HINTS ${WITH_LZ4}/lib)
|
||||
|
||||
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
|
||||
|
@ -273,13 +270,6 @@ IF(MSVC)
|
|||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Enable ZSTD if available. Upstream rocksdb cmake will use WITH_ZSTD and set
|
||||
# defines within their code.
|
||||
FIND_PACKAGE(zstd)
|
||||
IF (ZSTD_FOUND)
|
||||
SET(WITH_ZSTD ON)
|
||||
ENDIF()
|
||||
|
||||
IF(GIT_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb/.git)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
|
|
|
@ -35,52 +35,47 @@ endif()
|
|||
|
||||
# Optional compression libraries.
|
||||
|
||||
foreach(compression_lib LZ4 BZip2 ZSTD snappy)
|
||||
FIND_PACKAGE(${compression_lib})
|
||||
|
||||
SET(WITH_ROCKSDB_${compression_lib} AUTO CACHE STRING
|
||||
"Build RocksDB with ${compression_lib} compression. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'")
|
||||
|
||||
if(${WITH_ROCKSDB_${compression_lib}} STREQUAL "ON" AND NOT ${${compression_lib}_FOUND})
|
||||
MESSAGE(FATAL_ERROR
|
||||
"${compression_lib} library was not found, but WITH_ROCKSDB_${compression_lib} option is ON.\
|
||||
Either set WITH_ROCKSDB_${compression_lib} to OFF, or make sure ${compression_lib} is installed")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(LZ4_FOUND AND (NOT WITH_ROCKSDB_LZ4 STREQUAL "OFF"))
|
||||
add_definitions(-DLZ4)
|
||||
include_directories(${LZ4_INCLUDE_DIR})
|
||||
list(APPEND THIRDPARTY_LIBS ${LZ4_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(BZIP2_FOUND AND (NOT WITH_ROCKSDB_BZip2 STREQUAL "OFF"))
|
||||
add_definitions(-DBZIP2)
|
||||
include_directories(${BZIP2_INCLUDE_DIR})
|
||||
list(APPEND THIRDPARTY_LIBS ${BZIP2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(SNAPPY_FOUND AND (NOT WITH_ROCKSDB_snappy STREQUAL "OFF"))
|
||||
add_definitions(-DSNAPPY)
|
||||
include_directories(${snappy_INCLUDE_DIR})
|
||||
list(APPEND THIRDPARTY_LIBS ${snappy_LIBRARIES})
|
||||
endif()
|
||||
|
||||
include(CheckFunctionExists)
|
||||
if(ZSTD_FOUND AND (NOT WITH_ROCKSDB_ZSTD STREQUAL "OFF"))
|
||||
SET(CMAKE_REQUIRED_LIBRARIES zstd)
|
||||
CHECK_FUNCTION_EXISTS(ZDICT_trainFromBuffer ZSTD_VALID)
|
||||
UNSET(CMAKE_REQUIRED_LIBRARIES)
|
||||
if (WITH_ROCKSDB_ZSTD STREQUAL "ON" AND NOT ZSTD_VALID)
|
||||
macro(check_lib package var)
|
||||
STRING(TOUPPER ${package} PACKAGE_NAME)
|
||||
SET(WITH_ROCKSDB_${package} AUTO CACHE STRING
|
||||
"Build RocksDB with ${package} compression. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'")
|
||||
|
||||
IF (NOT ${WITH_ROCKSDB_${package}} STREQUAL "OFF")
|
||||
FIND_PACKAGE(${package} QUIET)
|
||||
IF (${${PACKAGE_NAME}_FOUND})
|
||||
IF(${ARGC} GREATER 2)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${${var}_LIBRARIES})
|
||||
CHECK_FUNCTION_EXISTS(${ARGV2} ${var}_VALID)
|
||||
UNSET(CMAKE_REQUIRED_LIBRARIES)
|
||||
ELSE()
|
||||
SET(${var}_VALID TRUE)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(${${var}_VALID})
|
||||
MESSAGE_ONCE(rocksdb_${var} "Found ${package}: ${${var}_LIBRARIES}")
|
||||
add_definitions(-D${PACKAGE_NAME})
|
||||
include_directories(${${var}_INCLUDE_DIR})
|
||||
list(APPEND THIRDPARTY_LIBS ${${var}_LIBRARIES})
|
||||
ELSEIF(${${PACKAGE_NAME}_FOUND})
|
||||
MESSAGE_ONCE(rocksdb_${var} "Found unusable ${package}: ${${var}_LIBRARIES} [${ARGV2}]")
|
||||
ELSE()
|
||||
MESSAGE_ONCE(rocksdb_${var} "Could NOT find ${package}")
|
||||
ENDIF()
|
||||
|
||||
IF (${WITH_ROCKSDB_${package}} STREQUAL "ON" AND NOT ${${PACKAGE_NAME}_FOUND})
|
||||
MESSAGE(FATAL_ERROR
|
||||
"WITH_ROCKSDB_ZSTD is ON and ZSTD library was found, but the version needs to be >= 1.1.3")
|
||||
"${package} library was not found, but WITH_ROCKSDB_${package} option is ON.\
|
||||
Either set WITH_ROCKSDB_${package} to OFF, or make sure ${package} is installed")
|
||||
endif()
|
||||
if (ZSTD_VALID)
|
||||
add_definitions(-DZSTD)
|
||||
include_directories(${ZSTD_INCLUDE_DIR})
|
||||
list(APPEND THIRDPARTY_LIBS ${ZSTD_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
check_lib(LZ4 LZ4)
|
||||
check_lib(BZip2 BZIP2)
|
||||
check_lib(snappy snappy) # rocksdb/cmake/modules/Findsnappy.cmake violates the convention
|
||||
check_lib(ZSTD ZSTD ZDICT_trainFromBuffer)
|
||||
|
||||
add_definitions(-DZLIB)
|
||||
list(APPEND THIRDPARTY_LIBS ${ZLIB_LIBRARY})
|
||||
|
|
Loading…
Reference in a new issue