Set argparse to not run tests or set up install if not top level

This commit is contained in:
cobyj33 2023-10-31 21:09:12 -05:00
parent e4d4f67a44
commit e6d2628723
2 changed files with 11 additions and 6 deletions

View File

@ -1,5 +1,11 @@
cmake_minimum_required(VERSION 3.12.4)
if(NOT DEFINED PROJECT_NAME)
set(ARGPARSE_IS_TOP_LEVEL ON)
else()
set(ARGPARSE_IS_TOP_LEVEL OFF)
endif()
project(argparse
VERSION 2.9.0
DESCRIPTION "A single header argument parser for C++17"
@ -9,6 +15,7 @@ project(argparse
option(ARGPARSE_INSTALL "Include an install target" ON)
option(ARGPARSE_BUILD_TESTS "Build tests" ON)
option(ARGPARSE_BUILD_SAMPLES "Build samples" OFF)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
@ -25,11 +32,11 @@ if(ARGPARSE_BUILD_SAMPLES)
add_subdirectory(samples)
endif()
if(ARGPARSE_BUILD_TESTS)
if(ARGPARSE_BUILD_TESTS AND ARGPARSE_IS_TOP_LEVEL)
add_subdirectory(test)
endif()
if(ARGPARSE_INSTALL)
if(ARGPARSE_INSTALL AND ARGPARSE_IS_TOP_LEVEL)
install(TARGETS argparse EXPORT argparseConfig)
install(EXPORT argparseConfig
NAMESPACE argparse::

View File

@ -1179,8 +1179,6 @@ PROJECT(myproject)
# fetch latest argparse
include(FetchContent)
set(ARGPARSE_BUILD_TESTS OFF CACHE INTERNAL "Turn off building argparse tests")
set(ARGPARSE_BUILD_SAMPLES OFF CACHE INTERNAL "Turn off building argparse samples")
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git