-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
CMakeLists.txt
181 lines (132 loc) · 4.18 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# 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.20)
project(boost_locale VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_locale
src/encoding/codepage.cpp
src/shared/date_time.cpp
src/shared/format.cpp
src/shared/formatting.cpp
src/shared/generator.cpp
src/shared/ids.cpp
src/shared/localization_backend.cpp
src/shared/message.cpp
src/shared/mo_lambda.cpp
src/util/codecvt_converter.cpp
src/util/default_locale.cpp
src/util/info.cpp
src/util/locale_data.cpp
)
add_library(Boost::locale ALIAS boost_locale)
target_include_directories(boost_locale PUBLIC include)
target_link_libraries(boost_locale
PUBLIC
Boost::assert
Boost::config
Boost::function
Boost::iterator
Boost::smart_ptr
Boost::static_assert
Boost::type_traits
PRIVATE
Boost::thread
Boost::unordered
)
target_compile_definitions(boost_locale
PUBLIC BOOST_LOCALE_NO_LIB
# Source files already define BOOST_LOCALE_SOURCE
# PRIVATE BOOST_LOCALE_SOURCE
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_locale PUBLIC BOOST_LOCALE_DYN_LINK)
else()
target_compile_definitions(boost_locale PUBLIC BOOST_LOCALE_STATIC_LINK)
endif()
# Build Options
find_package(Iconv QUIET) # requires CMake 3.11
find_package(ICU COMPONENTS data i18n uc QUIET)
set(_default_posix OFF)
if(CMAKE_SYSTEM_NAME MATCHES "Linux|Darwin")
set(_default_posix ON)
endif()
option(BOOST_LOCALE_ENABLE_ICONV "Boost.Locale: enable iconv backend" ${ICONV_FOUND})
option(BOOST_LOCALE_ENABLE_ICU "Boost.Locale: enable ICU backend" ${ICU_FOUND})
option(BOOST_LOCALE_ENABLE_POSIX "Boost.Locale: enable POSIX backend" ${_default_posix})
option(BOOST_LOCALE_ENABLE_STD "Boost.Locale: enable std::locale backend" ON)
option(BOOST_LOCALE_ENABLE_WINAPI "Boost.Locale: enable Windows API backend" ${WIN32})
unset(_default_posix)
if(BOOST_LOCALE_ENABLE_ICONV)
find_package(Iconv REQUIRED)
target_compile_definitions(boost_locale PRIVATE BOOST_LOCALE_WITH_ICONV=1)
target_link_libraries(boost_locale PRIVATE Iconv::Iconv)
endif()
if(BOOST_LOCALE_ENABLE_ICU)
find_package(ICU COMPONENTS data i18n uc REQUIRED)
target_compile_definitions(boost_locale PRIVATE BOOST_LOCALE_WITH_ICU=1)
target_link_libraries(boost_locale PRIVATE ICU::data ICU::i18n ICU::uc)
target_sources(boost_locale PRIVATE
src/icu/boundary.cpp
src/icu/codecvt.cpp
src/icu/collator.cpp
src/icu/conversion.cpp
src/icu/date_time.cpp
src/icu/formatter.cpp
src/icu/icu_backend.cpp
src/icu/numeric.cpp
src/icu/time_zone.cpp
)
endif()
if(BOOST_LOCALE_ENABLE_STD)
target_sources(boost_locale PRIVATE
src/std/codecvt.cpp
src/std/collate.cpp
src/std/converter.cpp
src/std/numeric.cpp
src/std/std_backend.cpp
)
else()
target_compile_definitions(boost_locale PRIVATE BOOST_LOCALE_NO_STD_BACKEND=1)
endif()
if(BOOST_LOCALE_ENABLE_WINAPI)
target_sources(boost_locale PRIVATE
src/win32/collate.cpp
src/win32/converter.cpp
src/win32/numeric.cpp
src/win32/win_backend.cpp
)
else()
target_compile_definitions(boost_locale PRIVATE BOOST_LOCALE_NO_WINAPI_BACKEND=1)
endif()
if(BOOST_LOCALE_ENABLE_WINAPI OR (BOOST_LOCALE_ENABLE_STD AND WIN32))
target_sources(boost_locale PRIVATE
src/win32/lcid.cpp
)
endif()
if(BOOST_LOCALE_ENABLE_POSIX)
target_sources(boost_locale PRIVATE
src/posix/collate.cpp
src/posix/converter.cpp
src/posix/numeric.cpp
src/posix/codecvt.cpp
src/posix/posix_backend.cpp
)
else()
target_compile_definitions(boost_locale PRIVATE BOOST_LOCALE_NO_POSIX_BACKEND=1)
endif()
if(BOOST_LOCALE_ENABLE_WINAPI OR BOOST_LOCALE_ENABLE_STD OR BOOST_LOCALE_ENABLE_POSIX)
target_sources(boost_locale PRIVATE
src/util/gregorian.cpp
)
endif()
message(STATUS "Boost.Locale: "
"iconv ${BOOST_LOCALE_ENABLE_ICONV}, "
"ICU ${BOOST_LOCALE_ENABLE_ICU}, "
"POSIX ${BOOST_LOCALE_ENABLE_POSIX}, "
"std ${BOOST_LOCALE_ENABLE_STD}, "
"winapi ${BOOST_LOCALE_ENABLE_WINAPI}"
)
# Testing
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()