Skip to content

Commit

Permalink
build: rely on gtest_main target instead of custom (#4396)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackgerrits authored Dec 28, 2022
1 parent 3a48e34 commit 7c1d200
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions cmake/VowpalWabbitUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,6 @@ 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 @@ -286,13 +276,11 @@ function(vw_add_test_executable)

vw_get_test_target(FULL_TEST_NAME ${VW_TEST_FOR_LIB})

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})
add_executable(${FULL_TEST_NAME} ${VW_TEST_SOURCES})
target_link_libraries(${FULL_TEST_NAME} PUBLIC
${FULL_FOR_LIB_NAME}
${VW_TEST_EXTRA_DEPS}
GTest::gmock GTest::gtest
GTest::gmock GTest::gtest_main
)
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 7c1d200

Please sign in to comment.