From adcf920f407f0d7b78b71348017e13632fdb95e9 Mon Sep 17 00:00:00 2001 From: suzanwen Date: Fri, 22 Nov 2019 08:18:15 -0800 Subject: [PATCH] Compatible changes for cmake (#6045) Summary: `${TESTUTILLIB}` should be linked with targets`${LIBS}`, otherwise it may not find the references. After that, we have to work fine with `${CMAKE_CURRENT_SOURCE_DIR}` in `cmake/modules/ReadVersion.cmake`, while building external projects with `add_subdirectory(/path/to/rocksdb)`. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6045 Differential Revision: D18641791 Pulled By: pdillinger fbshipit-source-id: a56b03b4dda6bae6edce1375324f51340917dddc --- CMakeLists.txt | 1 + cmake/modules/ReadVersion.cmake | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45693df50..b2883b53a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1070,6 +1070,7 @@ if(WITH_TESTS) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) set(TESTUTILLIB testutillib${ARTIFACT_SUFFIX}) add_library(${TESTUTILLIB} STATIC ${TESTUTIL_SOURCE}) + target_link_libraries(${TESTUTILLIB} ${LIBS}) if(MSVC) set_target_properties(${TESTUTILLIB} PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/testutillib${ARTIFACT_SUFFIX}.pdb") endif() diff --git a/cmake/modules/ReadVersion.cmake b/cmake/modules/ReadVersion.cmake index ae356d996..ebfd7d6f9 100644 --- a/cmake/modules/ReadVersion.cmake +++ b/cmake/modules/ReadVersion.cmake @@ -1,7 +1,7 @@ # 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) + file(READ "${CMAKE_CURRENT_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}) -- GitLab