Skip to content

Commit 7207f47

Browse files
committed
Add option to use header-only Boost::container
1 parent 83b8d57 commit 7207f47

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

CMakeLists.txt

+27-16
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,49 @@ cmake_minimum_required(VERSION 3.5...3.16)
66

77
project(boost_container VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES C CXX)
88

9-
add_library(boost_container
10-
src/alloc_lib.c
11-
src/dlmalloc.cpp
12-
src/global_resource.cpp
13-
src/monotonic_buffer_resource.cpp
14-
src/pool_resource.cpp
15-
src/synchronized_pool_resource.cpp
16-
src/unsynchronized_pool_resource.cpp
17-
)
9+
option(Boost_CONTAINER_HEADER_ONLY "Build Extended Allocators and Some Polymorphic Memory Resources classes" OFF)
10+
11+
if(Boost_CONTAINER_HEADER_ONLY)
12+
add_library(boost_container INTERFACE)
13+
set(_populate INTERFACE)
14+
else()
15+
add_library(boost_container
16+
src/alloc_lib.c
17+
src/dlmalloc.cpp
18+
src/global_resource.cpp
19+
src/monotonic_buffer_resource.cpp
20+
src/pool_resource.cpp
21+
src/synchronized_pool_resource.cpp
22+
src/unsynchronized_pool_resource.cpp
23+
)
24+
set(_populate PUBLIC)
25+
endif()
26+
1827

1928
add_library(Boost::container ALIAS boost_container)
2029

21-
target_include_directories(boost_container PUBLIC include)
30+
target_include_directories(boost_container ${_populate} include)
2231

2332
target_link_libraries(boost_container
24-
PUBLIC
33+
${_populate}
2534
Boost::assert
2635
Boost::config
2736
Boost::intrusive
2837
Boost::move
2938
)
3039

3140
target_compile_definitions(boost_container
32-
PUBLIC BOOST_CONTAINER_NO_LIB
41+
${_populate} BOOST_CONTAINER_NO_LIB
3342
# Source files already define BOOST_CONTAINER_SOURCE
3443
# PRIVATE BOOST_CONTAINER_SOURCE
3544
)
3645

37-
if(BUILD_SHARED_LIBS)
38-
target_compile_definitions(boost_container PUBLIC BOOST_CONTAINER_DYN_LINK)
39-
else()
40-
target_compile_definitions(boost_container PUBLIC BOOST_CONTAINER_STATIC_LINK)
46+
if(NOT Boost_CONTAINER_HEADER_ONLY)
47+
if(BUILD_SHARED_LIBS)
48+
target_compile_definitions(boost_container ${_populate} BOOST_CONTAINER_DYN_LINK)
49+
else()
50+
target_compile_definitions(boost_container ${_populate} BOOST_CONTAINER_STATIC_LINK)
51+
endif()
4152
endif()
4253

4354
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")

0 commit comments

Comments
 (0)