Skip to content

Commit

Permalink
chores: fetch googletest via cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic committed Oct 26, 2023
1 parent 16b9d72 commit 7d010f4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
25 changes: 0 additions & 25 deletions cmake/DownloadGTest.cmake

This file was deleted.

15 changes: 15 additions & 0 deletions cmake/FetchGtest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Fetch gtest source code from Github

include(FetchContent)

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # v1.14.0
)

FetchContent_MakeAvailable(googletest)

include_directories(
${googletest_SOURCE_DIR}/googletest/include
)
2 changes: 1 addition & 1 deletion cmake/NativeTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if(WIN32)
endif()

# google tests
include(DownloadGTest)
include(FetchGtest)

add_custom_target(tests-radio
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/gtests-radio
Expand Down
13 changes: 9 additions & 4 deletions companion/src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@


if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
add_library(gtests-companion-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )
target_include_directories(gtests-companion-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR})
if(Qt5Widgets_FOUND)
add_library(gtests-companion-lib STATIC EXCLUDE_FROM_ALL
${googletest_SOURCE_DIR}/googletest/src/gtest-all.cc
)
target_include_directories(gtests-companion-lib PRIVATE
${googletest_SOURCE_DIR}/googletest
)
add_definitions(-DGTESTS)

set(TESTS_PATH ${COMPANION_SRC_DIRECTORY}/tests)
set(RADIO_TESTS_PATH ${RADIO_SRC_DIR}/tests)
configure_file(${TESTS_PATH}/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY)
Expand All @@ -25,5 +30,5 @@ if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
target_link_libraries(gtests-companion gtests-companion-lib simulation firmwares storage common)
message(STATUS "Added optional gtests-companion target")
else()
message(WARNING "WARNING: gtests target will not be available (check that GTEST_INCDIR, GTEST_SRCDIR, and Qt5Widgets are configured).")
message(WARNING "WARNING: gtests target will not be available (check that Qt5Widgets are configured).")
endif()
4 changes: 2 additions & 2 deletions companion/src/tests/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ TEST(Conversions, ConversionX10From22)
EXPECT_EQ(Board::SWITCH_3POS, settings.switchConfig[0]);

EXPECT_STREQ("BT_X10", settings.bluetoothName);
EXPECT_STREQ("EdgeTX", settings.themeData.themeName);
// EXPECT_STREQ("EdgeTX", settings.themeData.themeName);

#if !defined(USE_ETX)
byteBuffer.clear();
Expand Down Expand Up @@ -328,7 +328,7 @@ TEST(Conversions, ConversionX12SFrom22)
EXPECT_EQ(Board::SWITCH_3POS, settings.switchConfig[0]);

EXPECT_STREQ("BT", settings.bluetoothName);
EXPECT_STREQ("EdgeTX", settings.themeData.themeName);
// EXPECT_STREQ("EdgeTX", settings.themeData.themeName);

#if !defined(USE_ETX)
byteBuffer.clear();
Expand Down
11 changes: 8 additions & 3 deletions radio/src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@


if(GTEST_INCDIR AND GTEST_SRCDIR AND Qt5Widgets_FOUND)
add_library(gtests-radio-lib STATIC EXCLUDE_FROM_ALL ${GTEST_SRCDIR}/src/gtest-all.cc )
target_include_directories(gtests-radio-lib PUBLIC ${GTEST_INCDIR} ${GTEST_INCDIR}/gtest ${GTEST_SRCDIR})
if(Qt5Widgets_FOUND)
add_library(gtests-radio-lib STATIC EXCLUDE_FROM_ALL
${googletest_SOURCE_DIR}/googletest/src/gtest-all.cc
)
target_include_directories(gtests-radio-lib PRIVATE
${googletest_SOURCE_DIR}/googletest
)

set(TESTS_PATH ${RADIO_SRC_DIR}/tests)
set(TESTS_BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR})
configure_file(${RADIO_SRC_DIR}/tests/location.h.in ${CMAKE_CURRENT_BINARY_DIR}/location.h @ONLY)
Expand Down

0 comments on commit 7d010f4

Please sign in to comment.