Skip to content

Commit

Permalink
Set working directory for tests and allow not linking to mock and mai…
Browse files Browse the repository at this point in the history
…n. (#35)
  • Loading branch information
Holt59 committed Aug 9, 2024
1 parent 0185ac7 commit 434f71f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions mo2_cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,18 @@ endfunction()
# OFF by default
#
function(mo2_configure_tests TARGET)
cmake_parse_arguments(MO2 "NO_MOCK;NO_MAIN" "" "" ${ARGN})
mo2_configure_target(${TARGET} TRANSLATIONS OFF AUTOMOC OFF ${ARGN})

find_package(GTest REQUIRED)
target_link_libraries(${TARGET} PRIVATE GTest::gtest GTest::gmock GTest::gtest_main)
target_link_libraries(${TARGET} PRIVATE GTest::gtest)

if (NOT MO2_NO_MOCK)
target_link_libraries(${TARGET} PRIVATE GTest::gmock)
endif()
if (NOT MO2_NO_MAIN)
target_link_libraries(${TARGET} PRIVATE GTest::gtest_main)
endif()

# gtest_discover_tests would be nice but it requires Qt DLL, uibase, etc., in the
# path, etc., and is not working right now
Expand All @@ -281,7 +289,10 @@ function(mo2_configure_tests TARGET)
# )
#

gtest_add_tests(TARGET ${TARGET} TEST_LIST ${TARGET}_gtests)
gtest_add_tests(
TARGET ${TARGET}
TEST_LIST ${TARGET}_gtests
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
set(${TARGET}_gtests ${${TARGET}_gtests} PARENT_SCOPE)

mo2_deploy_qt_for_tests(
Expand Down

0 comments on commit 434f71f

Please sign in to comment.