Skip to content

Commit

Permalink
gtest: build in cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
fchn289 committed Aug 19, 2024
1 parent cf94d3e commit b61d208
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
run: sudo apt-get update && sudo apt-get install valgrind

- name: install gmock & gtest # 1)always gtest latest 2)--depth 1 is to min download
run: pwd && git clone https://github.com/google/googletest.git --depth 1 && cd googletest && mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr && sudo make install -j
run: cd .. && git clone https://github.com/google/googletest.git --depth 1

- uses: actions/checkout@v4

- name: make ut
run: pwd && cmake -DCOV=1 -DCMAKE_CXX_COMPILER="g++" . && make -j
run: cmake -DCOV=1 -DCMAKE_CXX_COMPILER="g++" . && make -j

- name: ut
run: SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --log-file=ut/gcovr/cov.valgrind.log --error-exitcode=6 ./ut_exe --gtest_brief=1
Expand Down
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,21 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") # inc branch covera

add_executable(ut_exe)

set(gtest_dir ${CMAKE_CURRENT_SOURCE_DIR}/../googletest)
add_subdirectory(${gtest_dir} ${CMAKE_BINARY_DIR}/googletest)
add_subdirectory(src)
add_subdirectory(ut)

target_link_libraries(ut_exe PRIVATE
lib_domino
lib_ut
gtest_main
lib_domino
lib_ut
gtest_main
)

# ------------------------------------------------------------------------------------------------
# make run-ut_exe
add_custom_target(run
COMMAND ./ut_exe --gtest_brief=0
DEPENDS ut_exe
COMMAND ./ut_exe --gtest_brief=0
DEPENDS ut_exe
)

# simplify "make help"
Expand Down

0 comments on commit b61d208

Please sign in to comment.