diff --git a/CMakeLists.txt b/CMakeLists.txt index 089e4ad..19cd4dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.hpp.in ${CMAKE_CURRENT_ option(BUILD_TESTING "Build tests" OFF) +if (PROJECT_IS_TOP_LEVEL) + if (BUILD_TESTING) + set(CONAN_INSTALL_ARGS "${CONAN_INSTALL_ARGS};-o=&:with_test_deps=True") + endif () +endif () + add_library(${PROJECT_NAME} INTERFACE) # Use dice::sparse_map as target, more consistent with other libraries conventions (Boost, Qt, ...) add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) diff --git a/conanfile.py b/conanfile.py index c74577b..79deb76 100644 --- a/conanfile.py +++ b/conanfile.py @@ -14,9 +14,16 @@ class Recipe(ConanFile): package_type = "header-library" generators = "CMakeDeps", "CMakeToolchain" no_copy_source = True + options = { + "with_test_deps": [True, False], + } + default_options = { + "with_test_deps": False, + } def requirements(self): - self.test_requires("boost/1.83.0") + if self.options.with_test_deps: + self.test_requires("boost/1.83.0") def set_name(self): if not hasattr(self, 'name') or self.version is None: