1# 2# Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) 3# Copyright (c) 2021 Richard Hodges (hodges.r@gmail.com) 4# 5# Distributed under the Boost Software License, Version 1.0. (See accompanying 6# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7# 8# Official repository: https://github.com/boostorg/property_tree 9# 10 11cmake_minimum_required(VERSION 3.5...3.19) 12 13set(BOOST_PROPERTY_TREE_VERSION ${BOOST_SUPERPROJECT_VERSION}) 14 15project(boost_property_tree VERSION "${BOOST_PROPERTY_TREE_VERSION}" LANGUAGES CXX) 16 17option(BOOST_PROPERTY_TREE_BUILD_TESTS "Build boost::property_tree tests" ${BUILD_TESTING}) 18option(BOOST_PROPERTY_TREE_BUILD_EXAMPLES "Build boost::property_tree examples" ${BOOST_PROPERTY_TREE_BUILD_TESTS}) 19 20file(GLOB_RECURSE BOOST_PROPERTY_TREE_HEADERS $<$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.12>:CONFIGURE_DEPENDS> 21 include/boost/*.hpp 22 include/boost/*.ipp 23 include/boost/*.natvis 24) 25 26set(BOOST_PROPERTY_TREE_SOURCES 27) 28 29set_property(GLOBAL PROPERTY USE_FOLDERS ON) 30 31source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/boost PREFIX "" FILES ${BOOST_PROPERTY_TREE_HEADERS}) 32source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "" FILES ${BOOST_PROPERTY_TREE_SOURCES}) 33 34add_library(boost_property_tree INTERFACE) 35add_library(Boost::property_tree ALIAS boost_property_tree) 36 37target_include_directories(boost_property_tree INTERFACE include) 38 39if(BOOST_SUPERPROJECT_VERSION) 40 # 41 # Building as part of Boost superproject tree, with Boost as dependency. 42 # 43 target_link_libraries(boost_property_tree 44 INTERFACE 45 Boost::any 46 Boost::assert 47 Boost::bind 48 Boost::config 49 Boost::core 50 Boost::format 51 Boost::iterator 52 Boost::mpl 53 Boost::multi_index 54 Boost::optional 55 Boost::range 56 Boost::serialization 57 Boost::static_assert 58 Boost::throw_exception 59 Boost::type_traits 60 ) 61 62elseif(BOOST_PROPERTY_TREE_IN_BOOST_TREE) 63 # 64 # Building inside Boost tree, out of Boost superproject tree, with Boost as dependency. 65 # e.g. on Travis or other CI, or when producing Visual Studio Solution and Projects. 66 # 67 get_filename_component(BOOST_ROOT ../.. ABSOLUTE) 68 set(BOOST_INCLUDEDIR ${BOOST_ROOT}) 69 set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib) 70 find_package(Boost COMPONENTS serialization REQUIRED) 71 72 target_include_directories(boost_property_tree INTERFACE ${BOOST_ROOT}) 73 target_link_directories(boost_property_tree INTERFACE ${BOOST_ROOT}/stage/lib) 74 75else() 76 # 77 # Building out of Boost tree, out of Boost superproject tree, with Boost as dependency. 78 # e.g. for packaging or added with add_subdirectory. 79 # 80 find_package(Boost REQUIRED 81 #COMPONENTS container system 82 ) 83 target_link_libraries(boost_property_tree 84 INTERFACE 85 Boost::boost 86 ) 87endif() 88 89if(BUILD_TESTING) 90 include(CTest) 91 add_subdirectory(test) 92endif() 93 94if(BOOST_PROPERTY_TREE_BUILD_EXAMPLES) 95 if (BOOST_SUPERPROJECT_VERSION) 96 message(STATUS "[property_tree] superproject build - skipping examples") 97 else() 98 add_subdirectory(examples) 99 endif() 100endif() 101