1- # if the library is compiled by vcpkg during the port build,
1+ # if the library is compiled by vcpkg during the port build (i.e. during the package installation) ,
22# then we don't need to build unit tests
33if (IS_VCPKG_PORT_BUILD)
44 return ()
@@ -9,42 +9,76 @@ if(IOS)
99 return ()
1010endif ()
1111
12- set (test_srcs)
13- myci_add_source_files(test_srcs
14- DIRECTORY
15- ${CMAKE_CURRENT_LIST_DIR} /../../tests/unit/src
16- RECURSIVE
17- )
18-
12+ # For unit tests we need the tst testing framework library which in turn depends on utki.
1913if (CPPFW_MONOREPO)
20- set (utki_test_harness_dir ${CMAKE_CURRENT_LIST_DIR} /../../..)
14+ # In case of monorepo build we can add necessary tst dependencies right here.
15+
16+ myci_add_subdirectory(${CMAKE_CURRENT_LIST_DIR} /../../../clargs/build /cmake
17+ BINARY_DIR
18+ clargs
19+ )
20+ myci_add_subdirectory(${CMAKE_CURRENT_LIST_DIR} /../../../opros/build /cmake
21+ BINARY_DIR
22+ opros
23+ )
24+ myci_add_subdirectory(${CMAKE_CURRENT_LIST_DIR} /../../../nitki/build /cmake
25+ BINARY_DIR
26+ nitki
27+ )
28+ myci_add_subdirectory(${CMAKE_CURRENT_LIST_DIR} /../../../tst/build /cmake
29+ BINARY_DIR
30+ tst
31+ )
32+
33+ set (tst_dep tst::tst)
2134else ()
35+ # In case of non-monorepo build, we need to build the tst framework
36+ # from sources (from git submodules) together with unit tests.
37+
2238 set (utki_test_harness_dir ${CMAKE_CURRENT_LIST_DIR} /../../tests/harness)
23- endif ()
2439
25- myci_add_source_files(test_srcs
26- DIRECTORY
27- ${utki_test_harness_dir} /tst/src
28- RECURSIVE
29- )
40+ myci_add_source_files(tst_srcs
41+ DIRECTORY
42+ ${utki_test_harness_dir} /tst/src
43+ RECURSIVE
44+ )
45+
46+ myci_add_source_files(tst_srcs
47+ DIRECTORY
48+ ${utki_test_harness_dir} /clargs/src
49+ RECURSIVE
50+ )
3051
52+ myci_declare_library(tst
53+ SOURCES
54+ ${tst_srcs}
55+ PUBLIC_INCLUDE_DIRECTORIES
56+ ${utki_test_harness_dir} /tst/src
57+ PRIVATE_INCLUDE_DIRECTORIES
58+ ${utki_test_harness_dir} /clargs/src
59+ PREPROCESSOR_DEFINITIONS
60+ TST_NO_PAR
61+ DEPENDENCIES
62+ utki
63+ )
64+
65+ set (tst_dep ${PROJECT_NAME} ::tst)
66+ endif ()
67+
68+ set (test_srcs)
3169myci_add_source_files(test_srcs
3270 DIRECTORY
33- ${utki_test_harness_dir} /clargs /src
71+ ${CMAKE_CURRENT_LIST_DIR} /../../tests/unit /src
3472 RECURSIVE
3573)
3674
3775myci_declare_application(${PROJECT_NAME} -tests
3876 GUI
3977 SOURCES
4078 ${test_srcs}
41- INCLUDE_DIRECTORIES
42- ${utki_test_harness_dir} /tst/src
43- ${utki_test_harness_dir} /clargs/src
44- PREPROCESSOR_DEFINITIONS
45- TST_NO_PAR
4679 DEPENDENCIES
4780 utki
81+ ${tst_dep}
4882)
4983
5084myci_declare_test(${PROJECT_NAME} )
0 commit comments