1# Copyright 2018-2019 Mike Dev 2# Distributed under the Boost Software License, Version 1.0. 3# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt 4# 5# NOTE: CMake support for Boost.Regex is currently experimental at best 6# and the interface is likely to change in the future 7 8 9##### How-To: 10# 11# If you have a cmake project that wants to use and compile 12# boost_regex, as part of a single build system run, do the following: 13# 1) clone the boost project and all its sub-projects: 14# 15# git clone --branch develop --depth 1 --recursive --shallow-submodules https://github.com/boostorg/boost.git boost-root 16# 17# 2) add to your cmake script: 18# 19# add_subdirectory( <path-to-boost-root> [<build-dir-for-boost-libs>]) 20# target_link_libraries( <my-exec> PUBLIC Boost::regex) 21# 22# 3) run your cmake build as usual 23# 24# ## Explanation: 25# 26# Currently this file does not work standalone. It is expected to be 27# invoked from a parent script via add_subdirectory. That parent script 28# is responsible for providing targets for direct and indirect dependencies, 29# such as Boost::assert, Boost::concept_check, e.g. by also adding those 30# libraries via add_submodule (order doesn't matter). 31# The parent script can be your own cmake script, but it is easier to just 32# use add the CMakeLists in the root of the boost super project, which 33# will in turn add all boost libraries usable with the add_subdirectory 34# Workflow. 35# 36# Note: You don't need to actually clone all boost libraries. E.g. look 37# into the travis ci file to see on which libraries boost_regex actually 38# depends or use boostdep https://github.com/boostorg/boostdep 39 40 41##### Current Limitations: 42# 43# - Doesn't compile or run tests 44# 45 46cmake_minimum_required( VERSION 3.5...3.16 ) 47project( boost_regex VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX ) 48 49option( BOOST_REGEX_INCLUDE_EXAMPLES "Also build (some) boost regex examples" OFF ) 50option( BOOST_REGEX_USE_ICU "Enable ICU support in boost regex" OFF ) 51 52file( GLOB BOOST_REGEX_SRC ./src/*.cpp ) 53 54add_library( boost_regex ${BOOST_REGEX_SRC} ) 55add_library( Boost::regex ALIAS boost_regex ) 56 57target_include_directories( boost_regex PUBLIC include ) 58 59target_compile_definitions( boost_regex 60 PUBLIC 61 # No need for autolink 62 BOOST_REGEX_NO_LIB 63 $<$<STREQUAL:$<TARGET_PROPERTY:boost_regex,TYPE>,SHARED_LIBRARY>:BOOST_REGEX_DYN_LINK=1> 64 $<$<STREQUAL:$<TARGET_PROPERTY:boost_regex,TYPE>,STATIC_LIBRARY>:BOOST_REGEX_STATIC_LINK=1> 65) 66 67# Specify dependencies (including header-only libraries) 68target_link_libraries( boost_regex 69 PUBLIC 70 Boost::assert 71 Boost::concept_check 72 Boost::config 73 Boost::container_hash 74 Boost::core 75 Boost::integer 76 Boost::iterator 77 Boost::mpl 78 Boost::predef 79 Boost::smart_ptr 80 Boost::static_assert 81 Boost::throw_exception 82 Boost::type_traits 83) 84 85if( BOOST_REGEX_USE_ICU ) 86 # ICU Targets could be provided by parent project, 87 # if not, look for them ourselves 88 if( NOT TARGET ICU::dt ) 89 # components need to be listed explicitly 90 find_package( ICU COMPONENTS dt in uc REQUIRED ) 91 endif() 92 93 target_link_libraries( boost_regex 94 PRIVATE 95 ICU::dt ICU::in ICU::uc 96 ) 97 target_compile_definitions( boost_regex PRIVATE BOOST_HAS_ICU=1 ) 98endif() 99 100if( BOOST_REGEX_INCLUDE_EXAMPLES ) 101 add_subdirectory( example/snippets ) 102endif() 103 104