Skip to content

Commit 6003234

Browse files
ashtumvinniefalco
authored andcommitted
Fix build scripts and CI
1 parent f4e1e12 commit 6003234

38 files changed

+1217
-1481
lines changed

.github/workflows/ci.yml

Lines changed: 133 additions & 47 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 136 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,164 @@
11
#
2-
# Copyright (c) 2023 Vinnie Falco ([email protected])
2+
# Copyright (c) 2019 Vinnie Falco ([email protected])
3+
# Copyright (c) 2021 DMitry Arkhipov ([email protected])
4+
# Copyright (c) 2022 Alan de Freitas ([email protected])
5+
# Copyright (c) 2025 Mohammad Nejati
36
#
47
# Distributed under the Boost Software License, Version 1.0. (See accompanying
58
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
69
#
710
# Official repository: https://github.com/cppalliance/buffers
811
#
912

10-
cmake_minimum_required(VERSION 3.8...3.16)
11-
13+
#-------------------------------------------------
14+
#
15+
# Project
16+
#
17+
#-------------------------------------------------
18+
cmake_minimum_required(VERSION 3.8...3.20)
1219
set(BOOST_BUFFERS_VERSION 1)
13-
if(BOOST_SUPERPROJECT_VERSION)
20+
if (BOOST_SUPERPROJECT_VERSION)
1421
set(BOOST_BUFFERS_VERSION ${BOOST_SUPERPROJECT_VERSION})
15-
endif()
16-
22+
endif ()
1723
project(boost_buffers VERSION "${BOOST_BUFFERS_VERSION}" LANGUAGES CXX)
18-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
19-
20-
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
21-
include(CTest)
22-
option(BOOST_BUFFERS_INSTALL "Install boost::buffers files" ON)
23-
option(BOOST_BUFFERS_BUILD_TESTS "Build boost::buffers tests" ${BUILD_TESTING})
24+
set(BOOST_BUFFERS_IS_ROOT OFF)
25+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2426
set(BOOST_BUFFERS_IS_ROOT ON)
25-
else()
26-
set(BOOST_BUFFERS_BUILD_TESTS ${BUILD_TESTING})
27-
set(BOOST_BUFFERS_IS_ROOT OFF)
28-
endif()
27+
endif ()
28+
set(__ignore__ ${CMAKE_C_COMPILER})
2929

30-
include(GNUInstallDirs)
31-
if(BOOST_BUFFERS_IS_ROOT)
32-
set(BOOST_INCLUDE_LIBRARIES buffers core asio)
33-
set(BOOST_EXCLUDE_LIBRARIES buffers)
34-
set(CMAKE_FOLDER Dependencies)
35-
add_subdirectory(../.. Dependencies/boost EXCLUDE_FROM_ALL)
36-
unset(CMAKE_FOLDER)
37-
endif()
30+
#-------------------------------------------------
31+
#
32+
# Options
33+
#
34+
#-------------------------------------------------
35+
if (BOOST_BUFFERS_IS_ROOT)
36+
include(CTest)
37+
endif ()
38+
option(BOOST_BUFFERS_BUILD_TESTS "Build boost::buffers tests" ${BUILD_TESTING})
39+
option(BOOST_BUFFERS_BUILD_EXAMPLES "Build boost::buffers examples" ${BOOST_BUFFERS_IS_ROOT})
3840

39-
function(boost_buffers_setup_properties target)
40-
target_compile_features(${target} PUBLIC cxx_constexpr)
41-
target_compile_definitions(${target} PUBLIC BOOST_BUFFERS_NO_LIB=1)
4241

43-
if(BOOST_SUPERPROJECT_VERSION)
44-
target_include_directories(${target} PUBLIC "${PROJECT_SOURCE_DIR}/include")
45-
else()
46-
target_include_directories(${target}
47-
PUBLIC
48-
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
49-
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
50-
)
51-
endif()
42+
# Check if environment variable BOOST_SRC_DIR is set
43+
if (NOT DEFINED BOOST_SRC_DIR AND DEFINED ENV{BOOST_SRC_DIR})
44+
set(DEFAULT_BOOST_SRC_DIR "$ENV{BOOST_SRC_DIR}")
45+
else ()
46+
set(DEFAULT_BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
47+
endif ()
48+
set(BOOST_SRC_DIR ${DEFAULT_BOOST_SRC_DIR} CACHE STRING "Boost source dir to use when running CMake from this directory")
5249

53-
target_link_libraries(${target}
54-
PUBLIC
55-
Boost::assert
56-
Boost::config
57-
Boost::core
58-
Boost::static_assert
59-
Boost::system
60-
PRIVATE
61-
Boost::throw_exception
50+
#-------------------------------------------------
51+
#
52+
# Boost modules
53+
#
54+
#-------------------------------------------------
55+
# The boost super-project requires one explicit dependency per-line.
56+
set(BOOST_BUFFERS_DEPENDENCIES
57+
Boost::core
6258
)
63-
endfunction()
64-
65-
file(GLOB_RECURSE BOOST_BUFFERS_HEADERS CONFIGURE_DEPENDS
66-
include/boost/*.hpp
67-
include/boost/*.ipp
68-
include/boost/*.natvis
69-
)
7059

71-
file(GLOB_RECURSE BOOST_BUFFERS_SOURCES CONFIGURE_DEPENDS src/*.cpp)
60+
foreach (BOOST_BUFFERS_DEPENDENCY ${BOOST_BUFFERS_DEPENDENCIES})
61+
if (BOOST_BUFFERS_DEPENDENCY MATCHES "^[ ]*Boost::([A-Za-z0-9_]+)[ ]*$")
62+
list(APPEND BOOST_BUFFERS_INCLUDE_LIBRARIES ${CMAKE_MATCH_1})
63+
endif ()
64+
endforeach ()
65+
# Conditional dependencies
66+
if (BOOST_BUFFERS_BUILD_TESTS)
67+
set(BOOST_BUFFERS_UNIT_TEST_LIBRARIES asio)
68+
endif ()
69+
if (BOOST_BUFFERS_BUILD_EXAMPLES)
70+
# set(BOOST_BUFFERS_EXAMPLE_LIBRARIES json)
71+
endif ()
72+
# Complete dependency list
73+
set(BOOST_INCLUDE_LIBRARIES ${BOOST_BUFFERS_INCLUDE_LIBRARIES} ${BOOST_BUFFERS_UNIT_TEST_LIBRARIES} ${BOOST_BUFFERS_EXAMPLE_LIBRARIES})
74+
set(BOOST_EXCLUDE_LIBRARIES buffers)
75+
76+
#-------------------------------------------------
77+
#
78+
# Add Boost Subdirectory
79+
#
80+
#-------------------------------------------------
81+
if (BOOST_BUFFERS_IS_ROOT)
82+
set(CMAKE_FOLDER Dependencies)
83+
# Find absolute BOOST_SRC_DIR
84+
if (NOT IS_ABSOLUTE ${BOOST_SRC_DIR})
85+
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BOOST_SRC_DIR}")
86+
endif ()
87+
88+
# Validate BOOST_SRC_DIR
89+
set(BOOST_SRC_DIR_IS_VALID ON)
90+
foreach (F "CMakeLists.txt" "Jamroot" "boost-build.jam" "bootstrap.sh" "libs")
91+
if (NOT EXISTS "${BOOST_SRC_DIR}/${F}")
92+
message(STATUS "${BOOST_SRC_DIR}/${F} does not exist. Fallback to find_package.")
93+
set(BOOST_SRC_DIR_IS_VALID OFF)
94+
break()
95+
endif ()
96+
endforeach ()
97+
98+
# Create Boost interface targets
99+
if (BOOST_SRC_DIR_IS_VALID)
100+
# From BOOST_SRC_DIR
101+
if (BUILD_SHARED_LIBS)
102+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
103+
endif ()
104+
set(BOOST_EXCLUDE_LIBRARIES ${PROJECT_NAME})
105+
set(PREV_BUILD_TESTING ${BUILD_TESTING})
106+
set(BUILD_TESTING OFF CACHE BOOL "Build the tests." FORCE)
107+
add_subdirectory(${BOOST_SRC_DIR} Dependencies/boost EXCLUDE_FROM_ALL)
108+
set(BUILD_TESTING ${PREV_BUILD_TESTING} CACHE BOOL "Build the tests." FORCE)
109+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOOST_SRC_DIR}/tools/cmake/include")
110+
else ()
111+
# From Boost Package
112+
find_package(Boost REQUIRED COMPONENTS buffers filesystem url)
113+
foreach (BOOST_INCLUDE_LIBRARY ${BOOST_INCLUDE_LIBRARIES})
114+
if (NOT TARGET Boost::${BOOST_INCLUDE_LIBRARY})
115+
add_library(Boost::${BOOST_INCLUDE_LIBRARY} ALIAS Boost::headers)
116+
endif ()
117+
endforeach ()
118+
endif ()
119+
unset(CMAKE_FOLDER)
120+
endif ()
72121

122+
#-------------------------------------------------
123+
#
124+
# Library
125+
#
126+
#-------------------------------------------------
73127
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
74128

129+
file(GLOB_RECURSE BOOST_BUFFERS_HEADERS CONFIGURE_DEPENDS include/boost/*.hpp include/boost/*.natvis)
130+
file(GLOB_RECURSE BOOST_BUFFERS_SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.hpp)
131+
75132
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/boost PREFIX "" FILES ${BOOST_BUFFERS_HEADERS})
76133
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "buffers" FILES ${BOOST_BUFFERS_SOURCES})
77-
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES Jamfile)
78134

79-
add_library(boost_buffers ${BOOST_BUFFERS_HEADERS} ${BOOST_BUFFERS_SOURCES} build/Jamfile)
135+
add_library(boost_buffers ${BOOST_BUFFERS_HEADERS} ${BOOST_BUFFERS_SOURCES})
80136
add_library(Boost::buffers ALIAS boost_buffers)
81-
boost_buffers_setup_properties(boost_buffers)
82-
83-
target_compile_definitions(boost_buffers
84-
PUBLIC
85-
BOOST_BUFFERS_NO_LIB
86-
)
87-
88-
if(BUILD_SHARED_LIBS)
89-
target_compile_definitions(boost_buffers PUBLIC BOOST_BUFFERS_DYN_LINK=1)
90-
else()
91-
target_compile_definitions(boost_buffers PUBLIC BOOST_BUFFERS_STATIC_LINK=1)
92-
endif()
137+
target_compile_features(boost_buffers PUBLIC cxx_constexpr)
138+
target_include_directories(boost_buffers PUBLIC "${PROJECT_SOURCE_DIR}/include")
139+
target_link_libraries(boost_buffers PUBLIC ${BOOST_BUFFERS_DEPENDENCIES})
140+
target_compile_definitions(boost_buffers PUBLIC BOOST_BUFFERS_NO_LIB)
93141
target_compile_definitions(boost_buffers PRIVATE BOOST_BUFFERS_SOURCE)
142+
if (BUILD_SHARED_LIBS)
143+
target_compile_definitions(boost_buffers PUBLIC BOOST_BUFFERS_DYN_LINK)
144+
else ()
145+
target_compile_definitions(boost_buffers PUBLIC BOOST_BUFFERS_STATIC_LINK)
146+
endif ()
94147

95-
if(BOOST_BUFFERS_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
96-
install(TARGETS boost_buffers
97-
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
98-
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
99-
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
100-
)
101-
endif()
102-
103-
if(BOOST_BUFFERS_BUILD_TESTS)
148+
#-------------------------------------------------
149+
#
150+
# Tests
151+
#
152+
#-------------------------------------------------
153+
if (BOOST_BUFFERS_BUILD_TESTS)
104154
add_subdirectory(test)
105-
endif()
155+
endif ()
156+
157+
#-------------------------------------------------
158+
#
159+
# Examples
160+
#
161+
#-------------------------------------------------
162+
if (BOOST_BUFFERS_BUILD_EXAMPLES)
163+
# add_subdirectory(example)
164+
endif ()

doc/antora.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023 Alan de Freitas ([email protected])
2+
# Copyright (c) 2025 Mohammad Nejati
33
#
44
# Distributed under the Boost Software License, Version 1.0. (See accompanying
55
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -18,8 +18,5 @@ asciidoc:
1818
nav:
1919
- modules/ROOT/nav.adoc
2020
ext:
21-
collector:
22-
run:
23-
command: node doc/generate-files.mjs
24-
scan:
25-
dir: doc/build/generated-files
21+
cpp-reference:
22+
config: doc/mrdocs.yml

doc/local-playbook.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,29 @@ content:
1414

1515
ui:
1616
bundle:
17-
url: https://github.com/cppalliance/site-docs/releases/download/ui-master/ui-bundle.zip
17+
url: https://github.com/boostorg/website-v2-docs/releases/download/ui-master/ui-bundle.zip
1818
snapshot: true
1919

2020
antora:
2121
extensions:
22-
- require: '@antora/lunr-extension'
22+
- require: '@antora/lunr-extension' # https://gitlab.com/antora/antora-lunr-extension
2323
index_latest_only: true
24-
- '@antora/collector-extension'
24+
- require: '@cppalliance/antora-cpp-tagfiles-extension'
25+
cpp-tagfiles:
26+
using-namespaces:
27+
- 'boost::'
28+
- require: '@cppalliance/antora-cpp-reference-extension'
29+
dependencies:
30+
- name: 'boost'
31+
repo: 'https://github.com/boostorg/boost.git'
32+
tag: 'develop'
33+
variable: 'BOOST_SRC_DIR'
34+
system-env: 'BOOST_SRC_DIR'
35+
2536
asciidoc:
37+
attributes:
38+
# Enable pagination
39+
page-pagination: ''
2640
extensions:
27-
- ./lib/boost-link-inline-macro.js
28-
- ./lib/cpp.js
41+
- '@cppalliance/asciidoctor-boost-links'
2942
- '@asciidoctor/tabs'

doc/mrdocs.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# Input
2-
input:
3-
# Directories that contain documented source files
4-
include:
5-
- ../include
6-
# Patterns to filter out the source-files in the directories
7-
file-patterns:
8-
- '*.hpp'
92
source-root: ..
3+
# Directories that contain documented source files
4+
input:
5+
- ../include
6+
# Patterns to filter out the source-files in the directories
7+
file-patterns:
8+
- '*.hpp'
109

1110
# Filters
12-
filters:
13-
symbols:
14-
exclude:
15-
- 'boost::buffers::detail'
16-
- 'boost::buffers::*::detail'
11+
include-symbols:
12+
- 'boost::buffers::**'
13+
implementation-defined:
14+
- 'boost::buffers::detail'
15+
- 'boost::buffers::*::detail'
1716
inaccessible-members: never
1817
inaccessible-bases: never
1918

@@ -24,5 +23,6 @@ base-url: https://www.github.com/cppalliance/buffers/blob/develop/include/
2423
# Style
2524
verbose: true
2625
multipage: true
26+
use-system-libc: true
2727

28-
cmake: '-D BUILD_TESTING=ON'
28+
cmake: '-DCMAKE_CXX_STANDARD=20 -DBOOST_BUFFERS_BUILD_TESTS=OFF -DBOOST_BUFFERS_BUILD_EXAMPLES=OFF'

0 commit comments

Comments
 (0)