-
Notifications
You must be signed in to change notification settings - Fork 118
/
CMakeLists.txt
121 lines (85 loc) · 3.57 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Copyright 2020, 2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_iostreams VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_iostreams
src/file_descriptor.cpp
src/mapped_file.cpp
)
function(boost_iostreams_option name description package version found target) # sources...
find_package(${package} ${version} QUIET)
if(${found} AND TARGET ${target})
option(${name} ${description} ON)
else()
option(${name} ${description} OFF)
endif()
if(${name})
find_package(${package} ${version} REQUIRED)
target_sources(boost_iostreams PRIVATE ${ARGN})
target_link_libraries(boost_iostreams PRIVATE ${target})
endif()
endfunction()
set(BOOST_IOSTREAMS_ZSTD_TARGET "zstd::libzstd_shared" CACHE STRING "Target name for Zstd (zstd::libzstd_shared, zstd::libzstd_static)")
set_property(CACHE BOOST_IOSTREAMS_ZSTD_TARGET PROPERTY STRINGS "zstd::libzstd_shared" "zstd::libzstd_static")
boost_iostreams_option(BOOST_IOSTREAMS_ENABLE_ZLIB "Boost.Iostreams: Enable ZLIB support" ZLIB "" ZLIB_FOUND ZLIB::ZLIB src/zlib.cpp src/gzip.cpp)
boost_iostreams_option(BOOST_IOSTREAMS_ENABLE_BZIP2 "Boost.Iostreams: Enable BZip2 support" BZip2 "" BZIP2_FOUND BZip2::BZip2 src/bzip2.cpp)
boost_iostreams_option(BOOST_IOSTREAMS_ENABLE_LZMA "Boost.Iostreams: Enable LZMA support" LibLZMA "" LIBLZMA_FOUND LibLZMA::LibLZMA src/lzma.cpp)
boost_iostreams_option(BOOST_IOSTREAMS_ENABLE_ZSTD "Boost.Iostreams: Enable Zstd support" zstd "1.0" zstd_FOUND ${BOOST_IOSTREAMS_ZSTD_TARGET} src/zstd.cpp)
include(CheckCXXSourceCompiles)
function(iostreams_check var source incs libs defs)
set(CMAKE_REQUIRED_INCLUDES "${incs}")
list(APPEND CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/build")
set(CMAKE_REQUIRED_LIBRARIES "${libs}")
set(CMAKE_REQUIRED_DEFINITIONS "${defs}")
check_cxx_source_compiles("#include \"${source}\"" ${var})
set(${var} ${${var}} PARENT_SCOPE)
endfunction()
set(_lzma_mt "")
if(BOOST_IOSTREAMS_ENABLE_LZMA)
iostreams_check(BOOST_IOSTREAMS_HAS_LZMA_CPUTHREADS has_lzma_cputhreads.cpp "" "LibLZMA::LibLZMA" "")
if(BOOST_IOSTREAMS_HAS_LZMA_CPUTHREADS)
set(_lzma_mt " (multithreaded)")
else()
target_compile_definitions(boost_iostreams PRIVATE BOOST_IOSTREAMS_LZMA_NO_MULTITHREADED=1)
endif()
endif()
message(STATUS "Boost.Iostreams: ZLIB ${BOOST_IOSTREAMS_ENABLE_ZLIB}, BZip2 ${BOOST_IOSTREAMS_ENABLE_BZIP2}, LZMA ${BOOST_IOSTREAMS_ENABLE_LZMA}${_lzma_mt}, Zstd ${BOOST_IOSTREAMS_ENABLE_ZSTD}")
unset(_lzma_mt)
add_library(Boost::iostreams ALIAS boost_iostreams)
target_include_directories(boost_iostreams PUBLIC include)
target_link_libraries(boost_iostreams
PUBLIC
Boost::assert
Boost::config
Boost::core
Boost::detail
Boost::function
Boost::integer
Boost::iterator
Boost::mpl
Boost::preprocessor
Boost::random
Boost::range
Boost::regex
Boost::smart_ptr
Boost::static_assert
Boost::throw_exception
Boost::type_traits
Boost::utility
PRIVATE
Boost::numeric_conversion
)
target_compile_definitions(boost_iostreams
PUBLIC BOOST_IOSTREAMS_NO_LIB
# Source files already define BOOST_IOSTREAMS_SOURCE
# PRIVATE BOOST_IOSTREAMS_SOURCE
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_iostreams PUBLIC BOOST_IOSTREAMS_DYN_LINK)
else()
target_compile_definitions(boost_iostreams PUBLIC BOOST_IOSTREAMS_STATIC_LINK)
endif()
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()