@@ -7,16 +7,24 @@ cmake_minimum_required(VERSION 3.5...3.16)
7
7
8
8
project (boost_random VERSION "${BOOST_SUPERPROJECT_VERSION} " LANGUAGES CXX)
9
9
10
- add_library (boost_random
11
- src/random_device.cpp
12
- )
10
+ option (BOOST_RANDOM_ENABLE_RANDOM_DEVICE "Build boost::random_device" ON )
11
+
12
+ if (BOOST_RANDOM_ENABLE_RANDOM_DEVICE)
13
+ add_library (boost_random
14
+ src/random_device.cpp
15
+ )
16
+ set (_populate PUBLIC )
17
+ else ()
18
+ add_library (boost_random INTERFACE )
19
+ set (_populate INTERFACE )
20
+ endif ()
13
21
14
22
add_library (Boost::random ALIAS boost_random)
15
23
16
- target_include_directories (boost_random PUBLIC include )
24
+ target_include_directories (boost_random ${_populate} include )
17
25
18
26
target_link_libraries (boost_random
19
- PUBLIC
27
+ ${_populate}
20
28
Boost::assert
21
29
Boost::config
22
30
Boost::core
@@ -30,18 +38,20 @@ target_link_libraries(boost_random
30
38
Boost::utility
31
39
)
32
40
33
- target_compile_features (boost_random PUBLIC cxx_std_11)
41
+ target_compile_features (boost_random ${_populate} cxx_std_11)
34
42
35
43
target_compile_definitions (boost_random
36
- PUBLIC BOOST_RANDOM_NO_LIB
44
+ ${_populate} BOOST_RANDOM_NO_LIB
37
45
# Source files already define BOOST_RANDOM_SOURCE
38
46
# PRIVATE BOOST_RANDOM_SOURCE
39
47
)
40
48
41
- if (BUILD_SHARED_LIBS )
42
- target_compile_definitions (boost_random PUBLIC BOOST_RANDOM_DYN_LINK)
43
- else ()
44
- target_compile_definitions (boost_random PUBLIC BOOST_RANDOM_STATIC_LINK)
49
+ if (BOOST_RANDOM_ENABLE_RANDOM_DEVICE)
50
+ if (BUILD_SHARED_LIBS )
51
+ target_compile_definitions (boost_random PUBLIC BOOST_RANDOM_DYN_LINK)
52
+ else ()
53
+ target_compile_definitions (boost_random PUBLIC BOOST_RANDOM_STATIC_LINK)
54
+ endif ()
45
55
endif ()
46
56
47
57
if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /test/CMakeLists.txt" )
0 commit comments