File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,14 @@ project(scratchcpp-player VERSION 0.1 LANGUAGES CXX)
55set (CMAKE_AUTOMOC ON )
66set (CMAKE_CXX_STANDARD_REQUIRED ON )
77
8+ option (SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS "Build unit tests" ON )
9+
810find_package (Qt6 6.6 COMPONENTS Quick QuickControls2 REQUIRED)
911
12+ if (SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS)
13+ find_package (Qt6 6.6 COMPONENTS Test REQUIRED)
14+ endif ()
15+
1016add_subdirectory (src)
1117add_subdirectory (res)
1218
Original file line number Diff line number Diff line change 1+ if (SCRATCHCPP_PLAYER_BUILD_UNIT_TESTS)
2+ set (TARGET ${MODULE} _test)
3+ set (TEST_MAIN_SRC ${PROJECT_SOURCE_DIR} /test /main.cpp)
4+ set (GTEST_DIR thirdparty/googletest)
5+ add_subdirectory (${PROJECT_SOURCE_DIR} /${GTEST_DIR} ${CMAKE_CURRENT_BINARY_DIR} /${GTEST_DIR} )
6+
7+ include (GoogleTest)
8+
9+ add_executable (
10+ ${TARGET}
11+ ${TEST_MAIN_SRC}
12+ ${MODULE_TEST_SRC}
13+ )
14+
15+ target_link_libraries (
16+ ${TARGET}
17+ GTest::gtest_main
18+ Qt6::Gui
19+ Qt6::Test
20+ )
21+
22+ target_include_directories (${TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
23+ endif ()
Original file line number Diff line number Diff line change 1+ #include < QGuiApplication>
2+ #include < gtest/gtest.h>
3+
4+ int main (int argc, char **argv)
5+ {
6+ QGuiApplication a (argc, argv);
7+ ::testing::InitGoogleTest (&argc, argv);
8+ return RUN_ALL_TESTS ();
9+ }
You can’t perform that action at this time.
0 commit comments