Skip to content

Commit

Permalink
fix: fetch sanitizers-cmake only when either test or examples are ena…
Browse files Browse the repository at this point in the history
…bled
  • Loading branch information
DNKpp committed Sep 23, 2024
1 parent aa3cd16 commit 77dee8e
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 15 deletions.
11 changes: 0 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ project(
VERSION 1
)

CPMAddPackage(
NAME sanitizers-cmake
GITHUB_REPOSITORY "arsenm/sanitizers-cmake"
GIT_TAG "3f0542e4e034aab417c51b2b22c94f83355dee15"
SYSTEM YES
EXCLUDE_FROM_ALL YES
DOWNLOAD_ONLY YES
)
list(APPEND CMAKE_MODULE_PATH "${sanitizers-cmake_SOURCE_DIR}/cmake")
find_package(Sanitizers)

add_library(mimicpp INTERFACE)
add_library(mimicpp::mimicpp ALIAS mimicpp)
target_include_directories(
Expand Down
16 changes: 16 additions & 0 deletions cmake/FIndsanitizers-cmake.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CPMAddPackage(
NAME sanitizers-cmake
GITHUB_REPOSITORY "arsenm/sanitizers-cmake"
GIT_TAG "3f0542e4e034aab417c51b2b22c94f83355dee15"
SYSTEM YES
EXCLUDE_FROM_ALL YES
DOWNLOAD_ONLY YES
)

if (sanitizers-cmake_ADDED)

list(APPEND CMAKE_MODULE_PATH "${sanitizers-cmake_SOURCE_DIR}/cmake")

endif()

find_package(Sanitizers REQUIRED)
5 changes: 5 additions & 0 deletions cmake/FindCatch2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CPMAddPackage("gh:catchorg/[email protected]")

if (Catch2_ADDED)
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")
endif()
3 changes: 2 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
find_package(Catch2 REQUIRED)
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")

find_package(sanitizers-cmake REQUIRED)

add_executable(
mimicpp-examples
Expand Down
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
find_package(sanitizers-cmake REQUIRED)

add_subdirectory("unit-tests")

option(MIMICPP_ENABLE_ADAPTER_TESTS "Determines, whether the adapter tests shall be built." OFF)
Expand Down
1 change: 0 additions & 1 deletion test/adapter-tests/catch2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
find_package(Catch2 REQUIRED)
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")

add_executable(
mimicpp-adapter-tests-catch2
Expand Down
4 changes: 2 additions & 2 deletions test/unit-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CPMAddPackage("gh:catchorg/Catch2@3.7.1")
find_package(Catch2 REQUIRED)
CPMAddPackage("gh:rollbear/trompeloeil@48")
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")

add_executable(
mimicpp-tests
Expand All @@ -9,6 +8,7 @@ add_executable(
"Expectation.cpp"
"ExpectationBuilder.cpp"
"ExpectationPolicies.cpp"
"InterfaceMock.cpp"
"Matcher.cpp"
"Mock.cpp"
"Printer.cpp"
Expand Down

0 comments on commit 77dee8e

Please sign in to comment.