From 3bbc5b23cf4f685a4220e19f7d70b98bad8e9c9e Mon Sep 17 00:00:00 2001 From: Archie Date: Tue, 9 Jul 2024 11:43:42 +0100 Subject: [PATCH] fix: reverted changes to reallow unit tests in a static build --- CMakeLists.txt | 7 ------- library/CMakeLists.txt | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccd0480333..025203badf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,13 +29,6 @@ option(DPP_USE_EXTERNAL_JSON "Use an external installation of nlohmann::json" OF option(DPP_USE_PCH "Use precompiled headers to speed up compilation" OFF) option(AVX_TYPE "Force AVX type for speeding up audio mixing" OFF) -include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/colour.cmake") - -if (DPP_BUILD_TEST AND NOT BUILD_SHARED_LIBS) - set(DPP_BUILD_TEST OFF) - message("-- ${Yellow}Note - Unit Tests have been forcibly disabled since you are building statically.${ColourReset}") -endif() - include(CheckCXXSymbolExists) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_compile_definitions(DPP_BUILD) diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 3f46a281e0..e0eac6632c 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -359,7 +359,11 @@ if (DPP_BUILD_TEST) if (MSVC) target_compile_options(${testname} PRIVATE /utf-8) endif() - target_link_libraries(${testname} PUBLIC ${modname}) + set (static_if_needed "") + if(NOT BUILD_SHARED_LIBS) + set (static_if_needed "-static") + endif() + target_link_libraries(${testname} PUBLIC ${modname} ${static_if_needed}) endif() endforeach() add_test(