Skip to content

Commit

Permalink
Update build config
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchcamza committed Jul 28, 2024
1 parent f032021 commit 5f9d36b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
3 changes: 0 additions & 3 deletions COS3711-03-01/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ set(CMAKE_CXX_STANDARD 17)
# Add subdirectories
add_subdirectory(src/)
add_subdirectory(tests/)

# Enable testing
enable_testing()
20 changes: 8 additions & 12 deletions COS3711-03-01/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,29 @@ set(PROJECT_SOURCES
book.cpp
)

# Create a library target from the sources
add_library(MyProjectLib STATIC
mainwindow.cpp
mainwindow.h
author.cpp
author.h
book.h
book.cpp
)
# Create library
add_library(MyProjectLib ${PROJECT_SOURCES})

# Include directories for the library
target_include_directories(MyProjectLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

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

# Create the main executable
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(COS3711-03-01
MANUAL_FINALIZATION
${PROJECT_SOURCES}
main.cpp
)
else()
if(ANDROID)
add_library(COS3711-03-01 SHARED
${PROJECT_SOURCES}
main.cpp
)
else()
add_executable(COS3711-03-01
${PROJECT_SOURCES}
main.cpp
)
endif()
endif()
Expand Down
3 changes: 3 additions & 0 deletions COS3711-03-01/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ add_executable(UnitTests ${UNIT_TEST_SOURCES}

# Link the library from the main project and set include directories
target_link_libraries(UnitTests PRIVATE MyProjectLib Qt${QT_VERSION_MAJOR}::Test)

# Include directories for the tests
target_include_directories(UnitTests PRIVATE ${CMAKE_SOURCE_DIR}/../src)

# Add tests
add_test(NAME UnitTests COMMAND UnitTests)

0 comments on commit 5f9d36b

Please sign in to comment.