Commit 5f9d36b 1 parent f032021 commit 5f9d36b Copy full SHA for 5f9d36b
File tree 3 files changed +11
-15
lines changed
3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,3 @@ set(CMAKE_CXX_STANDARD 17)
6
6
# Add subdirectories
7
7
add_subdirectory (src/)
8
8
add_subdirectory (tests/)
9
-
10
- # Enable testing
11
- enable_testing ()
Original file line number Diff line number Diff line change @@ -22,33 +22,29 @@ set(PROJECT_SOURCES
22
22
book.cpp
23
23
)
24
24
25
- # Create a library target from the sources
26
- add_library (MyProjectLib STATIC
27
- mainwindow.cpp
28
- mainwindow.h
29
- author.cpp
30
- author.h
31
- book.h
32
- book.cpp
33
- )
25
+ # Create library
26
+ add_library (MyProjectLib ${PROJECT_SOURCES} )
34
27
28
+ # Include directories for the library
35
29
target_include_directories (MyProjectLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} )
36
30
31
+ # Link the library to the executable
37
32
target_link_libraries (MyProjectLib PRIVATE Qt${QT_VERSION_MAJOR} ::Widgets)
38
33
34
+ # Create the main executable
39
35
if (${QT_VERSION_MAJOR} GREATER_EQUAL 6)
40
36
qt_add_executable(COS3711-03-01
41
37
MANUAL_FINALIZATION
42
- ${PROJECT_SOURCES}
38
+ main.cpp
43
39
)
44
40
else ()
45
41
if (ANDROID)
46
42
add_library (COS3711-03-01 SHARED
47
- ${PROJECT_SOURCES}
43
+ main.cpp
48
44
)
49
45
else ()
50
46
add_executable (COS3711-03-01
51
- ${PROJECT_SOURCES}
47
+ main.cpp
52
48
)
53
49
endif ()
54
50
endif ()
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ add_executable(UnitTests ${UNIT_TEST_SOURCES}
24
24
25
25
# Link the library from the main project and set include directories
26
26
target_link_libraries (UnitTests PRIVATE MyProjectLib Qt${QT_VERSION_MAJOR} ::Test )
27
+
28
+ # Include directories for the tests
27
29
target_include_directories (UnitTests PRIVATE ${CMAKE_SOURCE_DIR} /../src)
28
30
31
+ # Add tests
29
32
add_test (NAME UnitTests COMMAND UnitTests)
You can’t perform that action at this time.
0 commit comments