From 6ac0b249f73a28800e9ba668ee3dfc60efdb6f3c Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier Date: Thu, 24 Nov 2022 09:09:19 +0100 Subject: [PATCH] cmake: support standard ctest option --- CMakeLists.txt | 6 ++++-- externals/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4562f1af..cb153e29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,12 +8,14 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(MASTER_PROJECT ON) endif() +include(CMakeDependentOption) + # Dynarmic project options option(DYNARMIC_ENABLE_CPU_FEATURE_DETECTION "Turning this off causes dynarmic to assume the host CPU doesn't support anything later than SSE3" ON) option(DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT "Enables support for systems that require W^X" OFF) option(DYNARMIC_FATAL_ERRORS "Errors are fatal" OFF) option(DYNARMIC_IGNORE_ASSERTS "Ignore asserts" OFF) -option(DYNARMIC_TESTS "Build tests" ${MASTER_PROJECT}) +cmake_dependent_option(DYNARMIC_TESTS "Build tests" ${MASTER_PROJECT} "NOT DEFINED BUILD_TESTING" "${BUILD_TESTING}") option(DYNARMIC_TESTS_USE_UNICORN "Enable fuzzing tests against unicorn" OFF) option(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF) option(DYNARMIC_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON) @@ -155,7 +157,7 @@ add_subdirectory(externals) # Dynarmic project files add_subdirectory(src/dynarmic) if (DYNARMIC_TESTS) - enable_testing(true) + enable_testing() add_subdirectory(tests) endif() diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 913f8df8..51bd2eb3 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -7,6 +7,9 @@ endif() # Allow options shadowing with normal variables when subproject use old cmake policy set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) +# Disable tests in all externals supporting the standard option name +set(BUILD_TESTING OFF) + # For libraries that already come with a CMakeLists file, # simply add the directory to that file as a subdirectory # to have CMake automatically recognize them.