From ba702043f006abc4418d51fcdb61f1237329503d Mon Sep 17 00:00:00 2001 From: Castor215 <132155746+Castor215@users.noreply.github.com> Date: Sat, 18 Nov 2023 23:54:27 +0000 Subject: [PATCH] externals: allow user to use system Catch2 (#7190) --- externals/CMakeLists.txt | 12 +++++++++--- externals/cmake-modules/CitraHandleSystemLibs.cmake | 3 +++ src/tests/CMakeLists.txt | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index d150cb6405..e9f57b5b51 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -41,9 +41,15 @@ else() endif() # Catch2 -set(CATCH_INSTALL_DOCS OFF CACHE BOOL "") -set(CATCH_INSTALL_EXTRAS OFF CACHE BOOL "") -add_subdirectory(catch2) +add_library(catch2 INTERFACE) +if(USE_SYSTEM_CATCH2) + find_package(Catch2 3.0.0 REQUIRED) +else() + set(CATCH_INSTALL_DOCS OFF CACHE BOOL "") + set(CATCH_INSTALL_EXTRAS OFF CACHE BOOL "") + add_subdirectory(catch2) +endif() +target_link_libraries(catch2 INTERFACE Catch2::Catch2WithMain) # Crypto++ if(USE_SYSTEM_CRYPTOPP) diff --git a/externals/cmake-modules/CitraHandleSystemLibs.cmake b/externals/cmake-modules/CitraHandleSystemLibs.cmake index 44f156b759..b1bb7ccd9a 100644 --- a/externals/cmake-modules/CitraHandleSystemLibs.cmake +++ b/externals/cmake-modules/CitraHandleSystemLibs.cmake @@ -25,6 +25,7 @@ option(USE_SYSTEM_LODEPNG "Use the system lodepng (instead of the bundled one)" option(USE_SYSTEM_OPENAL "Use the system OpenAL (instead of the bundled one)" OFF) option(USE_SYSTEM_VMA "Use the system VulkanMemoryAllocator (instead of the bundled one)" OFF) option(USE_SYSTEM_VULKAN_HEADERS "Use the system Vulkan headers (instead of the bundled ones)" OFF) +option(USE_SYSTEM_CATCH2 "Use the system Catch2 (instead of the bundled one)" OFF) # Qt and MoltenVK are handled separately CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_SDL2 "Disable system SDL2" OFF "USE_SYSTEM_LIBS" OFF) @@ -49,6 +50,7 @@ CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_LODEPNG "Disable system lodepng" OFF "USE_ CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_OPENAL "Disable system OpenAL" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_VMA "Disable system VulkanMemoryAllocator" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_VULKAN_HEADERS "Disable system Vulkan headers" OFF "USE_SYSTEM_LIBS" OFF) +CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_CATCH2 "Disable system Catch2" OFF "USE_SYSTEM_LIBS" OFF) set(LIB_VAR_LIST SDL2 @@ -73,6 +75,7 @@ set(LIB_VAR_LIST OPENAL VMA VULKAN_HEADERS + CATCH2 ) # First, check that USE_SYSTEM_XXX is not used with USE_SYSTEM_LIBS diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index dd6e6942f3..459168d451 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -21,7 +21,7 @@ add_executable(tests create_target_directory_groups(tests) target_link_libraries(tests PRIVATE citra_common citra_core video_core audio_core) -target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2WithMain nihstro-headers Threads::Threads) +target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} catch2 nihstro-headers Threads::Threads) add_test(NAME tests COMMAND tests)