Skip to content

Commit

Permalink
Add googletest in thirdparty.
Browse files Browse the repository at this point in the history
Signed-off-by: Henner Zeller <[email protected]>
  • Loading branch information
hzeller committed Sep 21, 2021
1 parent caf1067 commit 1f067d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[submodule "third_party/capnproto"]
path = third_party/capnproto
url = https://github.com/capnproto/capnproto.git


[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ message(STATUS "Python3_EXECUTABLE = ${Python3_EXECUTABLE}")

set(BUILD_TESTING OFF CACHE BOOL "Don't build capnproto tests")
add_subdirectory(third_party/capnproto EXCLUDE_FROM_ALL)
add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -229,6 +230,7 @@ add_dependencies(GenerateCode capnpc capnp_tool capnpc_cpp)

if (UHDM_BUILD_TESTS)
enable_testing()
include(GoogleTest)
# All unit-tests are registered with this custom target as dependency, so
# just `make UnitTests` will build them all.
add_custom_target(UnitTests)
Expand All @@ -240,11 +242,14 @@ if (UHDM_BUILD_TESTS)
get_filename_component(test_prefix ${test_cc_file} DIRECTORY)

add_executable(${test_bin} ${PROJECT_SOURCE_DIR}/${test_cc_file})
target_link_libraries(${test_bin} PRIVATE uhdm)
target_include_directories(${test_bin} PRIVATE
third_party/googletest/googletest/include
third_party/googletest/googlemock/include)
target_link_libraries(${test_bin} PRIVATE uhdm gtest gmock gtest_main)
add_test(
NAME ${test_prefix}/${test_bin} COMMAND ${test_bin}
WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")

#gtest_add_tests(TARGET ${test_cc_file})
# Now, add this binary to our UnitTests target that it builds this
add_dependencies(UnitTests ${test_bin})
endforeach()
Expand Down
1 change: 1 addition & 0 deletions third_party/googletest
Submodule googletest added at e2239e

0 comments on commit 1f067d2

Please sign in to comment.