cmake: do not build tests for Release build and cleanups (#5916)
Summary: fixes https://github.com/facebook/rocksdb/issues/2445 Pull Request resolved: https://github.com/facebook/rocksdb/pull/5916 Differential Revision: D19031236 fbshipit-source-id: bc3107b6b25a01958677d7cb411b1f381aae91c6
This commit is contained in:
parent
fec7302a9d
commit
ac304adf46
@ -63,7 +63,7 @@ matrix:
|
|||||||
# https://docs.travis-ci.com/user/caching/#ccache-cache
|
# https://docs.travis-ci.com/user/caching/#ccache-cache
|
||||||
install:
|
install:
|
||||||
- if [ "${TRAVIS_OS_NAME}" == osx ]; then
|
- if [ "${TRAVIS_OS_NAME}" == osx ]; then
|
||||||
brew install ccache zstd lz4 snappy xz;
|
brew install ccache gflags zstd lz4 snappy xz;
|
||||||
PATH=$PATH:/usr/local/opt/ccache/libexec;
|
PATH=$PATH:/usr/local/opt/ccache/libexec;
|
||||||
fi
|
fi
|
||||||
- if [ "${JOB_NAME}" == cmake-gcc8 ]; then
|
- if [ "${JOB_NAME}" == cmake-gcc8 ]; then
|
||||||
@ -113,7 +113,7 @@ script:
|
|||||||
;;
|
;;
|
||||||
cmake-mingw)
|
cmake-mingw)
|
||||||
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix;
|
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix;
|
||||||
mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb rocksdbjni
|
mkdir build && cd build && cmake -DJNI=1 -DWITH_GFLAGS=OFF .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb rocksdbjni
|
||||||
;;
|
;;
|
||||||
cmake*)
|
cmake*)
|
||||||
mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_BUILD_TYPE=Release && make -j4 rocksdb rocksdbjni
|
mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_BUILD_TYPE=Release && make -j4 rocksdb rocksdbjni
|
||||||
|
132
CMakeLists.txt
132
CMakeLists.txt
@ -45,6 +45,16 @@ if(POLICY CMP0042)
|
|||||||
cmake_policy(SET CMP0042 NEW)
|
cmake_policy(SET CMP0042 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
|
set(default_build_type "Debug")
|
||||||
|
else()
|
||||||
|
set(default_build_type "RelWithDebInfo")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING
|
||||||
|
"Default BUILD_TYPE is ${default_build_type}" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_program(CCACHE_FOUND ccache)
|
find_program(CCACHE_FOUND ccache)
|
||||||
if(CCACHE_FOUND)
|
if(CCACHE_FOUND)
|
||||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||||
@ -62,7 +72,7 @@ if (WITH_WINDOWS_UTF8_FILENAMES)
|
|||||||
endif()
|
endif()
|
||||||
# third-party/folly is only validated to work on Linux and Windows for now.
|
# third-party/folly is only validated to work on Linux and Windows for now.
|
||||||
# So only turn it on there by default.
|
# So only turn it on there by default.
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Windows")
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Windows")
|
||||||
if(MSVC AND MSVC_VERSION LESS 1910)
|
if(MSVC AND MSVC_VERSION LESS 1910)
|
||||||
# Folly does not compile with MSVC older than VS2017
|
# Folly does not compile with MSVC older than VS2017
|
||||||
option(WITH_FOLLY_DISTRIBUTED_MUTEX "build with folly::DistributedMutex" OFF)
|
option(WITH_FOLLY_DISTRIBUTED_MUTEX "build with folly::DistributedMutex" OFF)
|
||||||
@ -72,10 +82,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|||||||
else()
|
else()
|
||||||
option(WITH_FOLLY_DISTRIBUTED_MUTEX "build with folly::DistributedMutex" OFF)
|
option(WITH_FOLLY_DISTRIBUTED_MUTEX "build with folly::DistributedMutex" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
CMAKE_DEPENDENT_OPTION(WITH_GFLAGS "build with GFlags" ON
|
||||||
|
"NOT MSVC;NOT MINGW" OFF)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Defaults currently different for GFLAGS.
|
|
||||||
# We will address find_package work a little later
|
|
||||||
option(WITH_GFLAGS "build with GFlags" OFF)
|
|
||||||
option(WITH_XPRESS "build with windows built in compression" OFF)
|
option(WITH_XPRESS "build with windows built in compression" OFF)
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)
|
||||||
else()
|
else()
|
||||||
@ -92,14 +104,11 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# No config file for this
|
# No config file for this
|
||||||
option(WITH_GFLAGS "build with GFlags" ON)
|
|
||||||
if(WITH_GFLAGS)
|
if(WITH_GFLAGS)
|
||||||
find_package(gflags)
|
find_package(gflags REQUIRED)
|
||||||
if(gflags_FOUND)
|
add_definitions(-DGFLAGS=1)
|
||||||
add_definitions(-DGFLAGS=1)
|
include_directories(${gflags_INCLUDE_DIR})
|
||||||
include_directories(${gflags_INCLUDE_DIR})
|
list(APPEND THIRDPARTY_LIBS gflags::gflags)
|
||||||
list(APPEND THIRDPARTY_LIBS ${gflags_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WITH_SNAPPY)
|
if(WITH_SNAPPY)
|
||||||
@ -895,11 +904,15 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(WITH_TESTS "build with tests" ON)
|
add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest)
|
||||||
# For test libraries, utilities, and exes that are build iff WITH_TESTS=ON and
|
add_library(testharness STATIC
|
||||||
# in Debug mode. Add test only code that is not #ifdefed for Release here.
|
test_util/testharness.cc)
|
||||||
if(WITH_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
target_link_libraries(testharness gtest)
|
||||||
add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest)
|
|
||||||
|
# Tests are excluded from Release builds
|
||||||
|
CMAKE_DEPENDENT_OPTION(WITH_TESTS "build with tests" ON
|
||||||
|
"CMAKE_BUILD_TYPE STREQUAL Debug" OFF)
|
||||||
|
if(WITH_TESTS)
|
||||||
set(TESTS
|
set(TESTS
|
||||||
cache/cache_test.cc
|
cache/cache_test.cc
|
||||||
cache/lru_cache_test.cc
|
cache/lru_cache_test.cc
|
||||||
@ -1074,23 +1087,21 @@ if(WITH_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
|
EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
|
||||||
)
|
)
|
||||||
|
|
||||||
set(TEST_EXES ${TESTS})
|
foreach(sourcefile ${TESTS})
|
||||||
foreach(sourcefile ${TEST_EXES})
|
|
||||||
get_filename_component(exename ${sourcefile} NAME_WE)
|
get_filename_component(exename ${sourcefile} NAME_WE)
|
||||||
add_executable(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} ${sourcefile}
|
add_executable(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} ${sourcefile})
|
||||||
$<TARGET_OBJECTS:testharness>)
|
|
||||||
set_target_properties(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX}
|
set_target_properties(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX}
|
||||||
PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
|
PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
|
||||||
EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
|
EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
|
||||||
EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
|
EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
|
||||||
OUTPUT_NAME ${exename}${ARTIFACT_SUFFIX}
|
OUTPUT_NAME ${exename}${ARTIFACT_SUFFIX}
|
||||||
)
|
)
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} testutillib${ARTIFACT_SUFFIX} gtest ${ROCKSDB_LIB})
|
target_link_libraries(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} testutillib${ARTIFACT_SUFFIX} testharness gtest ${ROCKSDB_LIB})
|
||||||
if(NOT "${exename}" MATCHES "db_sanity_test")
|
if(NOT "${exename}" MATCHES "db_sanity_test")
|
||||||
add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX})
|
add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX})
|
||||||
add_dependencies(check ${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX})
|
add_dependencies(check ${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX})
|
||||||
endif()
|
endif()
|
||||||
endforeach(sourcefile ${TEST_EXES})
|
endforeach(sourcefile ${TESTS})
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# C executables must link to a shared object
|
# C executables must link to a shared object
|
||||||
@ -1105,50 +1116,51 @@ if(WITH_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|||||||
|
|
||||||
if(ROCKSDB_LIB_FOR_C)
|
if(ROCKSDB_LIB_FOR_C)
|
||||||
set(C_TESTS db/c_test.c)
|
set(C_TESTS db/c_test.c)
|
||||||
set(C_TEST_EXES ${C_TESTS})
|
# C executables must link to a shared object
|
||||||
|
add_executable(c_test db/c_test.c)
|
||||||
foreach(sourcefile ${C_TEST_EXES})
|
target_link_libraries(c_test ${ROCKSDB_SHARED_LIB} testharness)
|
||||||
string(REPLACE ".c" "" exename ${sourcefile})
|
add_test(NAME c_test COMMAND c_test${ARTIFACT_SUFFIX})
|
||||||
string(REGEX REPLACE "^((.+)/)+" "" exename ${exename})
|
add_dependencies(check c_test)
|
||||||
add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile})
|
|
||||||
set_target_properties(${exename}${ARTIFACT_SUFFIX}
|
|
||||||
PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1
|
|
||||||
EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1
|
|
||||||
EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1
|
|
||||||
)
|
|
||||||
target_link_libraries(${exename}${ARTIFACT_SUFFIX} ${ROCKSDB_LIB_FOR_C} testutillib${ARTIFACT_SUFFIX})
|
|
||||||
add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX})
|
|
||||||
add_dependencies(check ${exename}${ARTIFACT_SUFFIX})
|
|
||||||
endforeach(sourcefile ${C_TEST_EXES})
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(WITH_BENCHMARK_TOOLS "build with benchmarks" ON)
|
option(WITH_BENCHMARK_TOOLS "build with benchmarks" ON)
|
||||||
if(WITH_BENCHMARK_TOOLS)
|
if(WITH_BENCHMARK_TOOLS)
|
||||||
if(NOT TARGET gtest)
|
add_executable(db_bench
|
||||||
add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest)
|
|
||||||
endif()
|
|
||||||
set(BENCHMARKS
|
|
||||||
cache/cache_bench.cc
|
|
||||||
memtable/memtablerep_bench.cc
|
|
||||||
db/range_del_aggregator_bench.cc
|
|
||||||
table/table_reader_bench.cc
|
|
||||||
util/filter_bench.cc
|
|
||||||
utilities/persistent_cache/hash_table_bench.cc
|
|
||||||
)
|
|
||||||
add_library(testharness OBJECT test_util/testharness.cc)
|
|
||||||
foreach(sourcefile ${BENCHMARKS})
|
|
||||||
get_filename_component(exename ${sourcefile} NAME_WE)
|
|
||||||
add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile}
|
|
||||||
$<TARGET_OBJECTS:testharness>)
|
|
||||||
target_link_libraries(${exename}${ARTIFACT_SUFFIX} gtest ${ROCKSDB_LIB})
|
|
||||||
endforeach(sourcefile ${BENCHMARKS})
|
|
||||||
|
|
||||||
add_executable(db_bench${ARTIFACT_SUFFIX}
|
|
||||||
tools/db_bench.cc
|
tools/db_bench.cc
|
||||||
tools/db_bench_tool.cc
|
tools/db_bench_tool.cc)
|
||||||
$<TARGET_OBJECTS:testharness>)
|
target_link_libraries(db_bench
|
||||||
target_link_libraries(db_bench${ARTIFACT_SUFFIX} gtest ${ROCKSDB_LIB})
|
${ROCKSDB_LIB})
|
||||||
|
|
||||||
|
add_executable(cache_bench
|
||||||
|
cache/cache_bench.cc)
|
||||||
|
target_link_libraries(cache_bench
|
||||||
|
${ROCKSDB_LIB})
|
||||||
|
|
||||||
|
add_executable(memtablerep_bench
|
||||||
|
memtable/memtablerep_bench.cc)
|
||||||
|
target_link_libraries(memtablerep_bench
|
||||||
|
${ROCKSDB_LIB})
|
||||||
|
|
||||||
|
add_executable(range_del_aggregator_bench
|
||||||
|
db/range_del_aggregator_bench.cc)
|
||||||
|
target_link_libraries(range_del_aggregator_bench
|
||||||
|
${ROCKSDB_LIB})
|
||||||
|
|
||||||
|
add_executable(table_reader_bench
|
||||||
|
table/table_reader_bench.cc)
|
||||||
|
target_link_libraries(table_reader_bench
|
||||||
|
${ROCKSDB_LIB} testharness)
|
||||||
|
|
||||||
|
add_executable(filter_bench
|
||||||
|
util/filter_bench.cc)
|
||||||
|
target_link_libraries(filter_bench
|
||||||
|
${ROCKSDB_LIB})
|
||||||
|
|
||||||
|
add_executable(hash_table_bench
|
||||||
|
utilities/persistent_cache/hash_table_bench.cc)
|
||||||
|
target_link_libraries(hash_table_bench
|
||||||
|
${ROCKSDB_LIB})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(WITH_TOOLS "build with tools" ON)
|
option(WITH_TOOLS "build with tools" ON)
|
||||||
|
29
cmake/modules/Findgflags.cmake
Normal file
29
cmake/modules/Findgflags.cmake
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# - Find gflags library
|
||||||
|
# Find the gflags includes and library
|
||||||
|
#
|
||||||
|
# gflags_INCLUDE_DIR - where to find gflags.h.
|
||||||
|
# gflags_LIBRARIES - List of libraries when using gflags.
|
||||||
|
# gflags_FOUND - True if gflags found.
|
||||||
|
|
||||||
|
find_path(GFLAGS_INCLUDE_DIR
|
||||||
|
NAMES gflags/gflags.h)
|
||||||
|
|
||||||
|
find_library(GFLAGS_LIBRARIES
|
||||||
|
NAMES gflags)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(gflags
|
||||||
|
DEFAULT_MSG GFLAGS_LIBRARIES GFLAGS_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
GFLAGS_LIBRARIES
|
||||||
|
GFLAGS_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(gflags_FOUND AND NOT (TARGET gflags::gflags))
|
||||||
|
add_library(gflags::gflags UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(gflags::gflags
|
||||||
|
PROPERTIES
|
||||||
|
IMPORTED_LOCATION ${GFLAGS_LIBRARIES}
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${GFLAGS_INCLUDE_DIR}
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
|
||||||
|
endif()
|
@ -175,8 +175,8 @@ class BatchedOpsStressTest : public StressTest {
|
|||||||
const std::vector<int64_t>& rand_keys) override {
|
const std::vector<int64_t>& rand_keys) override {
|
||||||
size_t num_keys = rand_keys.size();
|
size_t num_keys = rand_keys.size();
|
||||||
std::vector<Status> ret_status(num_keys);
|
std::vector<Status> ret_status(num_keys);
|
||||||
std::array<std::string, 10> keys = {"0", "1", "2", "3", "4",
|
std::array<std::string, 10> keys = {{"0", "1", "2", "3", "4",
|
||||||
"5", "6", "7", "8", "9"};
|
"5", "6", "7", "8", "9"}};
|
||||||
size_t num_prefixes = keys.size();
|
size_t num_prefixes = keys.size();
|
||||||
for (size_t rand_key = 0; rand_key < num_keys; ++rand_key) {
|
for (size_t rand_key = 0; rand_key < num_keys; ++rand_key) {
|
||||||
std::vector<Slice> key_slices;
|
std::vector<Slice> key_slices;
|
||||||
|
Loading…
Reference in New Issue
Block a user