File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Expand file tree Collapse file tree 4 files changed +39
-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 @@ -25,3 +25,4 @@ list(REMOVE_DUPLICATES QML_IMPORT_PATH)
2525set (QML_IMPORT_PATH ${QML_IMPORT_PATH}  CACHE  STRING  ""  FORCE)
2626
2727target_link_libraries (appscratchcpp-player PRIVATE  ${MODULE} )
28+ set (MODULE_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
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  ${MODULE_SRC_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