From 793b5e773e760284d16f49868362870199fd0dc8 Mon Sep 17 00:00:00 2001 From: Kristian McGurran Date: Sat, 28 Jun 2025 13:59:21 +0100 Subject: [PATCH 1/3] Making vectorisation a library --- .github/workflows/VectorisationTests.yml | 2 +- CMakeLists.txt | 28 +++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/VectorisationTests.yml b/.github/workflows/VectorisationTests.yml index 293481a..a87ac38 100644 --- a/.github/workflows/VectorisationTests.yml +++ b/.github/workflows/VectorisationTests.yml @@ -23,7 +23,7 @@ jobs: run: cmake -B build -DCMAKE_BUILD_TYPE=Release - name: Build - run: cmake --build build --config Release + run: cmake -DENABLE_TESTS=ON --build build --config Release - name: Run Catch2 Tests and Save Output run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 882dcab..19ab633 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,31 @@ cmake_minimum_required (VERSION 3.25) + project (WRAPPER DESCRIPTION "Vectorisation Wrapper with Unit tested" LANGUAGES CXX) +option(ENABLE_TESTS "Build unit tests" OFF) + set (CMAKE_CXX_STANDARD 23) -add_subdirectory (Catch2) if (APPLE) - set (ACCELERATE_SOURCES VectorisationWrappers/Accelerate/AccelerateWrapper.cpp - VectorisationWrappers/Accelerate/Tests/AccelerateArithmeticUnitTests.cpp - VectorisationWrappers/Accelerate/Tests/AccelerateUtilitiesUnitTests.cpp - VectorisationWrappers/Accelerate/Tests/AccelerateRangeUnitTests.cpp - VectorisationWrappers/Accelerate/Tests/AccelerateTrigonometryUnitTests.cpp) + add_library (VECTORISATION_WRAPPER STATIC VectorisationWrappers/Accelerate/AccelerateWrapper.cpp) + target_include_directories (VECTORISATION_WRAPPER PUBLIC ${PROJECT_SOURCE_DIR}/VectorisationWrappers/Accelerate/) + + if (ENABLE_TESTS) + # Todo: fetch catch for tests + + add_subdirectory (Catch2) + set (ACCELERATE_SOURCES + VectorisationWrappers/Accelerate/AccelerateWrapper.cpp + VectorisationWrappers/Accelerate/Tests/AccelerateArithmeticUnitTests.cpp + VectorisationWrappers/Accelerate/Tests/AccelerateUtilitiesUnitTests.cpp + VectorisationWrappers/Accelerate/Tests/AccelerateRangeUnitTests.cpp + VectorisationWrappers/Accelerate/Tests/AccelerateTrigonometryUnitTests.cpp) + + add_executable(accelerate_DSP ${ACCELERATE_SOURCES}) - add_executable(accelerate_DSP ${ACCELERATE_SOURCES}) + target_link_libraries (accelerate_DSP PRIVATE Catch2::Catch2WithMain "$") + endif () - target_link_libraries (accelerate_DSP PRIVATE Catch2::Catch2WithMain "$") elseif (MSVC) message ("No Wrapper") endif() \ No newline at end of file From ea8ca48196c3e1df06d7e45e5b427b2d679ecdf4 Mon Sep 17 00:00:00 2001 From: Kristian McGurran Date: Sat, 28 Jun 2025 15:44:01 +0100 Subject: [PATCH 2/3] Cmake Config --- .github/workflows/VectorisationTests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/VectorisationTests.yml b/.github/workflows/VectorisationTests.yml index a87ac38..f1251bf 100644 --- a/.github/workflows/VectorisationTests.yml +++ b/.github/workflows/VectorisationTests.yml @@ -20,10 +20,10 @@ jobs: run: cmake --version - name: Configure with CMake - run: cmake -B build -DCMAKE_BUILD_TYPE=Release + run: cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON - name: Build - run: cmake -DENABLE_TESTS=ON --build build --config Release + run: cmake --build build --config Release - name: Run Catch2 Tests and Save Output run: | From 115aae3c7c50804e89b979861c74955eeb41885c Mon Sep 17 00:00:00 2001 From: Kristian McGurran Date: Sat, 28 Jun 2025 15:52:20 +0100 Subject: [PATCH 3/3] Removing catch2 submodule - Clone only if tests enabled --- .gitmodules | 3 --- CMakeLists.txt | 10 ++++++++-- Catch2 | 1 - 3 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 .gitmodules delete mode 160000 Catch2 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 2f24b84..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Catch2"] - path = Catch2 - url = https://github.com/catchorg/Catch2.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 19ab633..8489651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,15 @@ if (APPLE) target_include_directories (VECTORISATION_WRAPPER PUBLIC ${PROJECT_SOURCE_DIR}/VectorisationWrappers/Accelerate/) if (ENABLE_TESTS) - # Todo: fetch catch for tests - add_subdirectory (Catch2) + include(FetchContent) + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.5.2) + + FetchContent_MakeAvailable(Catch2) + set (ACCELERATE_SOURCES VectorisationWrappers/Accelerate/AccelerateWrapper.cpp VectorisationWrappers/Accelerate/Tests/AccelerateArithmeticUnitTests.cpp diff --git a/Catch2 b/Catch2 deleted file mode 160000 index 416b075..0000000 --- a/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 416b0752112e0e5f9a8568e3e18baace15de37a7