-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: cmake related cleanups #5662
Conversation
tchaikov
commented
Aug 1, 2019
•
edited
Loading
edited
- 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
Looks fine to me. |
CMakeLists.txt
Outdated
enable_language(ASM) | ||
cmake_minimum_required(VERSION 3.5.1) | ||
project(rocksdb | ||
VERSION 6.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to get version from version.h?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to not duplicate in two places. Is "VERSION 6.2.0" needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. i extracted ReadVersion.cmake
out, and use it instead.
cmake/modules/Findlz4.cmake
Outdated
# 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_DIR - where to find lz4.h, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lz4_INCLUDE_DIRS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks. fixed.
CMakeLists.txt
Outdated
add_definitions(-DBZIP2) | ||
include_directories(${BZIP2_INCLUDE_DIR}) | ||
include_directories(${BZIP2_INCLUDE_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also update Findbzip2.cmake accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Findbzip2.cmake
is removed in the same commit. please refer the commit message for more details.
FindBzip2.cmake has been shipped along with CMake since v2.6.0, so let's just use it instead of the homebrew one. please note, in CMake 3.5.1, FindBzip2.cmake exposed `BZIP2_INCLUDE_DIR`, see https://github.com/Kitware/CMake/blob/v3.5.1/Modules/FindBZip2.cmake. while since CMake 3.12.1, FindBzip2.cmake exposes both Bzip2::Bzip2 and `BZIP2_INCLUDE_DIRS`, see https://github.com/Kitware/CMake/blob/v3.12.1/Modules/FindBZip2.cmake Signed-off-by: Kefu Chai <tchaikov@gmail.com>
* require 3.5.1 * use project(... LANGUAGES ..) to silence warnings regarding to CMP0048 * use imported target of ZLIB::ZLIB, as it's available since 3.5.1 cmake 3.5.1 is offered by ubuntu xenial, and cmake3.13 is offered by EPEL7. so it should be safe to bump the required cmake version. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
changelog
|
* so it would be simpler to import these libraries * lower case the {lz4,snappy,zstd}_* variables to follow the convention of CMake that Find<name>.cmake should expose names of <name>_*. instead of <NAME>_*. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
for couple reasons * modularize the cmake file, to extract the subroutines into their own modules. this approach also avoid pollution the global namespace with the local variables. * use `<PROJECT_NAME>_VERSION_*` instead of `ROCKSDB_VERSION_*` to follow CMake conventions. please note, the project name of rocksdb in this CMakefile script is "rocksdb" instead of "ROCKSDB". * refactor the code to read the version number using a loop, let repeating this way. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
@tchaikov could you please update the PR description with a summary of the changes. |
@burtonli @yiwu-arbug Thanks for the review. In the PR good for landing? |
@maysamyabandeh sure. updated. |
LGTM |
1 similar comment
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@maysamyabandeh merged this pull request in cc9fa7f. |
rocksdb needs CMake 3.5.1 since facebook/rocksdb#5662 Signed-off-by: Kefu Chai <kchai@redhat.com>
rocksdb needs CMake 3.5.1 since facebook/rocksdb#5662 Signed-off-by: Kefu Chai <kchai@redhat.com>
rocksdb needs CMake 3.5.1 since facebook/rocksdb#5662 Fixes: https://tracker.ceph.com/issues/41253 Signed-off-by: Kefu Chai <kchai@redhat.com>
rocksdb needs CMake 3.5.1 since facebook/rocksdb#5662 Fixes: https://tracker.ceph.com/issues/41253 Signed-off-by: Kefu Chai <kchai@redhat.com>
rocksdb needs CMake 3.5.1 since facebook/rocksdb#5662 Fixes: https://tracker.ceph.com/issues/41253 Signed-off-by: Kefu Chai <kchai@redhat.com>
rocksdb needs CMake 3.5.1 since facebook/rocksdb#5662 Fixes: https://tracker.ceph.com/issues/41253 Signed-off-by: Kefu Chai <kchai@redhat.com>
rocksdb needs CMake 3.5.1 since facebook/rocksdb#5662 Fixes: https://tracker.ceph.com/issues/41253 Signed-off-by: Kefu Chai <kchai@redhat.com> (cherry picked from commit 52277bf)
This reverts commit cc9fa7f.
@@ -93,43 +93,38 @@ else() | |||
if(WITH_SNAPPY) | |||
find_package(snappy REQUIRED) | |||
add_definitions(-DSNAPPY) | |||
include_directories(${SNAPPY_INCLUDE_DIR}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tchaikov Why do you remove this line? Seems that cannot find it in include path. Errors like
/root/cs/suzanwen/repos/C++/storage/rocksdb_xxx/rocksdb/util/compression.h:31:20: fatal error: snappy.h: No such file or directory #include <snappy.h> ^ compilation terminated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because, IIUC, snappy::snappy should be able to populate the "INSTALL_INTERFACE" property to the library/executable linked against it, so cmake will determine the correct build property of consumer of snappy::snappy and library publicly linked against this library.
rocksdb/cmake/modules/Findsnappy.cmake
Line 28 in f65ec09
INTERFACE_INCLUDE_DIRECTORIES ${snappy_INCLUDE_DIRS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's right for the most targets, such as ROCKSDB_STATIC_LIB
. But not for TESTUTILLIB
. Plz have a glance at the following snippet.
Line 1072 in f65ec09
add_library(${TESTUTILLIB} STATIC ${TESTUTIL_SOURCE}) |
snappy.h
was included in db/db_test_util.cc
(just as the source file in target TESTUTILLIB
). Porbably we need make it works fine with target_link_libraries(${TESTUTILLIB} ${LIBS})
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: facebook#5662 Differential Revision: D16660974 Pulled By: maysamyabandeh fbshipit-source-id: 681594910e74253251fe14ad0befc41a4d0f4fd4
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be CMAKE_CURRENT_SOURCE_DIR
, not CMAKE_SOURCE_DIR
. This particular variable breaks a rockdb
source build that's been vendor'ed via add_subdirectory(vendor/rocksdb)
in a parent source tree, as it instead tries to get the include/rocksdb/version.h
in the parent project.
As noted in an inline comment, this breaks the |
@wbrown-lg thanks for pointing out this. Will fix it shortly. |
@wbrown-lg this was fixed by adcf920 . could you use a commit which includes that change instead? |