Skip to content

Commit 5f9d36b

Browse files
committed
Update build config
1 parent f032021 commit 5f9d36b

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

COS3711-03-01/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ set(CMAKE_CXX_STANDARD 17)
66
# Add subdirectories
77
add_subdirectory(src/)
88
add_subdirectory(tests/)
9-
10-
# Enable testing
11-
enable_testing()

COS3711-03-01/src/CMakeLists.txt

+8-12
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,29 @@ set(PROJECT_SOURCES
2222
book.cpp
2323
)
2424

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})
3427

28+
# Include directories for the library
3529
target_include_directories(MyProjectLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3630

31+
# Link the library to the executable
3732
target_link_libraries(MyProjectLib PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
3833

34+
# Create the main executable
3935
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
4036
qt_add_executable(COS3711-03-01
4137
MANUAL_FINALIZATION
42-
${PROJECT_SOURCES}
38+
main.cpp
4339
)
4440
else()
4541
if(ANDROID)
4642
add_library(COS3711-03-01 SHARED
47-
${PROJECT_SOURCES}
43+
main.cpp
4844
)
4945
else()
5046
add_executable(COS3711-03-01
51-
${PROJECT_SOURCES}
47+
main.cpp
5248
)
5349
endif()
5450
endif()

COS3711-03-01/tests/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ add_executable(UnitTests ${UNIT_TEST_SOURCES}
2424

2525
# Link the library from the main project and set include directories
2626
target_link_libraries(UnitTests PRIVATE MyProjectLib Qt${QT_VERSION_MAJOR}::Test)
27+
28+
# Include directories for the tests
2729
target_include_directories(UnitTests PRIVATE ${CMAKE_SOURCE_DIR}/../src)
2830

31+
# Add tests
2932
add_test(NAME UnitTests COMMAND UnitTests)

0 commit comments

Comments
 (0)