From f5f31d7ba9521aec0f1f08a64c9ea983c9f1c068 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 25 Jan 2021 16:51:10 +0000 Subject: [PATCH] Simplify CMakeLists.txt now that we're header only. [CI SKIP] --- CMakeLists.txt | 111 +++++++++---------------------------------------- 1 file changed, 19 insertions(+), 92 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a61ba77c..e380b4ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,103 +1,30 @@ -# Copyright 2018-2019 Mike Dev +# Copyright 2018 Mike Dev +# Copyright 2019 Peter Dimov # Distributed under the Boost Software License, Version 1.0. -# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt -# -# NOTE: CMake support for Boost.Regex is currently experimental at best -# and the interface is likely to change in the future +# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt +# We support CMake 3.5, but prefer 3.16 policies and behavior +cmake_minimum_required(VERSION 3.5...3.16) -##### How-To: -# -# If you have a cmake project that wants to use and compile -# boost_regex, as part of a single build system run, do the following: -# 1) clone the boost project and all its sub-projects: -# -# git clone --branch develop --depth 1 --recursive --shallow-submodules https://github.com/boostorg/boost.git boost-root -# -# 2) add to your cmake script: -# -# add_subdirectory( []) -# target_link_libraries( PUBLIC Boost::regex) -# -# 3) run your cmake build as usual -# -# ## Explanation: -# -# Currently this file does not work standalone. It is expected to be -# invoked from a parent script via add_subdirectory. That parent script -# is responsible for providing targets for direct and indirect dependencies, -# such as Boost::assert, Boost::concept_check, e.g. by also adding those -# libraries via add_submodule (order doesn't matter). -# The parent script can be your own cmake script, but it is easier to just -# use add the CMakeLists in the root of the boost super project, which -# will in turn add all boost libraries usable with the add_subdirectory -# Workflow. -# -# Note: You don't need to actually clone all boost libraries. E.g. look -# into the travis ci file to see on which libraries boost_regex actually -# depends or use boostdep https://github.com/boostorg/boostdep +project(boost_regex VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) +add_library(boost_regex INTERFACE) +add_library(Boost::regex ALIAS boost_regex) -##### Current Limitations: -# -# - Doesn't compile or run tests -# +target_include_directories(boost_regex INTERFACE include) -cmake_minimum_required( VERSION 3.5...3.16 ) -project( boost_regex VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX ) - -option( BOOST_REGEX_INCLUDE_EXAMPLES "Also build (some) boost regex examples" OFF ) -option( BOOST_REGEX_USE_ICU "Enable ICU support in boost regex" OFF ) - -file( GLOB BOOST_REGEX_SRC ./src/*.cpp ) - -add_library( boost_regex ${BOOST_REGEX_SRC} ) -add_library( Boost::regex ALIAS boost_regex ) - -target_include_directories( boost_regex PUBLIC include ) - -target_compile_definitions( boost_regex - PUBLIC - # No need for autolink - BOOST_REGEX_NO_LIB - $<$,SHARED_LIBRARY>:BOOST_REGEX_DYN_LINK=1> - $<$,STATIC_LIBRARY>:BOOST_REGEX_STATIC_LINK=1> +target_link_libraries(boost_regex + INTERFACE + Boost::config + Boost::throw_exception ) -# Specify dependencies (including header-only libraries) -target_link_libraries( boost_regex - PUBLIC - Boost::assert - Boost::concept_check - Boost::config - Boost::container_hash - Boost::core - Boost::integer - Boost::iterator - Boost::mpl - Boost::predef - Boost::smart_ptr - Boost::static_assert - Boost::throw_exception - Boost::type_traits -) +# boost_install requires PROJECT_VERSION +# Without the superproject, we don't have any, so skip installation -if( BOOST_REGEX_USE_ICU ) - # ICU Targets could be provided by parent project, - # if not, look for them ourselves - if( NOT TARGET ICU::dt ) - # components need to be listed explicitly - find_package( ICU COMPONENTS dt in uc REQUIRED ) - endif() +if(BOOST_SUPERPROJECT_VERSION) + + include(BoostInstall) + boost_install(TARGETS boost_regex HEADER_DIRECTORY include/) - target_link_libraries( boost_regex - PRIVATE - ICU::dt ICU::in ICU::uc - ) - target_compile_definitions( boost_regex PRIVATE BOOST_HAS_ICU=1 ) endif() - -if( BOOST_REGEX_INCLUDE_EXAMPLES ) - add_subdirectory( example/snippets ) -endif() -