From 16d0e560050b9da73d6e0e1103a75ab213767242 Mon Sep 17 00:00:00 2001 From: zhaoshihan Date: Sat, 15 Jun 2024 21:30:03 +0800 Subject: [PATCH] Allow to install when argparse is a subproject --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f9f183f..060675a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,8 @@ project(argparse LANGUAGES CXX ) -option(ARGPARSE_INSTALL "Include an install target" ON) -option(ARGPARSE_BUILD_TESTS "Build tests" ON) +option(ARGPARSE_INSTALL "Include an install target" ${ARGPARSE_IS_TOP_LEVEL}) +option(ARGPARSE_BUILD_TESTS "Build tests" ${ARGPARSE_IS_TOP_LEVEL}) option(ARGPARSE_BUILD_SAMPLES "Build samples" OFF) include(GNUInstallDirs) @@ -32,11 +32,11 @@ if(ARGPARSE_BUILD_SAMPLES) add_subdirectory(samples) endif() -if(ARGPARSE_BUILD_TESTS AND ARGPARSE_IS_TOP_LEVEL) +if(ARGPARSE_BUILD_TESTS) add_subdirectory(test) endif() -if(ARGPARSE_INSTALL AND ARGPARSE_IS_TOP_LEVEL) +if(ARGPARSE_INSTALL) install(TARGETS argparse EXPORT argparseConfig) install(EXPORT argparseConfig NAMESPACE argparse::