From 449fcd63c336cd17be3dd28f25f9fbf19adb4e42 Mon Sep 17 00:00:00 2001 From: Zhang Sheng Date: Tue, 5 Aug 2025 19:28:55 +0800 Subject: [PATCH] refactor: modify test build configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Changed default BUILD_TESTS option from OFF to ON to encourage testing 2. Added conditional check for Debug build type before including tests directory 3. These changes ensure tests are only built during development (Debug mode) 4. Improves development workflow while preventing test builds in production refactor: 修改测试构建配置 1. 将 BUILD_TESTS 选项默认值从 OFF 改为 ON 以鼓励测试 2. 在包含测试目录前添加了对 Debug 构建类型的条件检查 3. 这些更改确保测试仅在开发(Debug模式)期间构建 4. 改善了开发工作流程同时避免在生产环境中构建测试 --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf4eece..e31b2bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,10 +62,12 @@ set(DEPS_INCLUDE_DIRS ${DEPS_WITHOUT_MAGIC_INCLUDE_DIRS} ${LIBMAGIC_INCLUDE_DIRS # 添加子目录 add_subdirectory(src) -# 添加测试选项,默认不构建 -option(BUILD_TESTS "Build test applications" OFF) +# 添加测试选项,默认构建 +option(BUILD_TESTS "Build test applications" ON) # 有条件地添加测试目录 if(BUILD_TESTS) - add_subdirectory(tests) + if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") + add_subdirectory(tests) + endif() endif()