From 7e26d2fd3064c6adf3e7a52a275046dd0cf194be Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 8 Apr 2024 19:17:19 -0400 Subject: [PATCH] build(tests): ensure tests can be disabled during build (#2386) --- cmake/targets/common.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/targets/common.cmake b/cmake/targets/common.cmake index ec7c7cbcf98..094bbca7c20 100644 --- a/cmake/targets/common.cmake +++ b/cmake/targets/common.cmake @@ -56,14 +56,20 @@ endif() # custom compile flags, must be after adding tests +if (NOT BUILD_TESTS) + set(TEST_DIR "") +else() + set(TEST_DIR "${CMAKE_SOURCE_DIR}/tests") +endif() + # src/upnp set_source_files_properties("${CMAKE_SOURCE_DIR}/src/upnp.cpp" - DIRECTORY "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/tests" + DIRECTORY "${CMAKE_SOURCE_DIR}" "${TEST_DIR}" PROPERTIES COMPILE_FLAGS -Wno-pedantic) # third-party/nanors set_source_files_properties("${CMAKE_SOURCE_DIR}/third-party/nanors/rs.c" - DIRECTORY "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/tests" + DIRECTORY "${CMAKE_SOURCE_DIR}" "${TEST_DIR}" PROPERTIES COMPILE_FLAGS "-include deps/obl/autoshim.h -ftree-vectorize") # third-party/ViGEmClient @@ -74,7 +80,7 @@ string(APPEND VIGEM_COMPILE_FLAGS "-Wno-class-memaccess ") string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unused-function ") string(APPEND VIGEM_COMPILE_FLAGS "-Wno-unused-variable ") set_source_files_properties("${CMAKE_SOURCE_DIR}/third-party/ViGEmClient/src/ViGEmClient.cpp" - DIRECTORY "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/tests" + DIRECTORY "${CMAKE_SOURCE_DIR}" "${TEST_DIR}" PROPERTIES COMPILE_DEFINITIONS "UNICODE=1;ERROR_INVALID_DEVICE_OBJECT_PARAMETER=650" COMPILE_FLAGS ${VIGEM_COMPILE_FLAGS})