Skip to content

Commit

Permalink
Merge pull request #345 from gpospelov/remove-gtest
Browse files Browse the repository at this point in the history
Remove gtest
  • Loading branch information
gpospelov authored Aug 11, 2024
2 parents 86c9134 + e6dee74 commit 964e1f6
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 42 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: setup dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ccache \
cmake qt5-default qttools5-dev libqt5svg5-dev qtdeclarative5-dev libx11-xcb1
cmake qt5-default qttools5-dev libqt5svg5-dev qtdeclarative5-dev libx11-xcb1 libgtest-dev
- name: ccache timestamp
id: ccache_cache_timestamp
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: dependencies
run: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Install Qt
uses: jurplel/install-qt-action@v2
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ Main features of the framework are:
## Requirements

+ C++-17
+ CMake 3.14
+ Qt 5.12
+ CMake >= 3.14
+ Qt >= 5.12
+ gtest >= 1.10

## Installation instructions

```sh
git clone --recurse-submodules https://github.com/gpospelov/qt-mvvm.git
git clone https://github.com/gpospelov/qt-mvvm.git
mkdir ./build; cd ./build
cmake ..; make -j8; ctest

Expand Down
11 changes: 11 additions & 0 deletions cmake/modules/CodeTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ function(project_testcoverage_setup)
)
endfunction()

# Fetches google test version 1.12.1
function(fetch_googletest)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850)
FetchContent_MakeAvailable(googletest)
message(VERBOSE "GTest binaries are present at ${googletest_BINARY_DIR}")
endfunction()

# Setups targets for code processing.

function(project_codetools_setup)
Expand Down
12 changes: 12 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
enable_testing()

find_package(GTest 1.10 QUIET CONFIG)
if (NOT GTest_FOUND)
message(WARNING "GTest with version >= \"1.10\" was not found, fetching from internet" )
fetch_googletest()
endif()
find_package_message(
GTest_DETAILS
"Found GTest: ${GTest_DIR} (version \"${GTest_VERSION}\")"
"[${GTest_FOUND}][${GTest_DIR}][v${GTest_VERSION}]")

include(GoogleTest)

if(WIN32)
Expand Down
6 changes: 1 addition & 5 deletions tests/libtestmachinery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ set(library_name testmachinery)
file(GLOB source_files "*.cpp")
file(GLOB include_files "*.h")

if(WIN32)
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY)
endif()

add_library(${library_name} STATIC ${source_files} ${include_files})
target_link_libraries(${library_name} gtest gmock Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_model)
target_link_libraries(${library_name} PUBLIC GTest::gtest GTest::gmock Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_model)
target_include_directories(${library_name} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}> $<BUILD_INTERFACE:${MVVM_AUTOGEN_DIR}>)

Expand Down
2 changes: 1 addition & 1 deletion tests/testintegration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

set(CMAKE_AUTOMOC ON)
add_executable(${test} ${source_files} ${include_files})
target_link_libraries(${test} gtest gmock Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Test mvvm_view testmachinery qcustomplot)
target_link_libraries(${test} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Test mvvm_view testmachinery qcustomplot)

if (MVVM_DISCOVER_TESTS)
gtest_discover_tests(${test} TEST_PREFIX "Integration.")
Expand Down
2 changes: 1 addition & 1 deletion tests/testmodel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

set(CMAKE_AUTOMOC ON)
add_executable(${test} ${source_files} ${include_files})
target_link_libraries(${test} gtest gmock Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_model testmachinery)
target_link_libraries(${test} Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_model testmachinery)

if (MVVM_DISCOVER_TESTS)
gtest_discover_tests(${test} TEST_PREFIX "Model.")
Expand Down
2 changes: 1 addition & 1 deletion tests/testview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

set(CMAKE_AUTOMOC ON)
add_executable(${test} ${source_files} ${include_files})
target_link_libraries(${test} gtest gmock Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_view testmachinery qcustomplot)
target_link_libraries(${test} Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_view testmachinery qcustomplot)

if (MVVM_DISCOVER_TESTS)
gtest_discover_tests(${test} TEST_PREFIX "View.")
Expand Down
2 changes: 1 addition & 1 deletion tests/testviewmodel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})

set(CMAKE_AUTOMOC ON)
add_executable(${test} ${source_files} ${include_files})
target_link_libraries(${test} gtest gmock Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_viewmodel testmachinery qcustomplot)
target_link_libraries(${test} Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Test mvvm_viewmodel testmachinery qcustomplot)

if (MVVM_DISCOVER_TESTS)
gtest_discover_tests(${test} TEST_PREFIX "View.")
Expand Down
3 changes: 0 additions & 3 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
if(BUILD_TESTING)
add_subdirectory(gtest)
endif(BUILD_TESTING)
add_subdirectory(qcustomplot)
16 changes: 0 additions & 16 deletions thirdparty/gtest/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion thirdparty/gtest/googletest
Submodule googletest deleted from 9741c4

0 comments on commit 964e1f6

Please sign in to comment.