Skip to content

Commit

Permalink
Revert "build: rely on gtest_main target instead of custom (#4396)"
Browse files Browse the repository at this point in the history
This reverts commit 7c1d200.
  • Loading branch information
jackgerrits authored Dec 28, 2022
1 parent 863f04f commit 0e7e3b4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmake/VowpalWabbitUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ function(vw_add_executable)
endif()
endfunction()


set(GTEST_MAIN_FILE_CONTENTS "#include <gtest/gtest.h>\n\
\n\
int main(int argc, char** argv)\n\
{\n\
::testing::InitGoogleTest(&argc, argv);\n\
return RUN_ALL_TESTS();\n\
}\n"
)

function(vw_add_test_executable)
cmake_parse_arguments(VW_TEST
""
Expand All @@ -276,11 +286,13 @@ function(vw_add_test_executable)

vw_get_test_target(FULL_TEST_NAME ${VW_TEST_FOR_LIB})

add_executable(${FULL_TEST_NAME} ${VW_TEST_SOURCES})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${FULL_TEST_NAME}_main.cc "${GTEST_MAIN_FILE_CONTENTS}")

add_executable(${FULL_TEST_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${FULL_TEST_NAME}_main.cc ${VW_TEST_SOURCES})
target_link_libraries(${FULL_TEST_NAME} PUBLIC
${FULL_FOR_LIB_NAME}
${VW_TEST_EXTRA_DEPS}
GTest::gmock GTest::gtest_main
GTest::gmock GTest::gtest
)
target_compile_definitions(${FULL_TEST_NAME} PRIVATE ${VW_TEST_COMPILE_DEFS})
target_compile_options(${FULL_TEST_NAME} PRIVATE ${WARNING_OPTIONS} ${WARNING_AS_ERROR_OPTIONS})
Expand Down

0 comments on commit 0e7e3b4

Please sign in to comment.