Skip to content

Commit

Permalink
Try a different include approach.
Browse files Browse the repository at this point in the history
  • Loading branch information
fruffy committed May 15, 2024
1 parent a6c3199 commit de834be
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ if (ENABLE_GC)
endif ()
set (P4C_ABSL_LIBRARIES absl::flat_hash_map absl::flat_hash_set)
list (APPEND P4C_LIB_DEPS ${P4C_ABSL_LIBRARIES})
list(APPEND P4C_LIB_DEPS Boost::iostreams Boost::format Boost::multiprecision)
set (P4C_BOOST_LIBRARIES Boost::iostreams Boost::format Boost::multiprecision)
list(APPEND P4C_LIB_DEPS ${P4C_BOOST_LIBRARIES})

# Other required libraries.
p4c_add_library (rt clock_gettime HAVE_CLOCK_GETTIME)
Expand Down
165 changes: 162 additions & 3 deletions cmake/Boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ macro(p4c_obtain_boost)
# Always link Boost statically.
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_MP_STANDALONE ON CACHE BOOL "Use Boost.Multiprecision in standalone mode")
# set(BOOST_MP_STANDALONE ON CACHE BOOL "Use Boost.Multiprecision in standalone mode")

# Download and extract the boost library from GitHub.
message(STATUS "Downloading and extracting boost library sources. This may take some time...")
Expand All @@ -59,10 +59,169 @@ macro(p4c_obtain_boost)
DOWNLOAD_NO_EXTRACT FALSE
)
FetchContent_MakeAvailable(Boost)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/iostreams/include)
# Force inclusion of the correct Boost headers. This is necessary because users may have their own system boost headers which can be in conflict.
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/accumulators/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/algorithm/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/align/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/any/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/array/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/asio/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/assert/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/assign/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/atomic/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/beast/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/bimap/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/bind/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/callable_traits/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/charconv/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/chrono/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/circular_buffer/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/cobalt/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/compat/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/compatibility/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/compute/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/concept_check/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/config/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/container/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/container_hash/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/context/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/contract/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/conversion/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/convert/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/core/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/coroutine/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/coroutine2/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/crc/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/date_time/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/describe/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/detail/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/dll/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/dynamic_bitset/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/endian/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/exception/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/fiber/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/filesystem/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/flyweight/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/foreach/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/format/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/multiprecision/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/function/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/functional/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/function_types/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/fusion/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/geometry/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/gil/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/graph/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/graph_parallel/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/hana/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/headers/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/heap/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/histogram/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/hof/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/icl/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/integer/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/interprocess/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/intrusive/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/io/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/iostreams/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/iterator/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/json/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/lambda/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/lambda2/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/leaf/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/lexical_cast/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/locale/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/local_function/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/lockfree/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/log/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/logic/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/math/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/metaparse/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/move/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/mp11/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/mpi/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/mpl/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/msm/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/multi_array/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/multi_index/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/multiprecision/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/mysql/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/nowide/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/numeric/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/optional/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/outcome/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/parameter/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/parameter_python/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/pfr/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/phoenix/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/poly_collection/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/polygon/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/pool/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/predef/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/preprocessor/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/process/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/program_options/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/property_map/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/property_map_parallel/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/property_tree/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/proto/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/ptr_container/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/python/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/qvm/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/random/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/range/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/ratio/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/rational/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/redis/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/regex/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/safe_numerics/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/scope/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/scope_exit/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/serialization/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/signals2/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/smart_ptr/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/sort/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/spirit/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/stacktrace/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/statechart/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/static_assert/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/static_string/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/stl_interfaces/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/system/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/test/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/thread/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/throw_exception/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/timer/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/tokenizer/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/tti/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/tuple/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/type_erasure/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/type_index/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/typeof/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/type_traits/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/units/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/unordered/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/url/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/utility/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/uuid/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/variant/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/variant2/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/vmd/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/wave/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/winapi/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/xpressive/include)
include_directories(BEFORE SYSTEM ${Boost_SOURCE_DIR}/libs/yap/include)

# Suppress warnings for all Boost targets.
get_all_targets(BOOST_BUILD_TARGETS ${boost_SOURCE_DIR})
foreach(target in ${BOOST_BUILD_TARGETS})
if(target MATCHES "boost_*")
# Do not suppress warnings for Boost library targets that are aliased.
get_target_property(target_type ${target} TYPE)
if (NOT ${target_type} STREQUAL "INTERFACE_LIBRARY")
target_compile_options(${target} PRIVATE "-Wno-error" "-w")
endif()
endif()
endforeach()


# Reset temporary variable modifications.
Expand Down
1 change: 1 addition & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ target_link_libraries(p4ctoolkit
# These libraries are exposed by a header.
PUBLIC absl::bits
PUBLIC ${LIBGC_LIBRARIES}
PUBLIC Boost::format Boost::multiprecision
)

0 comments on commit de834be

Please sign in to comment.