Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ jobs:
needs: posix
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
compile_commands.json
120 changes: 98 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,122 @@
# -----------------------------------------------------------------------------
# Boost.Any CMake
# Handles: no modules, modules, modules + import std;
# -----------------------------------------------------------------------------
# Copyright 2019 Mike Dev
# 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
# -----------------------------------------------------------------------------

cmake_minimum_required( VERSION 3.8...3.31 )
project( boost_any VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
cmake_minimum_required(VERSION 3.21...4.3)

project(boost_any VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

if(PROJECT_IS_TOP_LEVEL)
find_package(Boost 1.90.0 CONFIG)
endif()

# -----------------------------------------------------------------------------
# User option: enable C++ modules
# -----------------------------------------------------------------------------
option(BOOST_USE_MODULES "Build Boost using C++ modules" OFF)

# -----------------------------------------------------------------------------
# Determine target type and sources
# -----------------------------------------------------------------------------
if(BOOST_USE_MODULES)

# Ensure CMAKE_CXX_STANDARD is set for module detection
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()

if (BOOST_USE_MODULES)
add_library(boost_any)
target_sources(boost_any PUBLIC
FILE_SET modules_public
TYPE CXX_MODULES
FILES modules/boost_any.cppm

target_sources(
boost_any
PUBLIC
FILE_SET modules_public
TYPE CXX_MODULES
FILES modules/boost_any.cppm
)

target_compile_features(boost_any PUBLIC cxx_std_20)
# Require C++20 for modules
target_compile_features(boost_any PUBLIC cxx_std_${CMAKE_CXX_STANDARD})

# Define macro indicating modules usage
target_compile_definitions(boost_any PUBLIC BOOST_USE_MODULES)
set(__boost_cxx_standard ${CMAKE_CXX_STANDARD})
if (NOT __boost_cxx_standard)
set(__boost_cxx_standard 20)
endif()
if (CMAKE_CXX_COMPILER_IMPORT_STD AND ${__boost_cxx_standard} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
target_compile_definitions(boost_any PRIVATE BOOST_ANY_USE_STD_MODULE)
message(STATUS "Using `import std;`")

# Check if import std; is available for the current standard
if(${CMAKE_CXX_STANDARD} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
target_compile_definitions(boost_any PUBLIC BOOST_ANY_USE_STD_MODULE)
set_property(TARGET boost_any PROPERTY CXX_MODULE_STD ON)
message(STATUS "Boost.Any: Using `import std;`")
else()
message(STATUS "`import std;` is not available")
message(WARNING "Boost.Any: `import std;` is not available for C++${CMAKE_CXX_STANDARD}")
endif()

set(__scope PUBLIC)

else()

# Modules disabled -> INTERFACE library
add_library(boost_any INTERFACE)

# If modules are disabled, require C++17 for headers
target_compile_features(boost_any INTERFACE cxx_std_17)

# Verify interface headers only at top level
if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)
endif()

set(__scope INTERFACE)

endif()

target_include_directories(boost_any ${__scope} include)
target_link_libraries( boost_any
${__scope}
# -----------------------------------------------------------------------------
# Include headers
# -----------------------------------------------------------------------------
# Note: usable starting with cmake v3.23
if(NOT CMAKE_VERSION VERSION_LESS 3.23)
target_sources(
boost_any
PUBLIC
FILE_SET headers_public
TYPE HEADERS
BASE_DIRS include
FILES
include/boost/any/bad_any_cast.hpp
include/boost/any/basic_any.hpp
include/boost/any/fwd.hpp
include/boost/any/unique_any.hpp
include/boost/any/detail/config.hpp
include/boost/any/detail/placeholder.hpp
)
else()
target_include_directories(boost_any ${__scope} include)
endif()

# -----------------------------------------------------------------------------
# Link dependencies
# -----------------------------------------------------------------------------
if(PROJECT_IS_TOP_LEVEL)
target_link_libraries(boost_any ${__scope} Boost::headers)
else()
target_link_libraries(boost_any
${__scope}
Boost::config
Boost::throw_exception
Boost::type_index
)
)
endif()

add_library( Boost::any ALIAS boost_any )
# Alias for convenient import
add_library(Boost::any ALIAS boost_any)

# -----------------------------------------------------------------------------
# Testing
# -----------------------------------------------------------------------------
if(BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
10 changes: 8 additions & 2 deletions include/boost/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@

#include <boost/any/detail/config.hpp>

#if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#ifndef BOOST_IN_MODULE_PURVIEW
// XXX import boost.core;
#endif

#else

/// \file boost/any.hpp
/// \brief \copybrief boost::any
Expand Down Expand Up @@ -377,6 +383,6 @@ BOOST_ANY_END_MODULE_EXPORT
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#endif // #if defined(BOOST_USE_MODULES) // !defined(BOOST_ANY_INTERFACE_UNIT)

#endif
10 changes: 8 additions & 2 deletions include/boost/any/bad_any_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@

#include <boost/any/detail/config.hpp>

#if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#ifndef BOOST_IN_MODULE_PURVIEW
// XXX import boost.core;
#endif

#else

#ifndef BOOST_ANY_INTERFACE_UNIT
#include <boost/config.hpp>
Expand Down Expand Up @@ -51,6 +57,6 @@ BOOST_ANY_END_MODULE_EXPORT

} // namespace boost

#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#endif // #if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#endif // #ifndef BOOST_ANYS_BAD_ANY_CAST_HPP_INCLUDED
10 changes: 8 additions & 2 deletions include/boost/any/basic_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

#include <boost/any/detail/config.hpp>

#if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#ifndef BOOST_IN_MODULE_PURVIEW
// XXX import boost.core;
#endif

#else

/// \file boost/any/basic_any.hpp
/// \brief \copybrief boost::anys::basic_any
Expand Down Expand Up @@ -567,6 +573,6 @@ BOOST_ANY_END_MODULE_EXPORT

} // namespace boost

#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#endif // #if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#endif // #ifndef BOOST_ANYS_BASIC_ANY_HPP_INCLUDED
10 changes: 8 additions & 2 deletions include/boost/any/detail/placeholder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@

#include <boost/any/detail/config.hpp>

#if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#ifndef BOOST_IN_MODULE_PURVIEW
// XXX import boost.core;
#endif

#else

#ifndef BOOST_ANY_INTERFACE_UNIT
#include <boost/config.hpp>
Expand All @@ -36,6 +42,6 @@ class BOOST_SYMBOL_VISIBLE placeholder {
} // namespace boost
/// @endcond

#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#endif // #if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#endif // #ifndef BOOST_ANY_ANYS_DETAIL_PLACEHOLDER_HPP
13 changes: 11 additions & 2 deletions include/boost/any/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@

#include <boost/any/detail/config.hpp>

#if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#ifndef BOOST_IN_MODULE_PURVIEW
// XXX import boost.core;
#endif

#else

#ifndef BOOST_ANY_INTERFACE_UNIT
#include <boost/config.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
# pragma once
#endif

#include <type_traits>

#endif // #ifndef BOOST_ANY_INTERFACE_UNIT

/// \file boost/any/fwd.hpp
Expand Down Expand Up @@ -66,6 +75,6 @@ namespace detail {
} // namespace boost
/// @endcond

#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#endif // #if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#endif // #ifndef BOOST_ANY_ANYS_FWD_HPP
10 changes: 8 additions & 2 deletions include/boost/any/unique_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@

#include <boost/any/detail/config.hpp>

#if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#ifndef BOOST_IN_MODULE_PURVIEW
// XXX import boost.core;
#endif

#else

/// \file boost/any/unique_any.hpp
/// \brief \copybrief boost::anys::unique_any
Expand Down Expand Up @@ -363,6 +369,6 @@ BOOST_ANY_END_MODULE_EXPORT

} // namespace boost

#endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_ANY_INTERFACE_UNIT)
#endif // #if defined(BOOST_USE_MODULES) && !defined(BOOST_ANY_INTERFACE_UNIT)

#endif // BOOST_ANYS_UNIQUE_ANY_HPP_INCLUDED
23 changes: 16 additions & 7 deletions modules/boost_any.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,40 @@
// To compile manually use a command like the following:
// clang++ -I ../include -std=c++20 --precompile -x c++-module any.cppm

// Global module fragment.
module;

#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/type_index.hpp>

#ifdef BOOST_ANY_USE_STD_MODULE
import std;
#else
#include <memory>
#include <memory> // for std::addressof

#ifndef BOOST_ANY_USE_STD_MODULE
#include <stdexcept>
#include <typeinfo>
#include <type_traits>
#include <utility>
#endif

#define BOOST_ANY_INTERFACE_UNIT

// Begins the module purview
export module boost.any;

import boost.type_index;

#ifdef BOOST_ANY_USE_STD_MODULE
import std;
#endif

// We will use these macros when we get to compatibility headers
#define BOOST_ANY_INTERFACE_UNIT
#define BOOST_IN_MODULE_PURVIEW

#ifdef __clang__
# pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
#endif

// Include the entire library
#include <boost/any.hpp>
#include <boost/any/basic_any.hpp>
#include <boost/any/unique_any.hpp>
Expand Down
Loading