From 0110125215c5b45316b93e42e920fed2e741388a Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 28 Jun 2022 18:08:38 +0200 Subject: build: exclude tests if is subproject --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59ed07c..050bf50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,11 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) +if(DEFINED PROJECT_NAME) + set(IS_SUBPROJECT ON) +else() + set(IS_SUBPROJECT OFF) +endif() project(yacppdic CXX) @@ -45,9 +50,14 @@ target_include_directories(${PROJECT_NAME} add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) if(test) - add_subdirectory(test) + if(NOT IS_SUBPROJECT) + add_subdirectory(test) + else() + message(WARNING "Tests excluded because the library is a subproject") + endif() endif() if(examples) add_subdirectory(examples/basic) endif() + -- cgit v1.2.3-18-g5258