From 5bd30b43526469dd847c7d08357c5b738cece08e Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Mon, 11 Nov 2024 19:04:44 +0300 Subject: [PATCH] Make building of tests optional --- CMakeLists.txt | 13 +++++++++++-- UnitTests/CMakeLists.txt | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4f95e3..6d5f8b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ if(WIN32 AND MSVC) endif() option(PDF4QT_BUILD_ONLY_CORE_LIBRARY "Build only core library" OFF) +option(PDF4QT_BUILD_TESTS "Build UnitTests" ON) set(PDF4QT_QT_ROOT "" CACHE PATH "Qt root directory") @@ -64,7 +65,11 @@ find_package(Qt6 REQUIRED COMPONENTS Core LinguistTools) if(PDF4QT_BUILD_ONLY_CORE_LIBRARY) find_package(Qt6 REQUIRED COMPONENTS Core Gui Svg Xml) else() - find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport TextToSpeech Test Concurrent) + find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport TextToSpeech Concurrent) +endif() + +if(PDF4QT_BUILD_TESTS) + find_package(Qt6 REQUIRED COMPONENTS Test) endif() qt_standard_project_setup(I18N_TRANSLATED_LANGUAGES en de cs es ko zh_CN zh_TW fr tr ru) @@ -160,7 +165,6 @@ if(NOT PDF4QT_BUILD_ONLY_CORE_LIBRARY) add_subdirectory(JBIG2_Viewer) add_subdirectory(PdfExampleGenerator) add_subdirectory(PdfTool) - add_subdirectory(UnitTests) add_subdirectory(Pdf4QtLibGui) add_subdirectory(Pdf4QtEditorPlugins) add_subdirectory(Pdf4QtEditor) @@ -171,6 +175,11 @@ if(NOT PDF4QT_BUILD_ONLY_CORE_LIBRARY) add_subdirectory(WixInstaller) endif() +if(PDF4QT_BUILD_TESTS) + enable_testing() + add_subdirectory(UnitTests) +endif() + qt_collect_translation_source_targets(i18n_targets) message("CMAKE_TRANSLATION_TARGETS = " ${i18n_targets}) diff --git a/UnitTests/CMakeLists.txt b/UnitTests/CMakeLists.txt index c1a912f..9f64ec8 100644 --- a/UnitTests/CMakeLists.txt +++ b/UnitTests/CMakeLists.txt @@ -32,3 +32,4 @@ set_target_properties(UnitTests PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PDF4QT_INSTALL_LIB_DIR} RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PDF4QT_INSTALL_BIN_DIR} ) +add_test(UnitTests "${CMAKE_BINARY_DIR}/${PDF4QT_INSTALL_BIN_DIR}/UnitTests") -- 2.52.0