mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-19 04:12:09 +00:00
97 lines
3.9 KiB
CMake
97 lines
3.9 KiB
CMake
# Generated by `boostdep --cmake dynamic_bitset`
|
|
# Copyright 2020 Peter Dimov
|
|
# Copyright 2025 Gennaro Prota
|
|
# Distributed under the Boost Software License, Version 1.0.
|
|
# https://www.boost.org/LICENSE_1_0.txt
|
|
|
|
cmake_minimum_required(VERSION 3.5...3.16)
|
|
|
|
project(boost_dynamic_bitset VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
|
set(BOOST_DYNAMIC_BITSET_IS_ROOT OFF)
|
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
set(BOOST_DYNAMIC_BITSET_IS_ROOT ON)
|
|
endif ()
|
|
|
|
add_library(boost_dynamic_bitset INTERFACE)
|
|
add_library(Boost::dynamic_bitset ALIAS boost_dynamic_bitset)
|
|
|
|
target_include_directories(boost_dynamic_bitset INTERFACE include)
|
|
|
|
if (BOOST_DYNAMIC_BITSET_IS_ROOT)
|
|
# This means this script will be executed as the root CMakeLists.txt
|
|
# so the Boost:: targets are not available unless we explicitly include
|
|
# them here. MrDocs executes this script as root too.
|
|
if (NOT DEFINED BOOST_SRC_DIR AND DEFINED ENV{BOOST_SRC_DIR})
|
|
set(DEFAULT_BOOST_SRC_DIR "$ENV{BOOST_SRC_DIR}")
|
|
else ()
|
|
set(DEFAULT_BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
|
endif ()
|
|
set(BOOST_SRC_DIR ${DEFAULT_BOOST_SRC_DIR} CACHE STRING "Boost source dir to use when running CMake from this directory")
|
|
if (NOT IS_ABSOLUTE ${BOOST_SRC_DIR})
|
|
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BOOST_SRC_DIR}")
|
|
endif ()
|
|
|
|
# Validate BOOST_SRC_DIR
|
|
set(BOOST_SRC_DIR_IS_VALID ON)
|
|
foreach (F "CMakeLists.txt" "Jamroot" "boost-build.jam" "bootstrap.sh" "libs")
|
|
if (NOT EXISTS "${BOOST_SRC_DIR}/${F}")
|
|
message(STATUS "${BOOST_SRC_DIR}/${F} does not exist. Fallback to find_package.")
|
|
set(BOOST_SRC_DIR_IS_VALID OFF)
|
|
break()
|
|
endif ()
|
|
endforeach ()
|
|
if (NOT BOOST_SRC_DIR_IS_VALID)
|
|
message(FATAL_ERROR "BOOST_SRC_DIR is not valid. Please set it to the root of a Boost checkout.")
|
|
endif ()
|
|
|
|
# If BOOST_SRC_DIR is valid, fallback to find_package
|
|
set(CMAKE_FOLDER Dependencies)
|
|
set(BOOST_INCLUDE_LIBRARIES assert config container_hash core throw_exception)
|
|
set(BOOST_EXCLUDE_LIBRARIES dynamic_bitset)
|
|
set(PREV_BUILD_TESTING ${BUILD_TESTING})
|
|
set(BUILD_TESTING OFF CACHE BOOL "Build the tests." FORCE)
|
|
add_subdirectory(${BOOST_SRC_DIR} Dependencies/boost EXCLUDE_FROM_ALL)
|
|
set(BUILD_TESTING ${PREV_BUILD_TESTING} CACHE BOOL "Build the tests." FORCE)
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOOST_SRC_DIR}/tools/cmake/include")
|
|
unset(CMAKE_FOLDER)
|
|
endif()
|
|
|
|
target_link_libraries(boost_dynamic_bitset
|
|
INTERFACE
|
|
Boost::assert
|
|
Boost::config
|
|
Boost::container_hash
|
|
Boost::core
|
|
Boost::throw_exception
|
|
)
|
|
|
|
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
|
|
|
if (DYNAMIC_BITSET_MRDOCS_BUILD)
|
|
set(INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
|
|
|
|
# Create a temporary source file that includes boost/dynamic_bitset.hpp.
|
|
set(TEMP_CPP_FILE "${CMAKE_CURRENT_BINARY_DIR}/dynamic_bitset_for_mrdocs.cpp")
|
|
file(WRITE ${TEMP_CPP_FILE} "// This file is generated automatically by CMake\n\n")
|
|
file(APPEND ${TEMP_CPP_FILE} "#include \"boost/dynamic_bitset.hpp\"\n")
|
|
|
|
# Create a custom target for MrDocs.
|
|
add_library(dynamic_bitset_mrdocs_target ${TEMP_CPP_FILE})
|
|
|
|
# This is to get the documentation of the constructor from basic_string_view.
|
|
set_target_properties(dynamic_bitset_mrdocs_target PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES)
|
|
|
|
# Set any other target properties here.
|
|
target_include_directories(dynamic_bitset_mrdocs_target PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
|
target_link_libraries(dynamic_bitset_mrdocs_target PRIVATE boost_dynamic_bitset)
|
|
file(GLOB BOOST_MODULE_PATHS "$ENV{BOOST_SRC_DIR}/libs/*/include")
|
|
target_include_directories(dynamic_bitset_mrdocs_target PRIVATE ${BOOST_MODULE_PATHS})
|
|
|
|
# Don't create any other targets.
|
|
return()
|
|
endif()
|