From bc56a511390c7aa4a6b7f2f8e115e3f865f8bbe1 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Wed, 24 Dec 2025 00:17:46 -0500 Subject: Allow skipping tests and utils with CMake --- CMakeLists.txt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dba3a4..c04f10c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,6 @@ cmake_minimum_required(VERSION 3.5) set (PACKAGE_NAME libpinyin) project (${PACKAGE_NAME} CXX C) -enable_testing() ######## Package information set (PACKAGE_URL https://github.com/libpinyin/libpinyin) @@ -41,6 +40,8 @@ set (VERSION ${LIBPINYIN_VERSION}) ######## Options option(BUILD_SHARED_LIBS "Build libpinyin as shared library" ON) +option(BUILD_TESTING "Build automated tests." ON) +option(BUILD_UTILS "Build libpinyin utils and data." ON) ######## Validation @@ -181,6 +182,13 @@ include_directories( ######## Subdirectories add_subdirectory(src) -add_subdirectory(tests) -add_subdirectory(utils) -add_subdirectory(data) + +if (BUILD_TESTING) + enable_testing() + add_subdirectory(tests) +endif() + +if (BUILD_UTILS) + add_subdirectory(utils) + add_subdirectory(data) +endif() -- cgit