From 941ece365cbd2f87fda6e835ac33ab1d2c41f983 Mon Sep 17 00:00:00 2001 From: kilo52 Date: Tue, 23 Dec 2025 23:29:49 +0100 Subject: [PATCH] Add BUILD_TESTING option to give consumer the ability to skip test building. Rename the 'ts-test' test target to 'ts-java-test' to avoid target name collisions with other TS projects that define their test target with the same name. --- CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6498173..4f099e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ project(tree-sitter-java LANGUAGES C) option(BUILD_SHARED_LIBS "Build using shared libraries" ON) +option(BUILD_TESTING "Build tests" ON) option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF) set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version") @@ -53,6 +54,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-java.pc" install(TARGETS tree-sitter-java LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") -add_custom_target(ts-test "${TREE_SITTER_CLI}" test - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMENT "tree-sitter test") +if(BUILD_TESTING) + add_custom_target(ts-java-test "${TREE_SITTER_CLI}" test + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "tree-sitter test") +endif()