cmake: cmake related cleanups (#5662)
Summary: - cmake: use the builtin FindBzip2.cmake from CMake - cmake: require CMake v3.5.1 - cmake: add imported target for 3rd party libraries - cmake: extract ReadVersion.cmake out and refactor it Pull Request resolved: https://github.com/facebook/rocksdb/pull/5662 Differential Revision: D16660974 Pulled By: maysamyabandeh fbshipit-source-id: 681594910e74253251fe14ad0befc41a4d0f4fd4main
parent
f4a616ebf9
commit
cc9fa7fcdb
@ -1,21 +1,29 @@ |
||||
# - Find JeMalloc library |
||||
# Find the native JeMalloc includes and library |
||||
# |
||||
# JEMALLOC_INCLUDE_DIR - where to find jemalloc.h, etc. |
||||
# JEMALLOC_LIBRARIES - List of libraries when using jemalloc. |
||||
# JEMALLOC_FOUND - True if jemalloc found. |
||||
# JeMalloc_INCLUDE_DIRS - where to find jemalloc.h, etc. |
||||
# JeMalloc_LIBRARIES - List of libraries when using jemalloc. |
||||
# JeMalloc_FOUND - True if jemalloc found. |
||||
|
||||
find_path(JEMALLOC_INCLUDE_DIR |
||||
find_path(JeMalloc_INCLUDE_DIRS |
||||
NAMES jemalloc/jemalloc.h |
||||
HINTS ${JEMALLOC_ROOT_DIR}/include) |
||||
|
||||
find_library(JEMALLOC_LIBRARIES |
||||
find_library(JeMalloc_LIBRARIES |
||||
NAMES jemalloc |
||||
HINTS ${JEMALLOC_ROOT_DIR}/lib) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(jemalloc DEFAULT_MSG JEMALLOC_LIBRARIES JEMALLOC_INCLUDE_DIR) |
||||
find_package_handle_standard_args(JeMalloc DEFAULT_MSG JeMalloc_LIBRARIES JeMalloc_INCLUDE_DIRS) |
||||
|
||||
mark_as_advanced( |
||||
JEMALLOC_LIBRARIES |
||||
JEMALLOC_INCLUDE_DIR) |
||||
JeMalloc_LIBRARIES |
||||
JeMalloc_INCLUDE_DIRS) |
||||
|
||||
if(JeMalloc_FOUND AND NOT (TARGET JeMalloc::JeMalloc)) |
||||
add_library (JeMalloc::JeMalloc UNKNOWN IMPORTED) |
||||
set_target_properties(JeMalloc::JeMalloc |
||||
PROPERTIES |
||||
IMPORTED_LOCATION ${JeMalloc_LIBRARIES} |
||||
INTERFACE_INCLUDE_DIRECTORIES ${JeMalloc_INCLUDE_DIRS}) |
||||
endif() |
||||
|
@ -1,21 +0,0 @@ |
||||
# - Find Bzip2 |
||||
# Find the bzip2 compression library and includes |
||||
# |
||||
# BZIP2_INCLUDE_DIR - where to find bzlib.h, etc. |
||||
# BZIP2_LIBRARIES - List of libraries when using bzip2. |
||||
# BZIP2_FOUND - True if bzip2 found. |
||||
|
||||
find_path(BZIP2_INCLUDE_DIR |
||||
NAMES bzlib.h |
||||
HINTS ${BZIP2_ROOT_DIR}/include) |
||||
|
||||
find_library(BZIP2_LIBRARIES |
||||
NAMES bz2 |
||||
HINTS ${BZIP2_ROOT_DIR}/lib) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(bzip2 DEFAULT_MSG BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) |
||||
|
||||
mark_as_advanced( |
||||
BZIP2_LIBRARIES |
||||
BZIP2_INCLUDE_DIR) |
@ -1,21 +1,29 @@ |
||||
# - Find Lz4 |
||||
# Find the lz4 compression library and includes |
||||
# |
||||
# LZ4_INCLUDE_DIR - where to find lz4.h, etc. |
||||
# LZ4_LIBRARIES - List of libraries when using lz4. |
||||
# LZ4_FOUND - True if lz4 found. |
||||
# lz4_INCLUDE_DIRS - where to find lz4.h, etc. |
||||
# lz4_LIBRARIES - List of libraries when using lz4. |
||||
# lz4_FOUND - True if lz4 found. |
||||
|
||||
find_path(LZ4_INCLUDE_DIR |
||||
find_path(lz4_INCLUDE_DIRS |
||||
NAMES lz4.h |
||||
HINTS ${LZ4_ROOT_DIR}/include) |
||||
HINTS ${lz4_ROOT_DIR}/include) |
||||
|
||||
find_library(LZ4_LIBRARIES |
||||
find_library(lz4_LIBRARIES |
||||
NAMES lz4 |
||||
HINTS ${LZ4_ROOT_DIR}/lib) |
||||
HINTS ${lz4_ROOT_DIR}/lib) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(lz4 DEFAULT_MSG LZ4_LIBRARIES LZ4_INCLUDE_DIR) |
||||
find_package_handle_standard_args(lz4 DEFAULT_MSG lz4_LIBRARIES lz4_INCLUDE_DIRS) |
||||
|
||||
mark_as_advanced( |
||||
LZ4_LIBRARIES |
||||
LZ4_INCLUDE_DIR) |
||||
lz4_LIBRARIES |
||||
lz4_INCLUDE_DIRS) |
||||
|
||||
if(lz4_FOUND AND NOT (TARGET lz4::lz4)) |
||||
add_library(lz4::lz4 UNKNOWN IMPORTED) |
||||
set_target_properties(lz4::lz4 |
||||
PROPERTIES |
||||
IMPORTED_LOCATION ${lz4_LIBRARIES} |
||||
INTERFACE_INCLUDE_DIRECTORIES ${lz4_INCLUDE_DIRS}) |
||||
endif() |
||||
|
@ -1,21 +1,29 @@ |
||||
# - Find Snappy |
||||
# Find the snappy compression library and includes |
||||
# |
||||
# SNAPPY_INCLUDE_DIR - where to find snappy.h, etc. |
||||
# SNAPPY_LIBRARIES - List of libraries when using snappy. |
||||
# SNAPPY_FOUND - True if snappy found. |
||||
# snappy_INCLUDE_DIRS - where to find snappy.h, etc. |
||||
# snappy_LIBRARIES - List of libraries when using snappy. |
||||
# snappy_FOUND - True if snappy found. |
||||
|
||||
find_path(SNAPPY_INCLUDE_DIR |
||||
find_path(snappy_INCLUDE_DIRS |
||||
NAMES snappy.h |
||||
HINTS ${SNAPPY_ROOT_DIR}/include) |
||||
HINTS ${snappy_ROOT_DIR}/include) |
||||
|
||||
find_library(SNAPPY_LIBRARIES |
||||
NAMES snappy |
||||
HINTS ${SNAPPY_ROOT_DIR}/lib) |
||||
HINTS ${snappy_ROOT_DIR}/lib) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(snappy DEFAULT_MSG SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIR) |
||||
find_package_handle_standard_args(snappy DEFAULT_MSG snappy_LIBRARIES snappy_INCLUDE_DIRS) |
||||
|
||||
mark_as_advanced( |
||||
SNAPPY_LIBRARIES |
||||
SNAPPY_INCLUDE_DIR) |
||||
snappy_LIBRARIES |
||||
snappy_INCLUDE_DIRS) |
||||
|
||||
if(snappy_FOUND AND NOT (TARGET snappy::snappy)) |
||||
add_library (snappy::snappy UNKNOWN IMPORTED) |
||||
set_target_properties(snappy::snappy |
||||
PROPERTIES |
||||
IMPORTED_LOCATION ${snappy_LIBRARIES} |
||||
INTERFACE_INCLUDE_DIRECTORIES ${snappy_INCLUDE_DIRS}) |
||||
endif() |
||||
|
@ -1,21 +1,29 @@ |
||||
# - Find zstd |
||||
# Find the zstd compression library and includes |
||||
# |
||||
# ZSTD_INCLUDE_DIR - where to find zstd.h, etc. |
||||
# ZSTD_LIBRARIES - List of libraries when using zstd. |
||||
# ZSTD_FOUND - True if zstd found. |
||||
# zstd_INCLUDE_DIRS - where to find zstd.h, etc. |
||||
# zstd_LIBRARIES - List of libraries when using zstd. |
||||
# zstd_FOUND - True if zstd found. |
||||
|
||||
find_path(ZSTD_INCLUDE_DIR |
||||
find_path(zstd_INCLUDE_DIRS |
||||
NAMES zstd.h |
||||
HINTS ${ZSTD_ROOT_DIR}/include) |
||||
HINTS ${zstd_ROOT_DIR}/include) |
||||
|
||||
find_library(ZSTD_LIBRARIES |
||||
find_library(zstd_LIBRARIES |
||||
NAMES zstd |
||||
HINTS ${ZSTD_ROOT_DIR}/lib) |
||||
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_DIRS) |
||||
|
||||
mark_as_advanced( |
||||
ZSTD_LIBRARIES |
||||
ZSTD_INCLUDE_DIR) |
||||
zstd_LIBRARIES |
||||
zstd_INCLUDE_DIRS) |
||||
|
||||
if(zstd_FOUND AND NOT (TARGET zstd::zstd)) |
||||
add_library (zstd::zstd UNKNOWN IMPORTED) |
||||
set_target_properties(zstd::zstd |
||||
PROPERTIES |
||||
IMPORTED_LOCATION ${zstd_LIBRARIES} |
||||
INTERFACE_INCLUDE_DIRECTORIES ${zstd_INCLUDE_DIRS}) |
||||
endif() |
||||
|
@ -0,0 +1,10 @@ |
||||
# Read rocksdb version from version.h header file. |
||||
|
||||
function(get_rocksdb_version version_var) |
||||
file(READ "${CMAKE_SOURCE_DIR}/include/rocksdb/version.h" version_header_file) |
||||
foreach(component MAJOR MINOR PATCH) |
||||
string(REGEX MATCH "#define ROCKSDB_${component} ([0-9]+)" _ ${version_header_file}) |
||||
set(ROCKSDB_VERSION_${component} ${CMAKE_MATCH_1}) |
||||
endforeach() |
||||
set(${version_var} "${ROCKSDB_VERSION_MAJOR}.${ROCKSDB_VERSION_MINOR}.${ROCKSDB_VERSION_PATCH}" PARENT_SCOPE) |
||||
endfunction() |
Loading…
Reference in new issue