@ -29,37 +29,108 @@
cmake_minimum_required ( VERSION 2.6 )
project ( rocksdb )
include ( ${ CMAKE_CURRENT_SOURCE_DIR } /thirdparty.inc )
execute_process ( COMMAND powershell -Command "Get-Date -format MM_dd_yyyy" OUTPUT_VARIABLE DATE )
execute_process ( COMMAND powershell -Command "Get-Date -format HH:mm:ss" OUTPUT_VARIABLE TIME )
string ( REGEX REPLACE "(..)_(..)_..(..).*" "\\1/\\2/\\3" DATE "${DATE}" )
string ( REGEX REPLACE "(..):(.....).*" " \\1:\\2" TIME "${TIME}" )
string ( CONCAT GIT_DATE_TIME ${ DATE } ${ TIME } )
if ( POLICY CMP0042 )
cmake_policy ( SET CMP0042 NEW )
endif ( )
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/" )
if ( WIN32 )
include ( ${ CMAKE_CURRENT_SOURCE_DIR } /thirdparty.inc )
else ( )
option ( WITH_JEMALLOC "build with JeMalloc" OFF )
if ( WITH_JEMALLOC )
find_package ( JeMalloc REQUIRED )
add_definitions ( -DROCKSDB_JEMALLOC )
include_directories ( ${ JEMALLOC_INCLUDE_DIR } )
endif ( )
option ( WITH_SNAPPY "build with SNAPPY" OFF )
if ( WITH_SNAPPY )
find_package ( snappy REQUIRED )
add_definitions ( -DSNAPPY )
include_directories ( ${ SNAPPY_INCLUDE_DIR } )
list ( APPEND THIRDPARTY_LIBS ${ SNAPPY_LIBRARIES } )
endif ( )
endif ( )
if ( WIN32 )
execute_process ( COMMAND powershell -Command "Get-Date -format MM_dd_yyyy" OUTPUT_VARIABLE DATE )
execute_process ( COMMAND powershell -Command "Get-Date -format HH:mm:ss" OUTPUT_VARIABLE TIME )
string ( REGEX REPLACE "(..)_(..)_..(..).*" "\\1/\\2/\\3" DATE "${DATE}" )
string ( REGEX REPLACE "(..):(.....).*" " \\1:\\2" TIME "${TIME}" )
string ( CONCAT GIT_DATE_TIME ${ DATE } ${ TIME } )
else ( )
execute_process ( COMMAND date "+%Y/%m/%d %H:%M:%S" OUTPUT_VARIABLE DATETIME )
string ( REGEX REPLACE "\n" "" DATETIME ${ DATETIME } )
string ( CONCAT GIT_DATE_TIME ${ DATETIME } )
endif ( )
find_package ( Git )
if ( GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git" )
if ( WIN32 )
execute_process ( COMMAND $ENV{ COMSPEC } /C ${ GIT_EXECUTABLE } -C ${ CMAKE_CURRENT_SOURCE_DIR } rev-parse HEAD OUTPUT_VARIABLE GIT_SHA )
else ( )
execute_process ( COMMAND ${ GIT_EXECUTABLE } -C ${ CMAKE_CURRENT_SOURCE_DIR } rev-parse HEAD OUTPUT_VARIABLE GIT_SHA )
endif ( )
else ( )
set ( GIT_SHA 0 )
set ( GIT_SHA 0 )
endif ( )
string ( REGEX REPLACE "[^0-9a-f]+" "" GIT_SHA "${GIT_SHA}" )
set ( BUILD_VERSION_CC ${ CMAKE_CURRENT_SOURCE_DIR } /util/build_version.cc )
add_custom_command ( OUTPUT ${ BUILD_VERSION_CC }
C O M M A N D e c h o " # i n c l u d e \ " b u i l d _ v e r s i o n . h \ " " > $ { B U I L D _ V E R S I O N _ C C }
C O M M A N D e c h o " c o n s t c h a r * r o c k s d b _ b u i l d _ g i t _ s h a = \ " r o c k s d b _ b u i l d _ g i t _ s h a : $ { G I T _ S H A } \ " ; " > > $ { B U I L D _ V E R S I O N _ C C }
C O M M A N D e c h o " c o n s t c h a r * r o c k s d b _ b u i l d _ g i t _ d a t e t i m e = \ " r o c k s d b _ b u i l d _ g i t _ d a t e t i m e : $ { G I T _ D A T E _ T I M E } \ " ; " > > $ { B U I L D _ V E R S I O N _ C C }
C O M M A N D e c h o c o n s t c h a r * r o c k s d b _ b u i l d _ c o m p i l e _ d a t e = _ _ D A T E _ _ \ ; > > $ { B U I L D _ V E R S I O N _ C C }
)
set ( BUILD_VERSION_CC ${ CMAKE_BINARY_DIR } /build_version.cc )
file ( GENERATE OUTPUT ${ BUILD_VERSION_CC } CONTENT
" # i n c l u d e \ " b u i l d _ v e r s i o n . h \ "
c o n s t c h a r * r o c k s d b _ b u i l d _ g i t _ s h a = \ " r o c k s d b _ b u i l d _ g i t _ s h a : $ { G I T _ S H A } \ " ;
c o n s t c h a r * r o c k s d b _ b u i l d _ g i t _ d a t e t i m e = \ " r o c k s d b _ b u i l d _ g i t _ d a t e t i m e : $ { G I T _ D A T E _ T I M E } \ " ;
c o n s t c h a r * r o c k s d b _ b u i l d _ c o m p i l e _ d a t e = _ _ D A T E _ _ ;
" )
add_library ( build_version OBJECT ${ BUILD_VERSION_CC } )
target_include_directories ( build_version PRIVATE
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / u t i l )
if ( WIN32 )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /nologo /EHsc /GS /Gd /GR /GF /fp:precise /Zc:wchar_t /Zc:forScope /errorReport:queue" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC /d2Zi+ /W3 /WX /wd4127 /wd4800 /wd4996 /wd4351" )
else ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall -Werror" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -fno-omit-frame-pointer -momit-leaf-frame-pointer" )
endif ( )
add_custom_target ( GenerateBuildVersion DEPENDS ${ BUILD_VERSION_CC } )
option ( WITH_ASAN "build with ASAN" OFF )
if ( WITH_ASAN )
add_definitions ( -DROCKSDB_TSAN_RUN )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address" )
if ( WITH_JEMALLOC )
message ( FATAL "ASAN does not work well with JeMalloc" )
endif ( )
endif ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /nologo /EHsc /GS /Gd /GR /GF /fp:precise /Zc:wchar_t /Zc:forScope /errorReport:queue" )
option ( WITH_TSAN "build with TSAN" OFF )
if ( WITH_TSAN )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread -pie" )
add_definitions ( -DROCKSDB_TSAN_RUN )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fPIC" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fPIC" )
if ( WITH_JEMALLOC )
message ( FATAL "TSAN does not work well with JeMalloc" )
endif ( )
endif ( )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC /d2Zi+ /W3 /WX /wd4127 /wd4800 /wd4996 /wd4351" )
option ( WITH_UBSAN "build with UBSAN" OFF )
if ( WITH_UBSAN )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined" )
if ( WITH_JEMALLOC )
message ( FATAL "UBSAN does not work well with JeMalloc" )
endif ( )
endif ( )
# U s e d t o r u n C I b u i l d a n d t e s t s s o w e c a n r u n f a s t e r
set ( OPTIMIZE_DEBUG_DEFAULT 0 ) # D e b u g b u i l d i s u n o p t i m i z e d b y d e f a u l t u s e - D O P T D B G = 1 t o o p t i m i z e
@ -70,33 +141,102 @@ else()
set ( OPTIMIZE_DEBUG ${ OPTIMIZE_DEBUG_DEFAULT } )
endif ( )
if ( ( ${ OPTIMIZE_DEBUG } EQUAL 1 ) )
message ( STATUS "Debug optimization is enabled" )
set ( CMAKE_CXX_FLAGS_DEBUG "/Oxt /MDd" )
else ( )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /RTC1 /Gm /MDd" )
if ( WIN32 )
if ( ( ${ OPTIMIZE_DEBUG } EQUAL 1 ) )
message ( STATUS "Debug optimization is enabled" )
set ( CMAKE_CXX_FLAGS_DEBUG "/Oxt /MDd" )
else ( )
set ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /RTC1 /Gm /MDd" )
endif ( )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oxt /Zp8 /Gm- /Gy /MD" )
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG" )
endif ( )
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oxt /Zp8 /Gm- /Gy /MD" )
if ( CMAKE_COMPILER_IS_GNUCXX )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp" )
endif ( )
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG" )
option ( ROCKSDB_LITE "Build RocksDBLite version" OFF )
if ( ROCKSDB_LITE )
add_definitions ( -DROCKSDB_LITE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions" )
endif ( )
add_definitions ( -DWIN32 -DOS_WIN -D_MBCS -DWIN64 -DNOMINMAX )
if ( CMAKE_SYSTEM_NAME MATCHES "Cygwin" )
add_definitions ( -fno-builtin-memcmp -DCYGWIN )
elseif ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
add_definitions ( -DOS_MACOSX )
if ( CMAKE_SYSTEM_PROCESSOR MATCHES arm )
add_definitions ( -DIOS_CROSS_COMPILE -DROCKSDB_LITE )
# n o d e b u g i n f o f o r I O S , t h a t w i l l m a k e o u r l i b r a r y b i g
add_definitions ( -DNDEBUG )
endif ( )
elseif ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
add_definitions ( -DOS_LINUX )
elseif ( CMAKE_SYSTEM_NAME MATCHES "SunOS" )
add_definitions ( -DOS_SOLARIS )
elseif ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
add_definitions ( -DOS_FREEBSD )
elseif ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
add_definitions ( -DOS_NETBSD )
elseif ( CMAKE_SYSTEM_NAME MATCHES "OpenBSD" )
add_definitions ( -DOS_OPENBSD )
elseif ( CMAKE_SYSTEM_NAME MATCHES "DragonFly" )
add_definitions ( -DOS_DRAGONFLYBSD )
elseif ( CMAKE_SYSTEM_NAME MATCHES "Android" )
add_definitions ( -DOS_ANDROID )
elseif ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
add_definitions ( -DWIN32 -DOS_WIN -D_MBCS -DWIN64 -DNOMINMAX )
endif ( )
if ( NOT WIN32 )
add_definitions ( -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX )
endif ( )
option ( WITH_FALLOCATE "build with fallocate" ON )
if ( WITH_FALLOCATE )
include ( CheckCSourceCompiles )
CHECK_C_SOURCE_COMPILES ( "
# i n c l u d e < f c n t l . h >
# i n c l u d e < l i n u x / f a l l o c . h >
i n t main ( ) {
i n t f d = open ( \"/dev/null\", 0 ) ;
fallocate ( fd, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, 0, 1024 ) ;
}
" H A V E _ F A L L O C A T E )
if ( HAVE_FALLOCATE )
add_definitions ( -DROCKSDB_FALLOCATE_PRESENT )
endif ( )
endif ( )
include ( CheckFunctionExists )
CHECK_FUNCTION_EXISTS ( malloc_usable_size HAVE_MALLOC_USABLE_SIZE )
if ( HAVE_MALLOC_USABLE_SIZE )
add_definitions ( -DROCKSDB_MALLOC_USABLE_SIZE )
endif ( )
include_directories ( ${ PROJECT_SOURCE_DIR } )
include_directories ( ${ PROJECT_SOURCE_DIR } /include )
include_directories ( ${ PROJECT_SOURCE_DIR } /third-party/gtest-1.7.0/fused-src )
include_directories ( SYSTEM ${ PROJECT_SOURCE_DIR } /third-party/gtest-1.7.0/fused-src )
set ( ROCKSDB_LIBS rocksdblib ${ ARTIFACT_SUFFIX } )
set ( THIRDPARTY_LIBS ${ THIRDPARTY_LIBS } gtest )
set ( SYSTEM_LIBS ${ SYSTEM_LIBS } Shlwapi.lib Rpcrt4.lib )
find_package ( Threads REQUIRED )
if ( WIN32 )
set ( SYSTEM_LIBS ${ SYSTEM_LIBS } Shlwapi.lib Rpcrt4.lib )
else ( )
set ( SYSTEM_LIBS ${ CMAKE_THREAD_LIBS_INIT } )
endif ( )
set ( ROCKSDB_LIBS rocksdblib ${ ARTIFACT_SUFFIX } )
set ( LIBS ${ ROCKSDB_LIBS } ${ THIRDPARTY_LIBS } ${ SYSTEM_LIBS } )
add_subdirectory ( third-party/gtest-1.7.0/fused-src/gtest )
add_subdirectory ( tools )
# M a i n l i b r a r y s o u r c e c o d e
set ( SOURCES
d b / a u t o _ r o l l _ l o g g e r . c c
d b / b u i l d e r . c c
@ -153,12 +293,6 @@ set(SOURCES
m e m t a b l e / s k i p l i s t r e p . c c
m e m t a b l e / v e c t o r r e p . c c
p o r t / s t a c k _ t r a c e . c c
p o r t / w i n / i o _ w i n . c c
p o r t / w i n / e n v _ w i n . c c
p o r t / w i n / e n v _ d e f a u l t . c c
p o r t / w i n / p o r t _ w i n . c c
p o r t / w i n / w i n _ l o g g e r . c c
p o r t / w i n / x p r e s s _ w i n . c c
t a b l e / a d a p t i v e _ t a b l e _ f a c t o r y . c c
t a b l e / b l o c k . c c
t a b l e / b l o c k _ b a s e d _ f i l t e r _ b l o c k . c c
@ -192,7 +326,6 @@ set(SOURCES
t o o l s / d u m p / d b _ d u m p _ t o o l . c c
u t i l / a r e n a . c c
u t i l / b l o o m . c c
u t i l / b u i l d _ v e r s i o n . c c
u t i l / c f _ o p t i o n s . c c
u t i l / c l o c k _ c a c h e . c c
u t i l / c o d i n g . c c
@ -238,7 +371,6 @@ set(SOURCES
u t i l / s t a t u s _ m e s s a g e . c c
u t i l / s t r i n g _ u t i l . c c
u t i l / s y n c _ p o i n t . c c
u t i l / t e s t h a r n e s s . c c
u t i l / t e s t u t i l . c c
u t i l / t h r e a d _ l o c a l . c c
u t i l / t h r e a d p o o l _ i m p . c c
@ -293,56 +425,56 @@ set(SOURCES
u t i l i t i e s / c o l _ b u f _ e n c o d e r . c c
u t i l i t i e s / c o l _ b u f _ d e c o d e r . c c
u t i l i t i e s / c o l u m n _ a w a r e _ e n c o d i n g _ u t i l . c c
)
$ < T A R G E T _ O B J E C T S : b u i l d _ v e r s i o n > )
if ( WIN32 )
list ( APPEND SOURCES
p o r t / w i n / i o _ w i n . c c
p o r t / w i n / e n v _ w i n . c c
p o r t / w i n / e n v _ d e f a u l t . c c
p o r t / w i n / p o r t _ w i n . c c
p o r t / w i n / w i n _ l o g g e r . c c
p o r t / w i n / x p r e s s _ w i n . c c )
else ( )
list ( APPEND SOURCES
p o r t / p o r t _ p o s i x . c c
u t i l / e n v _ p o s i x . c c
u t i l / i o _ p o s i x . c c )
endif ( )
# F o r t e s t u t i l l i b r a r y t h a t i s b u i l d o n l y i n D E B U G m o d e
# a n d l i n k e d t o t e s t s . A d d t e s t o n l y c o d e t h a t i s n o t # i f d e f e d f o r R e l e a s e h e r e .
set ( TESTUTIL_SOURCE
d b / d b _ t e s t _ u t i l . c c
t a b l e / m o c k _ t a b l e . c c
u t i l / m o c k _ e n v . c c
u t i l / f a u l t _ i n j e c t i o n _ t e s t _ e n v . c c
u t i l / t h r e a d _ s t a t u s _ u p d a t e r _ d e b u g . c c
)
option ( WITH_LIBRADOS "Build with librados" OFF )
if ( WITH_LIBRADOS )
list ( APPEND SOURCES
u t i l i t i e s / e n v _ l i b r a d o s . c c )
list ( APPEND THIRDPARTY_LIBS rados )
endif ( )
add_library ( rocksdblib ${ ARTIFACT_SUFFIX } ${ SOURCES } )
set_target_properties ( rocksdblib ${ ARTIFACT_SUFFIX } PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/rocksdblib${ARTIFACT_SUFFIX}.pdb" )
add_dependencies ( rocksdblib ${ ARTIFACT_SUFFIX } GenerateBuildVersion )
add_library ( rocksdblib ${ ARTIFACT_SUFFIX } STATIC ${ SOURCES } )
target_link_libraries ( rocksdblib ${ ARTIFACT_SUFFIX }
$ { T H I R D P A R T Y _ L I B S } $ { S Y S T E M _ L I B S } )
if ( WIN32 )
set_target_properties ( rocksdblib ${ ARTIFACT_SUFFIX } PROPERTIES
C O M P I L E _ F L A G S " / F d $ { C M A K E _ C F G _ I N T D I R } / r o c k s d b l i b $ { A R T I F A C T _ S U F F I X } . p d b " )
endif ( )
add_library ( rocksdb ${ ARTIFACT_SUFFIX } SHARED ${ SOURCES } )
set_target_properties ( rocksdb ${ ARTIFACT_SUFFIX } PROPERTIES COMPILE_FLAGS "-DROCKSDB_DLL -DROCKSDB_LIBRARY_EXPORTS /Fd${CMAKE_CFG_INTDIR}/rocksdb${ARTIFACT_SUFFIX}.pdb" )
add_dependencies ( rocksdb ${ ARTIFACT_SUFFIX } GenerateBuildVersion )
target_link_libraries ( rocksdb ${ ARTIFACT_SUFFIX } ${ LIBS } )
if ( DEFINED JNI )
if ( ${ JNI } EQUAL 1 )
message ( STATUS "JNI library is enabled" )
add_subdirectory ( ${ CMAKE_CURRENT_SOURCE_DIR } /java )
else ( )
message ( STATUS "JNI library is disabled" )
endif ( )
target_link_libraries ( rocksdb ${ ARTIFACT_SUFFIX }
$ { T H I R D P A R T Y _ L I B S } $ { S Y S T E M _ L I B S } )
if ( WIN32 )
set_target_properties ( rocksdb ${ ARTIFACT_SUFFIX } PROPERTIES
C O M P I L E _ F L A G S " - D R O C K S D B _ D L L - D R O C K S D B _ L I B R A R Y _ E X P O R T S / F d $ { C M A K E _ C F G _ I N T D I R } / r o c k s d b $ { A R T I F A C T _ S U F F I X } . p d b " )
endif ( )
option ( WITH_JNI "build with JNI" OFF )
if ( WITH_JNI OR JNI )
message ( STATUS "JNI library is enabled" )
add_subdirectory ( ${ CMAKE_CURRENT_SOURCE_DIR } /java )
else ( )
message ( STATUS "JNI library is disabled" )
endif ( )
set ( APPS
t o o l s / d b _ b e n c h . c c
d b / m e m t a b l e r e p _ b e n c h . c c
t a b l e / t a b l e _ r e a d e r _ b e n c h . c c
t o o l s / d b _ s t r e s s . c c
t o o l s / w r i t e _ s t r e s s . c c
t o o l s / d b _ r e p l _ s t r e s s . c c
t o o l s / l d b . c c
t o o l s / s s t _ d u m p . c c
t o o l s / d u m p / r o c k s d b _ d u m p . c c
t o o l s / d u m p / r o c k s d b _ u n d u m p . c c
u t i l / c a c h e _ b e n c h . c c
u t i l i t i e s / p e r s i s t e n t _ c a c h e / h a s h _ t a b l e _ b e n c h . c c
u t i l i t i e s / c o l u m n _ a w a r e _ e n c o d i n g _ e x p . c c
)
set ( C_TESTS db/c_test.c )
set ( TESTS
d b / a u t o _ r o l l _ l o g g e r _ t e s t . c c
d b / c o l u m n _ f a m i l y _ t e s t . c c
@ -409,7 +541,6 @@ set(TESTS
t a b l e / f u l l _ f i l t e r _ b l o c k _ t e s t . c c
t a b l e / m e r g e r _ t e s t . c c
t a b l e / t a b l e _ t e s t . c c
t o o l s / d b _ s a n i t y _ t e s t . c c
t o o l s / l d b _ c m d _ t e s t . c c
t o o l s / r e d u c e _ l e v e l s _ t e s t . c c
t o o l s / s s t _ d u m p _ t e s t . c c
@ -461,20 +592,42 @@ set(TESTS
u t i l i t i e s / w r i t e _ b a t c h _ w i t h _ i n d e x / w r i t e _ b a t c h _ w i t h _ i n d e x _ t e s t . c c
u t i l i t i e s / c o l u m n _ a w a r e _ e n c o d i n g _ t e s t . c c
)
if ( WITH_LIBRADOS )
list ( APPEND TESTS utilities/env_librados_test.cc )
endif ( )
set ( EXES ${ APPS } )
foreach ( sourcefile ${ EXES } )
string ( REPLACE ".cc" "" exename ${ sourcefile } )
string ( REGEX REPLACE "^((.+)/)+" "" exename ${ exename } )
add_executable ( ${ exename } ${ ARTIFACT_SUFFIX } ${ sourcefile } )
target_link_libraries ( ${ exename } ${ ARTIFACT_SUFFIX } ${ LIBS } )
endforeach ( sourcefile ${ EXES } )
set ( BENCHMARKS
t o o l s / d b _ b e n c h . c c
t a b l e / t a b l e _ r e a d e r _ b e n c h . c c
u t i l / c a c h e _ b e n c h . c c
d b / m e m t a b l e r e p _ b e n c h . c c
u t i l i t i e s / c o l u m n _ a w a r e _ e n c o d i n g _ e x p . c c
u t i l i t i e s / p e r s i s t e n t _ c a c h e / h a s h _ t a b l e _ b e n c h . c c )
add_library ( testharness OBJECT util/testharness.cc )
foreach ( sourcefile ${ BENCHMARKS } )
get_filename_component ( exename ${ sourcefile } NAME_WE )
add_executable ( ${ exename } ${ ARTIFACT_SUFFIX } ${ sourcefile }
$ < T A R G E T _ O B J E C T S : t e s t h a r n e s s > )
target_link_libraries ( ${ exename } ${ ARTIFACT_SUFFIX } ${ LIBS } gtest )
endforeach ( sourcefile ${ BENCHMARKS } )
# F o r t e s t u t i l l i b r a r y t h a t i s b u i l d o n l y i n D E B U G m o d e
# a n d l i n k e d t o t e s t s . A d d t e s t o n l y c o d e t h a t i s n o t # i f d e f e d f o r R e l e a s e h e r e .
set ( TESTUTIL_SOURCE
d b / d b _ t e s t _ u t i l . c c
t a b l e / m o c k _ t a b l e . c c
u t i l / m o c k _ e n v . c c
u t i l / f a u l t _ i n j e c t i o n _ t e s t _ e n v . c c
u t i l / t h r e a d _ s t a t u s _ u p d a t e r _ d e b u g . c c
)
# t e s t u t i l i t i e s a r e o n l y b u i l d i n d e b u g
enable_testing ( )
add_custom_target ( check COMMAND ${ CMAKE_CTEST_COMMAND } )
set ( TESTUTILLIB testutillib ${ ARTIFACT_SUFFIX } )
add_library ( ${ TESTUTILLIB } STATIC ${ TESTUTIL_SOURCE } )
set_target_properties ( ${ TESTUTILLIB } PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/testutillib${ARTIFACT_SUFFIX}.pdb" )
if ( WIN32 )
set_target_properties ( ${ TESTUTILLIB } PROPERTIES COMPILE_FLAGS "/Fd${CMAKE_CFG_INTDIR}/testutillib${ARTIFACT_SUFFIX}.pdb" )
endif ( )
set_target_properties ( ${ TESTUTILLIB }
P R O P E R T I E S E X C L U D E _ F R O M _ D E F A U L T _ B U I L D _ R E L E A S E 1
E X C L U D E _ F R O M _ D E F A U L T _ B U I L D _ M I N R E L E A S E 1
@ -485,18 +638,23 @@ set_target_properties(${TESTUTILLIB}
set ( TEST_EXES ${ TESTS } )
foreach ( sourcefile ${ TEST_EXES } )
string ( REPLACE ".cc" "" exename ${ sourcefile } )
string ( REGEX REPLACE "^((.+)/)+" "" exename ${ exename } )
add_executable ( ${ exename } ${ ARTIFACT_SUFFIX } ${ sourcefile } )
get_filename_component ( exename ${ sourcefile } NAME_WE )
add_executable ( ${ exename } ${ ARTIFACT_SUFFIX } ${ sourcefile }
$ < T A R G E T _ O B J E C T S : t e s t h a r n e s s > )
set_target_properties ( ${ exename } ${ ARTIFACT_SUFFIX }
P R O P E R T I E S E X C L U D E _ F R O M _ D E F A U L T _ B U I L D _ R E L E A S E 1
E X C L U D E _ F R O M _ D E F A U L T _ B U I L D _ M I N R E L E A S E 1
E X C L U D E _ F R O M _ D E F A U L T _ B U I L D _ R E L W I T H D E B I N F O 1
)
target_link_libraries ( ${ exename } ${ ARTIFACT_SUFFIX } ${ LIBS } testutillib ${ ARTIFACT_SUFFIX } )
target_link_libraries ( ${ exename } ${ ARTIFACT_SUFFIX } testutillib ${ ARTIFACT_SUFFIX } ${ LIBS } gtest )
if ( NOT "${exename}" MATCHES "db_sanity_test" )
add_test ( NAME ${ exename } COMMAND ${ exename } ${ ARTIFACT_SUFFIX } )
add_dependencies ( check ${ exename } ${ ARTIFACT_SUFFIX } )
endif ( )
endforeach ( sourcefile ${ TEST_EXES } )
# C e x e c u t a b l e s m u s t l i n k t o a s h a r e d o b j e c t
set ( C_TESTS db/c_test.c )
set ( C_TEST_EXES ${ C_TESTS } )
foreach ( sourcefile ${ C_TEST_EXES } )
@ -509,4 +667,6 @@ foreach(sourcefile ${C_TEST_EXES})
E X C L U D E _ F R O M _ D E F A U L T _ B U I L D _ R E L W I T H D E B I N F O 1
)
target_link_libraries ( ${ exename } ${ ARTIFACT_SUFFIX } rocksdb ${ ARTIFACT_SUFFIX } testutillib ${ ARTIFACT_SUFFIX } )
add_test ( NAME ${ exename } COMMAND ${ exename } ${ ARTIFACT_SUFFIX } )
add_dependencies ( check ${ exename } ${ ARTIFACT_SUFFIX } )
endforeach ( sourcefile ${ C_TEST_EXES } )