diff --git a/CMakeLists.txt b/CMakeLists.txt index a83622068164e008289f6daa58e6fc50149ee3ff..9329ae3ae696c5cdabb54b5cb29177a6f1155458 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,23 +13,33 @@ add_custom_target(check COMMAND ./clang-tidy.sh WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/ci") +# Specify the .cpp files common across all targets +add_library(common OBJECT + src/Message.cpp + src/Services/EventReportService.cpp + src/Services/MemoryManagementService.cpp + src/Services/ParameterService.cpp + src/Services/RequestVerificationService.cpp + src/Services/TestService.cpp + ) + # Specify the .cpp files for the executables -add_executable(ecss_services src/main.cpp src/Message.cpp src/Service.cpp - src/Services/TestService.cpp - src/Services/RequestVerificationService.cpp - src/Services/MemoryManagementService.cpp - src/Services/ParameterService.cpp - src/Services/EventReportService.cpp - inc/Services/EventReportService.hpp) +add_executable(ecss_services + src/main.cpp + $<TARGET_OBJECTS:common> + src/Platform/x86/Service.cpp + ) IF (EXISTS "${PROJECT_SOURCE_DIR}/lib/Catch2/CMakeLists.txt") + # Gather all the .cpp files corresponding to tests + file(GLOB test_main_SRC "test/*.cpp") + file(GLOB test_SRC "test/**/*.cpp") + add_subdirectory(lib/Catch2) - add_executable(tests src/Message.cpp src/Services/TestService.cpp - src/Services/RequestVerificationService.cpp src/Services/ParameterService.cpp - src/Services/MemoryManagementService.cpp test/tests.cpp test/Message.cpp - test/TestPlatform.cpp test/Services/TestService.cpp - test/Services/RequestVerificationService.cpp - test/Services/ParameterService.cpp test/Services/MemoryManagementService.cpp) + add_executable(tests + $<TARGET_OBJECTS:common> + ${test_main_SRC} + ${test_SRC}) target_link_libraries(tests Catch2::Catch2) -ENDIF () +ENDIF() diff --git a/src/Platform/README.md b/src/Platform/README.md new file mode 100644 index 0000000000000000000000000000000000000000..eb0a3ae39f9c1079d32ec6cd60298838564319a9 --- /dev/null +++ b/src/Platform/README.md @@ -0,0 +1,3 @@ +This folder contains platform-specific files: + +- **x86**: Files to be run on a PC with a proper operating system \ No newline at end of file diff --git a/src/Service.cpp b/src/Platform/x86/Service.cpp similarity index 100% rename from src/Service.cpp rename to src/Platform/x86/Service.cpp