Skip to content
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

[#feature 1226] cmake file for blackwidow tests #1246

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

项目的主CMakeList.txt 需要添加下findpackage(gtest)


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.