cmake: make tests optional

This commit is contained in:
Alexandre Bouvier 2022-01-12 00:36:20 +01:00
parent c65c651b6f
commit c8b358dba2
4 changed files with 12 additions and 7 deletions

View File

@ -35,6 +35,8 @@ option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF)
option(YUZU_USE_BUNDLED_OPUS "Compile bundled opus" ON) option(YUZU_USE_BUNDLED_OPUS "Compile bundled opus" ON)
option(YUZU_TESTS "Compile tests" ON)
# Default to a Release build # Default to a Release build
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE)
@ -168,7 +170,6 @@ macro(yuzu_find_packages)
# Capitalization matters here. We need the naming to match the generated paths from Conan # Capitalization matters here. We need the naming to match the generated paths from Conan
set(REQUIRED_LIBS set(REQUIRED_LIBS
# Cmake Pkg Prefix Version Conan Pkg # Cmake Pkg Prefix Version Conan Pkg
"Catch2 2.13.7 catch2/2.13.7"
"fmt 8.0.1 fmt/8.1.1" "fmt 8.0.1 fmt/8.1.1"
"lz4 1.8 lz4/1.9.2" "lz4 1.8 lz4/1.9.2"
"nlohmann_json 3.8 nlohmann_json/3.8.0" "nlohmann_json 3.8 nlohmann_json/3.8.0"
@ -177,6 +178,11 @@ macro(yuzu_find_packages)
# can't use opus until AVX check is fixed: https://github.com/yuzu-emu/yuzu/pull/4068 # can't use opus until AVX check is fixed: https://github.com/yuzu-emu/yuzu/pull/4068
#"opus 1.3 opus/1.3.1" #"opus 1.3 opus/1.3.1"
) )
if (YUZU_TESTS)
list(APPEND REQUIRED_LIBS
"Catch2 2.13.7 catch2/2.13.7"
)
endif()
foreach(PACKAGE ${REQUIRED_LIBS}) foreach(PACKAGE ${REQUIRED_LIBS})
string(REGEX REPLACE "[ \t\r\n]+" ";" PACKAGE_SPLIT ${PACKAGE}) string(REGEX REPLACE "[ \t\r\n]+" ";" PACKAGE_SPLIT ${PACKAGE})

View File

@ -13,10 +13,6 @@ if (ARCHITECTURE_x86 OR ARCHITECTURE_x86_64)
target_compile_definitions(xbyak INTERFACE XBYAK_NO_OP_NAMES) target_compile_definitions(xbyak INTERFACE XBYAK_NO_OP_NAMES)
endif() endif()
# Catch
add_library(catch-single-include INTERFACE)
target_include_directories(catch-single-include INTERFACE catch/single_include)
# Dynarmic # Dynarmic
if (ARCHITECTURE_x86_64) if (ARCHITECTURE_x86_64)
set(DYNARMIC_TESTS OFF) set(DYNARMIC_TESTS OFF)

View File

@ -151,7 +151,10 @@ add_subdirectory(audio_core)
add_subdirectory(video_core) add_subdirectory(video_core)
add_subdirectory(input_common) add_subdirectory(input_common)
add_subdirectory(shader_recompiler) add_subdirectory(shader_recompiler)
add_subdirectory(tests)
if (YUZU_TESTS)
add_subdirectory(tests)
endif()
if (ENABLE_SDL2) if (ENABLE_SDL2)
add_subdirectory(yuzu_cmd) add_subdirectory(yuzu_cmd)

View File

@ -16,6 +16,6 @@ add_executable(tests
create_target_directory_groups(tests) create_target_directory_groups(tests)
target_link_libraries(tests PRIVATE common core input_common) target_link_libraries(tests PRIVATE common core input_common)
target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} catch-single-include Threads::Threads) target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2 Threads::Threads)
add_test(NAME tests COMMAND tests) add_test(NAME tests COMMAND tests)