build(cmake): add zeal_add_test helper (#1838)

This commit is contained in:
Oleg Shparber
2026-05-03 02:35:11 +03:00
committed by GitHub
parent 7ba055f672
commit 7a1a9420ab
3 changed files with 25 additions and 1 deletions
+2
View File
@@ -21,6 +21,8 @@ project(Zeal
set(ZEAL_RELEASE_VERSION "0.8.1") # x-release-please-version
include(ZealHelpers)
option(ZEAL_USE_CLANG_TIDY "Enable clang-tidy static analysis" OFF)
if(ZEAL_USE_CLANG_TIDY)
find_program(CLANG_TIDY_PROGRAM clang-tidy)
+22
View File
@@ -0,0 +1,22 @@
#
# ZealHelpers.cmake - Project-specific CMake helpers
#
# SPDX-FileCopyrightText: Oleg Shparber, et al. <https://zealdocs.org>
# SPDX-License-Identifier: MIT
#
# Register a unit test executable. On Windows, prepends Qt's DLL directory to
# PATH at test-run time so the test binary can locate Qt6Core.dll without
# deploying Qt next to every test executable.
#
# TODO: Once cmake_minimum_required is >= 3.27, replace the Qt-specific
# directory with $<TARGET_RUNTIME_DLL_DIRS:${test_name}> to cover any future
# non-Qt shared dependencies automatically.
function(zeal_add_test test_name)
add_test(NAME ${test_name} COMMAND ${test_name})
if(WIN32)
set_tests_properties(${test_name} PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:Qt6::Core>"
)
endif()
endfunction()
+1 -1
View File
@@ -4,4 +4,4 @@ find_package(Qt6 REQUIRED COMPONENTS Test)
add_executable(fuzzy_test fuzzy_test.cpp)
target_link_libraries(fuzzy_test PRIVATE Util Qt6::Test)
add_test(NAME fuzzy_test COMMAND fuzzy_test)
zeal_add_test(fuzzy_test)