Skip to content

Commit

Permalink
Modified: GTest linking from submodule in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
s-bose7 committed Jun 20, 2024
1 parent 88b8523 commit efcd6e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
sudo apt-get install -y libsnappy-dev
- name: Configure CMake
run: mkdir build && cd build && cmake ..
run: mkdir build && cd build && cmake -DUSE_SUBMODULE_GTEST=ON ..

- name: Build
run: cd build && make
Expand Down
20 changes: 17 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,28 @@ find_package(Snappy REQUIRED)
include_directories(${SNAPPY_INCLUDE_DIRS})
target_link_libraries(MemCache ${SNAPPY_LIBRARIES})


# Option to use submodule for googletest
option(USE_SUBMODULE_GTEST "Use googletest from submodule" OFF)

# Add Google Test
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
if(USE_SUBMODULE_GTEST)
# Use googletest from submodule
add_subdirectory(extern/googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
target_link_libraries(MemCache gtest gtest_main)

else()
# Use system-installed googletest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

endif()

# Add test executable
add_executable(run_tests
tests/test_memcache.cpp
tests/test_thread_safety.cpp
tests/test_atomicity.cpp
)
target_link_libraries(run_tests ${GTEST_LIBRARIES} pthread MemCache)
target_link_libraries(run_tests gtest gtest_main pthread MemCache)

0 comments on commit efcd6e8

Please sign in to comment.