Skip to content

Commit

Permalink
[#feature] cmake file for blackwidow tests(#1226)
Browse files Browse the repository at this point in the history
Signed-off-by: tangruilin <tang.ruilin@foxmail.com>
  • Loading branch information
Tangruilin committed Feb 9, 2023
1 parent fdaddd2 commit 653a5ed
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ tags
make_config.mk
src/*.d
src/build_version.cc

#cache
.cache
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized" CACHE STRING "Set C++ Compiler Flags" FORCE)

find_package(Snappy REQUIRED)
find_package(GTest REQUIRED)

# rocksdb option
set(WITH_SNAPPY ON)
Expand Down
7 changes: 5 additions & 2 deletions src/blackwidow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ cmake_minimum_required (VERSION 3.10)
set (CMAKE_CXX_STANDARD 17)
project (blackwidow)

# Other CMake modules
add_subdirectory(tests)

add_definitions(-DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX)

aux_source_directory(./src DIR_SRCS)

add_library(blackwidow STATIC ${DIR_SRCS} )

target_include_directories(blackwidow
target_include_directories(blackwidow
PUBLIC ${PROJECT_SOURCE_DIR}/include
)
target_include_directories(blackwidow
target_include_directories(blackwidow
PUBLIC ${PROJECT_SOURCE_DIR}
PUBLIC ${PROJECT_SOURCE_DIR}/../../third/rocksdb/include
PUBLIC ${PROJECT_SOURCE_DIR}/../../third/rocksdb
Expand Down
28 changes: 28 additions & 0 deletions src/blackwidow/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.10)

include(GoogleTest)

file(GLOB_RECURSE BLACKWINDOW_TEST_SOURCE "${PROJECT_SOURCE_DIR}/tests/*.cc")

aux_source_directory(../stc TEST_SRCS)

foreach(blackwindow_test_source ${BLACKWINDOW_TEST_SOURCE})
get_filename_component(blackwidow_test_filename ${blackwindow_test_source} NAME)
message(${blackwidow_test_filename})
string(REPLACE ".cc" "" blackwindow_test_name ${blackwidow_test_filename})

# Add the test target
add_executable(${blackwindow_test_name} ${blackwindow_test_source})
target_include_directories(${blackwindow_test_name}
PUBLIC ${PROJECT_SOURCE_DIR}/include
PUBLIC ${PROJECT_SOURCE_DIR}/../../third/rocksdb/include
PUBLIC ${PROJECT_SOURCE_DIR}/../../third/rocksdb
PUBLIC ${PROJECT_SOURCE_DIR}/..
)
target_link_libraries(${blackwindow_test_name}
PUBLIC gtest
PUBLIC slash
PUBLIC rocksdb
PUBLIC blackwidow
)
endforeach(blackwindow_test_source ${BLACKWINDOW_TEST_SOURCE})
28 changes: 0 additions & 28 deletions src/blackwidow/tests/main.cc

This file was deleted.

0 comments on commit 653a5ed

Please sign in to comment.