facter 3.11.0.cfacter.20180319 → 3.11.2.cfacter.20180606

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/ext/facter/facter/CMakeLists.txt +1 -1
  3. data/ext/facter/facter/acceptance/Gemfile +4 -3
  4. data/ext/facter/facter/acceptance/Rakefile +2 -342
  5. data/ext/facter/facter/acceptance/config/aio/options.rb +0 -6
  6. data/ext/facter/facter/acceptance/config/git/options.rb +1 -5
  7. data/ext/facter/facter/lib/Doxyfile +1 -1
  8. data/ext/facter/facter/lib/inc/internal/facts/aix/networking_resolver.hpp +7 -0
  9. data/ext/facter/facter/lib/inc/internal/facts/bsd/networking_resolver.hpp +2 -0
  10. data/ext/facter/facter/lib/inc/internal/facts/freebsd/networking_resolver.hpp +7 -0
  11. data/ext/facter/facter/lib/inc/internal/facts/linux/networking_resolver.hpp +7 -0
  12. data/ext/facter/facter/lib/inc/internal/facts/openbsd/networking_resolver.hpp +7 -0
  13. data/ext/facter/facter/lib/inc/internal/facts/osx/networking_resolver.hpp +7 -0
  14. data/ext/facter/facter/lib/inc/internal/facts/posix/networking_resolver.hpp +7 -0
  15. data/ext/facter/facter/lib/inc/internal/facts/resolvers/networking_resolver.hpp +3 -2
  16. data/ext/facter/facter/lib/inc/internal/facts/solaris/networking_resolver.hpp +7 -0
  17. data/ext/facter/facter/lib/src/facts/aix/disk_resolver.cc +11 -2
  18. data/ext/facter/facter/lib/src/facts/aix/networking_resolver.cc +5 -0
  19. data/ext/facter/facter/lib/src/facts/bsd/networking_resolver.cc +60 -4
  20. data/ext/facter/facter/lib/src/facts/freebsd/networking_resolver.cc +10 -1
  21. data/ext/facter/facter/lib/src/facts/linux/networking_resolver.cc +10 -1
  22. data/ext/facter/facter/lib/src/facts/openbsd/networking_resolver.cc +10 -1
  23. data/ext/facter/facter/lib/src/facts/osx/networking_resolver.cc +10 -1
  24. data/ext/facter/facter/lib/src/facts/posix/networking_resolver.cc +2 -1
  25. data/ext/facter/facter/lib/src/facts/resolvers/networking_resolver.cc +23 -7
  26. data/ext/facter/facter/lib/src/facts/solaris/networking_resolver.cc +5 -0
  27. data/ext/facter/facter/locales/FACTER.pot +32 -1
  28. data/ext/facter/leatherman/CHANGELOG.md +9 -0
  29. data/ext/facter/leatherman/CMakeLists.txt +2 -1
  30. data/ext/facter/leatherman/cmake/FindICU.cmake +690 -0
  31. data/ext/facter/leatherman/locale/CMakeLists.txt +7 -0
  32. metadata +4 -9
  33. data/ext/facter/facter/acceptance/setup/aio/pre-suite/010_Install.rb +0 -22
  34. data/ext/facter/facter/acceptance/setup/aio/pre-suite/021_InstallAristaModule.rb +0 -12
  35. data/ext/facter/facter/acceptance/setup/aio/pre-suite/022_Remove_LD_PRELOAD.rb +0 -11
  36. data/ext/facter/facter/acceptance/setup/common/00_EnvSetup.rb +0 -64
  37. data/ext/facter/facter/acceptance/setup/common/pre-suite/000-delete-puppet-when-none.rb +0 -11
  38. data/ext/facter/facter/acceptance/setup/git/pre-suite/01_TestSetup.rb +0 -31
@@ -1,5 +1,5 @@
1
1
  cmake_minimum_required(VERSION 3.2.2)
2
- project(leatherman VERSION 1.4.0)
2
+ project(leatherman VERSION 1.4.1)
3
3
 
4
4
  if (WIN32)
5
5
  link_libraries("-Wl,--nxcompat -Wl,--dynamicbase")
@@ -29,6 +29,7 @@ defoption(LEATHERMAN_DEBUG "Enable verbose logging messages from leatherman macr
29
29
  defoption(LEATHERMAN_ENABLE_TESTING "Build the leatherman test binary" ${LEATHERMAN_DEFAULT_ENABLE})
30
30
  defoption(LEATHERMAN_INSTALL "Install the leatherman libraries and headers" ${LEATHERMAN_DEFAULT_ENABLE})
31
31
  defoption(LEATHERMAN_SHARED "Create shared libraries instead of static" FALSE)
32
+ defoption(LEATHERMAN_USE_ICU "Set when Boost is built with ICU" FALSE)
32
33
 
33
34
  set(BUILDING_LEATHERMAN TRUE)
34
35
 
@@ -0,0 +1,690 @@
1
+ # This module can find the International Components for Unicode (ICU) libraries
2
+ #
3
+ # Requirements:
4
+ # - CMake >= 2.8.3 (for new version of find_package_handle_standard_args)
5
+ #
6
+ # The following variables will be defined for your use:
7
+ # - ICU_FOUND : were all of your specified components found?
8
+ # - ICU_INCLUDE_DIRS : ICU include directory
9
+ # - ICU_LIBRARIES : ICU libraries
10
+ # - ICU_VERSION : complete version of ICU (x.y.z)
11
+ # - ICU_VERSION_MAJOR : major version of ICU
12
+ # - ICU_VERSION_MINOR : minor version of ICU
13
+ # - ICU_VERSION_PATCH : patch version of ICU
14
+ # - ICU_<COMPONENT>_FOUND : were <COMPONENT> found? (FALSE for non specified component if it is not a dependency)
15
+ #
16
+ # For windows or non standard installation, define ICU_ROOT_DIR variable to point to the root installation of ICU. Two ways:
17
+ # - run cmake with -DICU_ROOT_DIR=<PATH>
18
+ # - define an environment variable with the same name before running cmake
19
+ # With cmake-gui, before pressing "Configure":
20
+ # 1) Press "Add Entry" button
21
+ # 2) Add a new entry defined as:
22
+ # - Name: ICU_ROOT_DIR
23
+ # - Type: choose PATH in the selection list
24
+ # - Press "..." button and select the root installation of ICU
25
+ #
26
+ # Example Usage:
27
+ #
28
+ # 1. Copy this file in the root of your project source directory
29
+ # 2. Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt:
30
+ # set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
31
+ # 3. Finally call find_package() once, here are some examples to pick from
32
+ #
33
+ # Require ICU 4.4 or later
34
+ # find_package(ICU 4.4 REQUIRED)
35
+ #
36
+ # if(ICU_FOUND)
37
+ # add_executable(myapp myapp.c)
38
+ # include_directories(${ICU_INCLUDE_DIRS})
39
+ # target_link_libraries(myapp ${ICU_LIBRARIES})
40
+ # # with CMake >= 3.0.0, the last two lines can be replaced by the following
41
+ # target_link_libraries(myapp ICU::ICU)
42
+ # endif(ICU_FOUND)
43
+
44
+ ########## <ICU finding> ##########
45
+
46
+ find_package(PkgConfig QUIET)
47
+
48
+ ########## Private ##########
49
+ if(NOT DEFINED ICU_PUBLIC_VAR_NS)
50
+ set(ICU_PUBLIC_VAR_NS "ICU") # Prefix for all ICU relative public variables
51
+ endif(NOT DEFINED ICU_PUBLIC_VAR_NS)
52
+ if(NOT DEFINED ICU_PRIVATE_VAR_NS)
53
+ set(ICU_PRIVATE_VAR_NS "_${ICU_PUBLIC_VAR_NS}") # Prefix for all ICU relative internal variables
54
+ endif(NOT DEFINED ICU_PRIVATE_VAR_NS)
55
+ if(NOT DEFINED PC_ICU_PRIVATE_VAR_NS)
56
+ set(PC_ICU_PRIVATE_VAR_NS "_PC${ICU_PRIVATE_VAR_NS}") # Prefix for all pkg-config relative internal variables
57
+ endif(NOT DEFINED PC_ICU_PRIVATE_VAR_NS)
58
+
59
+ set(${ICU_PRIVATE_VAR_NS}_HINTS )
60
+ # <deprecated>
61
+ # for future removal
62
+ if(DEFINED ENV{ICU_ROOT})
63
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_HINTS "$ENV{ICU_ROOT}")
64
+ message(AUTHOR_WARNING "ENV{ICU_ROOT} is deprecated in favor of ENV{ICU_ROOT_DIR}")
65
+ endif(DEFINED ENV{ICU_ROOT})
66
+ if (DEFINED ICU_ROOT)
67
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_HINTS "${ICU_ROOT}")
68
+ message(AUTHOR_WARNING "ICU_ROOT is deprecated in favor of ICU_ROOT_DIR")
69
+ endif(DEFINED ICU_ROOT)
70
+ # </deprecated>
71
+ if(DEFINED ENV{ICU_ROOT_DIR})
72
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_HINTS "$ENV{ICU_ROOT_DIR}")
73
+ endif(DEFINED ENV{ICU_ROOT_DIR})
74
+ if (DEFINED ICU_ROOT_DIR)
75
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_HINTS "${ICU_ROOT_DIR}")
76
+ endif(DEFINED ICU_ROOT_DIR)
77
+
78
+ set(${ICU_PRIVATE_VAR_NS}_COMPONENTS )
79
+ # <icu component name> <library name 1> ... <library name N>
80
+ macro(_icu_declare_component _NAME)
81
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_COMPONENTS ${_NAME})
82
+ set("${ICU_PRIVATE_VAR_NS}_COMPONENTS_${_NAME}" ${ARGN})
83
+ endmacro(_icu_declare_component)
84
+
85
+ _icu_declare_component(data icudata)
86
+ _icu_declare_component(uc icuuc) # Common and Data libraries
87
+ _icu_declare_component(i18n icui18n icuin) # Internationalization library
88
+ _icu_declare_component(io icuio ustdio) # Stream and I/O Library
89
+ _icu_declare_component(le icule) # Layout library
90
+ _icu_declare_component(lx iculx) # Paragraph Layout library
91
+
92
+ ########## Public ##########
93
+ set(${ICU_PUBLIC_VAR_NS}_FOUND FALSE)
94
+ set(${ICU_PUBLIC_VAR_NS}_LIBRARIES )
95
+ set(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS )
96
+ set(${ICU_PUBLIC_VAR_NS}_C_FLAGS "")
97
+ set(${ICU_PUBLIC_VAR_NS}_CXX_FLAGS "")
98
+ set(${ICU_PUBLIC_VAR_NS}_CPP_FLAGS "")
99
+ set(${ICU_PUBLIC_VAR_NS}_C_SHARED_FLAGS "")
100
+ set(${ICU_PUBLIC_VAR_NS}_CXX_SHARED_FLAGS "")
101
+ set(${ICU_PUBLIC_VAR_NS}_CPP_SHARED_FLAGS "")
102
+
103
+ foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS})
104
+ string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
105
+ set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" FALSE) # may be done in the _icu_declare_component macro
106
+ endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
107
+
108
+ # Check components
109
+ if(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS) # uc required at least
110
+ set(${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc)
111
+ else(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
112
+ list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS uc)
113
+ list(REMOVE_DUPLICATES ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
114
+ foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
115
+ if(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
116
+ message(FATAL_ERROR "Unknown ICU component: ${${ICU_PRIVATE_VAR_NS}_COMPONENT}")
117
+ endif(NOT DEFINED ${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT})
118
+ endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
119
+ endif(NOT ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS)
120
+
121
+ # if pkg-config is available check components dependencies and append `pkg-config icu-<component> --variable=prefix` to hints
122
+ if(PKG_CONFIG_FOUND)
123
+ set(${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
124
+ foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_DUP})
125
+ pkg_check_modules(${PC_ICU_PRIVATE_VAR_NS} "icu-${${ICU_PRIVATE_VAR_NS}_COMPONENT}" QUIET)
126
+
127
+ if(${PC_ICU_PRIVATE_VAR_NS}_FOUND)
128
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_HINTS ${${PC_ICU_PRIVATE_VAR_NS}_PREFIX})
129
+ foreach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY ${${PC_ICU_PRIVATE_VAR_NS}_LIBRARIES})
130
+ string(REGEX REPLACE "^icu" "" ${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY ${${PC_ICU_PRIVATE_VAR_NS}_LIBRARY})
131
+ if(NOT ${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY STREQUAL "data")
132
+ list(FIND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS ${${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY} ${ICU_PRIVATE_VAR_NS}_COMPONENT_INDEX)
133
+ if(${ICU_PRIVATE_VAR_NS}_COMPONENT_INDEX EQUAL -1)
134
+ message(WARNING "Missing component dependency: ${${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY}. Add it to your find_package(ICU) line as COMPONENTS to fix this warning.")
135
+ list(APPEND ${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS ${${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY})
136
+ endif(${ICU_PRIVATE_VAR_NS}_COMPONENT_INDEX EQUAL -1)
137
+ endif(NOT ${PC_ICU_PRIVATE_VAR_NS}_STRIPPED_LIBRARY STREQUAL "data")
138
+ endforeach(${PC_ICU_PRIVATE_VAR_NS}_LIBRARY)
139
+ endif(${PC_ICU_PRIVATE_VAR_NS}_FOUND)
140
+ endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
141
+ endif(PKG_CONFIG_FOUND)
142
+ # list(APPEND ${ICU_PRIVATE_VAR_NS}_HINTS ENV ICU_ROOT_DIR)
143
+ # message("${ICU_PRIVATE_VAR_NS}_HINTS = ${${ICU_PRIVATE_VAR_NS}_HINTS}")
144
+
145
+ # Includes
146
+ find_path(
147
+ ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR
148
+ NAMES unicode/utypes.h utypes.h
149
+ HINTS ${${ICU_PRIVATE_VAR_NS}_HINTS}
150
+ PATH_SUFFIXES "include"
151
+ DOC "Include directories for ICU"
152
+ )
153
+
154
+ if(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR)
155
+ ########## <part to keep synced with tests/version/CMakeLists.txt> ##########
156
+ if(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/unicode/uvernum.h") # ICU >= 4.4
157
+ file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/unicode/uvernum.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
158
+ elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/unicode/uversion.h") # ICU [2;4.4[
159
+ file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/unicode/uversion.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
160
+ elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/unicode/utypes.h") # ICU [1.4;2[
161
+ file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/unicode/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
162
+ elseif(EXISTS "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/utypes.h") # ICU 1.3
163
+ file(READ "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}/utypes.h" ${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS)
164
+ else()
165
+ message(FATAL_ERROR "ICU version header not found")
166
+ endif()
167
+
168
+ if(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *ICU_VERSION *\"([0-9]+)\".*") # ICU 1.3
169
+ # [1.3;1.4[ as #define ICU_VERSION "3" (no patch version, ie all 1.3.X versions will be detected as 1.3.0)
170
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR "1")
171
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_MINOR "${CMAKE_MATCH_1}")
172
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_PATCH "0")
173
+ elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION_MAJOR_NUM *([0-9]+).*")
174
+ #
175
+ # Since version 4.9.1, ICU release version numbering was totaly changed, see:
176
+ # - http://site.icu-project.org/download/49
177
+ # - http://userguide.icu-project.org/design#TOC-Version-Numbers-in-ICU
178
+ #
179
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR "${CMAKE_MATCH_1}")
180
+ string(REGEX REPLACE ".*# *define *U_ICU_VERSION_MINOR_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_VERSION_MINOR "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}")
181
+ string(REGEX REPLACE ".*# *define *U_ICU_VERSION_PATCHLEVEL_NUM *([0-9]+).*" "\\1" ${ICU_PUBLIC_VAR_NS}_VERSION_PATCH "${${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS}")
182
+ elseif(${ICU_PRIVATE_VAR_NS}_VERSION_HEADER_CONTENTS MATCHES ".*# *define *U_ICU_VERSION *\"(([0-9]+)(\\.[0-9]+)*)\".*") # ICU [1.4;1.8[
183
+ # [1.4;1.8[ as #define U_ICU_VERSION "1.4.1.2" but it seems that some 1.4.[12](?:\.\d)? have releasing error and appears as 1.4.0
184
+ set(${ICU_PRIVATE_VAR_NS}_FULL_VERSION "${CMAKE_MATCH_1}") # copy CMAKE_MATCH_1, no longer valid on the following if
185
+ if(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)$")
186
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR "${CMAKE_MATCH_1}")
187
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_MINOR "${CMAKE_MATCH_2}")
188
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_PATCH "0")
189
+ elseif(${ICU_PRIVATE_VAR_NS}_FULL_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
190
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR "${CMAKE_MATCH_1}")
191
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_MINOR "${CMAKE_MATCH_2}")
192
+ set(${ICU_PUBLIC_VAR_NS}_VERSION_PATCH "${CMAKE_MATCH_3}")
193
+ endif()
194
+ else()
195
+ message(FATAL_ERROR "failed to detect ICU version")
196
+ endif()
197
+ set(${ICU_PUBLIC_VAR_NS}_VERSION "${${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR}.${${ICU_PUBLIC_VAR_NS}_VERSION_MINOR}.${${ICU_PUBLIC_VAR_NS}_VERSION_PATCH}")
198
+ ########## </part to keep synced with tests/version/CMakeLists.txt> ##########
199
+ endif(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR)
200
+
201
+ # Check libraries
202
+ if(MSVC)
203
+ include(SelectLibraryConfigurations)
204
+ endif(MSVC)
205
+ foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
206
+ string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
207
+ if(MSVC)
208
+ set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES )
209
+ set(${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES )
210
+ foreach(${ICU_PRIVATE_VAR_NS}_BASE_NAME ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT}})
211
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}")
212
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}d")
213
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR}${${ICU_PUBLIC_VAR_NS}_VERSION_MINOR}")
214
+ list(APPEND ${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES "${${ICU_PRIVATE_VAR_NS}_BASE_NAME}${${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR}${${ICU_PUBLIC_VAR_NS}_VERSION_MINOR}d")
215
+ endforeach(${ICU_PRIVATE_VAR_NS}_BASE_NAME)
216
+
217
+ find_library(
218
+ ${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_RELEASE
219
+ NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_RELEASE_NAMES}
220
+ HINTS ${${ICU_PRIVATE_VAR_NS}_HINTS}
221
+ DOC "Release library for ICU ${${ICU_PRIVATE_VAR_NS}_COMPONENT} component"
222
+ )
223
+ find_library(
224
+ ${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_DEBUG
225
+ NAMES ${${ICU_PRIVATE_VAR_NS}_POSSIBLE_DEBUG_NAMES}
226
+ HINTS ${${ICU_PRIVATE_VAR_NS}_HINTS}
227
+ DOC "Debug library for ICU ${${ICU_PRIVATE_VAR_NS}_COMPONENT} component"
228
+ )
229
+
230
+ select_library_configurations("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}")
231
+ list(APPEND ${ICU_PUBLIC_VAR_NS}_LIBRARY ${${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY})
232
+ else(MSVC)
233
+ find_library(
234
+ ${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY
235
+ NAMES ${${ICU_PRIVATE_VAR_NS}_COMPONENTS_${${ICU_PRIVATE_VAR_NS}_COMPONENT}}
236
+ PATHS ${${ICU_PRIVATE_VAR_NS}_HINTS}
237
+ DOC "Library for ICU ${${ICU_PRIVATE_VAR_NS}_COMPONENT} component"
238
+ )
239
+
240
+ if(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY)
241
+ set("${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_FOUND" TRUE)
242
+ list(APPEND ${ICU_PUBLIC_VAR_NS}_LIBRARY ${${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY})
243
+ endif(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY)
244
+ endif(MSVC)
245
+ endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
246
+
247
+ # Try to find out compiler flags
248
+ find_program(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE icu-config HINTS ${${ICU_PRIVATE_VAR_NS}_HINTS})
249
+ if(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE)
250
+ execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_C_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
251
+ execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cxxflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CXX_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
252
+ execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cppflags OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CPP_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
253
+
254
+ execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_C_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
255
+ execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cxxflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CXX_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
256
+ execute_process(COMMAND ${${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE} --cppflags-dynamic OUTPUT_VARIABLE ${ICU_PUBLIC_VAR_NS}_CPP_SHARED_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
257
+ endif(${ICU_PUBLIC_VAR_NS}_CONFIG_EXECUTABLE)
258
+
259
+ # Check find_package arguments
260
+ include(FindPackageHandleStandardArgs)
261
+ if(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
262
+ find_package_handle_standard_args(
263
+ ${ICU_PUBLIC_VAR_NS}
264
+ REQUIRED_VARS ${ICU_PUBLIC_VAR_NS}_LIBRARY ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR
265
+ VERSION_VAR ${ICU_PUBLIC_VAR_NS}_VERSION
266
+ )
267
+ else(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
268
+ find_package_handle_standard_args(${ICU_PUBLIC_VAR_NS} "Could NOT find ICU" ${ICU_PUBLIC_VAR_NS}_LIBRARY ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR)
269
+ endif(${ICU_PUBLIC_VAR_NS}_FIND_REQUIRED AND NOT ${ICU_PUBLIC_VAR_NS}_FIND_QUIETLY)
270
+
271
+ if(${ICU_PUBLIC_VAR_NS}_FOUND)
272
+ # <deprecated>
273
+ # for compatibility with previous versions, alias old ICU_(MAJOR|MINOR|PATCH)_VERSION to ICU_VERSION_$1
274
+ set(${ICU_PUBLIC_VAR_NS}_MAJOR_VERSION ${${ICU_PUBLIC_VAR_NS}_VERSION_MAJOR})
275
+ set(${ICU_PUBLIC_VAR_NS}_MINOR_VERSION ${${ICU_PUBLIC_VAR_NS}_VERSION_MINOR})
276
+ set(${ICU_PUBLIC_VAR_NS}_PATCH_VERSION ${${ICU_PUBLIC_VAR_NS}_VERSION_PATCH})
277
+ # </deprecated>
278
+ set(${ICU_PUBLIC_VAR_NS}_LIBRARIES ${${ICU_PUBLIC_VAR_NS}_LIBRARY})
279
+ set(${ICU_PUBLIC_VAR_NS}_INCLUDE_DIRS ${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR})
280
+
281
+ if(NOT CMAKE_VERSION VERSION_LESS "3.0.0")
282
+ if(NOT TARGET ICU::ICU)
283
+ add_library(ICU::ICU INTERFACE IMPORTED)
284
+ endif(NOT TARGET ICU::ICU)
285
+ set_target_properties(ICU::ICU PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}")
286
+ foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PUBLIC_VAR_NS}_FIND_COMPONENTS})
287
+ string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
288
+ add_library("ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}" UNKNOWN IMPORTED)
289
+ if(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_RELEASE)
290
+ set_property(TARGET "ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}" APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
291
+ set_target_properties("ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}" PROPERTIES IMPORTED_LOCATION_RELEASE "${${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_RELEASE}")
292
+ endif(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_RELEASE)
293
+ if(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_DEBUG)
294
+ set_property(TARGET "ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}" APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
295
+ set_target_properties("ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}" PROPERTIES IMPORTED_LOCATION_DEBUG "${${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_DEBUG}")
296
+ endif(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY_DEBUG)
297
+ if(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY)
298
+ set_target_properties("ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}" PROPERTIES IMPORTED_LOCATION "${${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY}")
299
+ endif(${ICU_PUBLIC_VAR_NS}_${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_LIBRARY)
300
+ set_property(TARGET ICU::ICU APPEND PROPERTY INTERFACE_LINK_LIBRARIES "ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}")
301
+ # set_target_properties("ICU::${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR}")
302
+ endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
303
+ endif(NOT CMAKE_VERSION VERSION_LESS "3.0.0")
304
+ endif(${ICU_PUBLIC_VAR_NS}_FOUND)
305
+
306
+ mark_as_advanced(
307
+ ${ICU_PUBLIC_VAR_NS}_INCLUDE_DIR
308
+ ${ICU_PUBLIC_VAR_NS}_LIBRARY
309
+ )
310
+
311
+ ########## </ICU finding> ##########
312
+
313
+ ########## <resource bundle support> ##########
314
+
315
+ ########## Private ##########
316
+ function(_icu_extract_locale_from_rb _BUNDLE_SOURCE _RETURN_VAR_NAME)
317
+ file(READ "${_BUNDLE_SOURCE}" _BUNDLE_CONTENTS)
318
+ string(REGEX REPLACE "//[^\n]*\n" "" _BUNDLE_CONTENTS_WITHOUT_COMMENTS ${_BUNDLE_CONTENTS})
319
+ string(REGEX REPLACE "[ \t\n]" "" _BUNDLE_CONTENTS_WITHOUT_COMMENTS_AND_SPACES ${_BUNDLE_CONTENTS_WITHOUT_COMMENTS})
320
+ string(REGEX MATCH "^([a-zA-Z_-]+)(:table)?{" LOCALE_FOUND ${_BUNDLE_CONTENTS_WITHOUT_COMMENTS_AND_SPACES})
321
+ set("${_RETURN_VAR_NAME}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
322
+ endfunction(_icu_extract_locale_from_rb)
323
+
324
+ ########## Public ##########
325
+
326
+ #
327
+ # Prototype:
328
+ # icu_generate_resource_bundle([NAME <name>] [PACKAGE] [DESTINATION <location>] [FILES <list of files>])
329
+ #
330
+ # Common arguments:
331
+ # - NAME <name> : name of output package and to create dummy targets
332
+ # - FILES <file 1> ... <file N> : list of resource bundles sources
333
+ # - DEPENDS <target1> ... <target N> : required to package as library (shared or static), a list of cmake parent targets to link to
334
+ # Note: only (PREVIOUSLY DECLARED) add_executable and add_library as dependencies
335
+ # - DESTINATION <location> : optional, directory where to install final binary file(s)
336
+ # - FORMAT <name> : optional, one of none (ICU4C binary format, default), java (plain java) or xliff (XML), see below
337
+ #
338
+ # Arguments depending on FORMAT:
339
+ # - none (default):
340
+ # * PACKAGE : if present, package all resource bundles together. Default is to stop after building individual *.res files
341
+ # * TYPE <name> : one of :
342
+ # + common or archive (default) : archive all ressource bundles into a single .dat file
343
+ # + library or dll : assemble all ressource bundles into a separate and loadable library (.dll/.so)
344
+ # + static : integrate all ressource bundles to targets designed by DEPENDS parameter (as a static library)
345
+ # * NO_SHARED_FLAGS : only with TYPE in ['library', 'dll', 'static'], do not append ICU_C(XX)_SHARED_FLAGS to targets given as DEPENDS argument
346
+ # - JAVA:
347
+ # * BUNDLE <name> : required, prefix for generated classnames
348
+ # - XLIFF:
349
+ # (none)
350
+ #
351
+
352
+ #
353
+ # For an archive, the idea is to generate the following dependencies:
354
+ #
355
+ # root.txt => root.res \
356
+ # |
357
+ # en.txt => en.res |
358
+ # | => pkglist.txt => application.dat
359
+ # fr.txt => fr.res |
360
+ # |
361
+ # and so on /
362
+ #
363
+ # Lengend: 'A => B' means B depends on A
364
+ #
365
+ # Steps (correspond to arrows):
366
+ # 1) genrb (from .txt to .res)
367
+ # 2) generate a file text (pkglist.txt) with all .res files to put together
368
+ # 3) build final archive (from *.res/pkglist.txt to .dat)
369
+ #
370
+
371
+ function(icu_generate_resource_bundle)
372
+
373
+ ##### <check for pkgdata/genrb availability> #####
374
+ find_program(${ICU_PUBLIC_VAR_NS}_GENRB_EXECUTABLE genrb HINTS ${${ICU_PRIVATE_VAR_NS}_HINTS})
375
+ find_program(${ICU_PUBLIC_VAR_NS}_PKGDATA_EXECUTABLE pkgdata HINTS ${${ICU_PRIVATE_VAR_NS}_HINTS})
376
+
377
+ if(NOT ${ICU_PUBLIC_VAR_NS}_GENRB_EXECUTABLE)
378
+ message(FATAL_ERROR "genrb not found")
379
+ endif(NOT ${ICU_PUBLIC_VAR_NS}_GENRB_EXECUTABLE)
380
+ if(NOT ${ICU_PUBLIC_VAR_NS}_PKGDATA_EXECUTABLE)
381
+ message(FATAL_ERROR "pkgdata not found")
382
+ endif(NOT ${ICU_PUBLIC_VAR_NS}_PKGDATA_EXECUTABLE)
383
+ ##### </check for pkgdata/genrb availability> #####
384
+
385
+ ##### <constants> #####
386
+ set(TARGET_SEPARATOR "+")
387
+ set(__FUNCTION__ "icu_generate_resource_bundle")
388
+ set(PACKAGE_TARGET_PREFIX "ICU${TARGET_SEPARATOR}PKG")
389
+ set(RESOURCE_TARGET_PREFIX "ICU${TARGET_SEPARATOR}RB")
390
+ ##### </constants> #####
391
+
392
+ ##### <hash constants> #####
393
+ # filename extension of built resource bundle (without dot)
394
+ set(BUNDLES__SUFFIX "res")
395
+ set(BUNDLES_JAVA_SUFFIX "java")
396
+ set(BUNDLES_XLIFF_SUFFIX "xlf")
397
+ # alias: none (default) = common = archive ; dll = library ; static
398
+ set(PKGDATA__ALIAS "")
399
+ set(PKGDATA_COMMON_ALIAS "")
400
+ set(PKGDATA_ARCHIVE_ALIAS "")
401
+ set(PKGDATA_DLL_ALIAS "LIBRARY")
402
+ set(PKGDATA_LIBRARY_ALIAS "LIBRARY")
403
+ set(PKGDATA_STATIC_ALIAS "STATIC")
404
+ # filename prefix of built package
405
+ set(PKGDATA__PREFIX "")
406
+ set(PKGDATA_LIBRARY_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}")
407
+ set(PKGDATA_STATIC_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
408
+ # filename extension of built package (with dot)
409
+ set(PKGDATA__SUFFIX ".dat")
410
+ set(PKGDATA_LIBRARY_SUFFIX "${CMAKE_SHARED_LIBRARY_SUFFIX}")
411
+ set(PKGDATA_STATIC_SUFFIX "${CMAKE_STATIC_LIBRARY_SUFFIX}")
412
+ # pkgdata option mode specific
413
+ set(PKGDATA__OPTIONS "-m" "common")
414
+ set(PKGDATA_STATIC_OPTIONS "-m" "static")
415
+ set(PKGDATA_LIBRARY_OPTIONS "-m" "library")
416
+ # cmake library type for output package
417
+ set(PKGDATA_LIBRARY__TYPE "")
418
+ set(PKGDATA_LIBRARY_STATIC_TYPE STATIC)
419
+ set(PKGDATA_LIBRARY_LIBRARY_TYPE SHARED)
420
+ ##### </hash constants> #####
421
+
422
+ include(CMakeParseArguments)
423
+ cmake_parse_arguments(
424
+ PARSED_ARGS # output variable name
425
+ # options (true/false) (default value: false)
426
+ "PACKAGE;NO_SHARED_FLAGS"
427
+ # univalued parameters (default value: "")
428
+ "NAME;DESTINATION;TYPE;FORMAT;BUNDLE"
429
+ # multivalued parameters (default value: "")
430
+ "FILES;DEPENDS"
431
+ ${ARGN}
432
+ )
433
+
434
+ # assert(${PARSED_ARGS_NAME} != "")
435
+ if(NOT PARSED_ARGS_NAME)
436
+ message(FATAL_ERROR "${__FUNCTION__}(): no name given, NAME parameter missing")
437
+ endif(NOT PARSED_ARGS_NAME)
438
+
439
+ # assert(length(PARSED_ARGS_FILES) > 0)
440
+ list(LENGTH PARSED_ARGS_FILES PARSED_ARGS_FILES_LEN)
441
+ if(PARSED_ARGS_FILES_LEN LESS 1)
442
+ message(FATAL_ERROR "${__FUNCTION__}() expects at least 1 resource bundle as FILES argument, 0 given")
443
+ endif(PARSED_ARGS_FILES_LEN LESS 1)
444
+
445
+ string(TOUPPER "${PARSED_ARGS_FORMAT}" UPPER_FORMAT)
446
+ # assert(${UPPER_FORMAT} in ['', 'java', 'xlif'])
447
+ if(NOT DEFINED BUNDLES_${UPPER_FORMAT}_SUFFIX)
448
+ message(FATAL_ERROR "${__FUNCTION__}(): unknown FORMAT '${PARSED_ARGS_FORMAT}'")
449
+ endif(NOT DEFINED BUNDLES_${UPPER_FORMAT}_SUFFIX)
450
+
451
+ if(UPPER_FORMAT STREQUAL "JAVA")
452
+ # assert(${PARSED_ARGS_BUNDLE} != "")
453
+ if(NOT PARSED_ARGS_BUNDLE)
454
+ message(FATAL_ERROR "${__FUNCTION__}(): java bundle name expected, BUNDLE parameter missing")
455
+ endif(NOT PARSED_ARGS_BUNDLE)
456
+ endif(UPPER_FORMAT STREQUAL "JAVA")
457
+
458
+ if(PARSED_ARGS_PACKAGE)
459
+ # assert(${PARSED_ARGS_FORMAT} == "")
460
+ if(PARSED_ARGS_FORMAT)
461
+ message(FATAL_ERROR "${__FUNCTION__}(): packaging is only supported for binary format, not xlif neither java outputs")
462
+ endif(PARSED_ARGS_FORMAT)
463
+
464
+ string(TOUPPER "${PARSED_ARGS_TYPE}" UPPER_MODE)
465
+ # assert(${UPPER_MODE} in ['', 'common', 'archive', 'dll', library'])
466
+ if(NOT DEFINED PKGDATA_${UPPER_MODE}_ALIAS)
467
+ message(FATAL_ERROR "${__FUNCTION__}(): unknown TYPE '${PARSED_ARGS_TYPE}'")
468
+ else(NOT DEFINED PKGDATA_${UPPER_MODE}_ALIAS)
469
+ set(TYPE "${PKGDATA_${UPPER_MODE}_ALIAS}")
470
+ endif(NOT DEFINED PKGDATA_${UPPER_MODE}_ALIAS)
471
+
472
+ # Package name: strip file extension if present
473
+ get_filename_component(PACKAGE_NAME_WE ${PARSED_ARGS_NAME} NAME_WE)
474
+ # Target name to build package
475
+ set(PACKAGE_TARGET_NAME "${PACKAGE_TARGET_PREFIX}${TARGET_SEPARATOR}${PACKAGE_NAME_WE}")
476
+ # Target name to build intermediate list file
477
+ set(PACKAGE_LIST_TARGET_NAME "${PACKAGE_TARGET_NAME}${TARGET_SEPARATOR}PKGLIST")
478
+ # Directory (absolute) to set as "current directory" for genrb (does not include package directory, -p)
479
+ # We make our "cook" there to prevent any conflict
480
+ if(DEFINED CMAKE_PLATFORM_ROOT_BIN) # CMake < 2.8.10
481
+ set(RESOURCE_GENRB_CHDIR_DIR "${CMAKE_PLATFORM_ROOT_BIN}/${PACKAGE_TARGET_NAME}.dir/")
482
+ else(DEFINED CMAKE_PLATFORM_ROOT_BIN) # CMake >= 2.8.10
483
+ set(RESOURCE_GENRB_CHDIR_DIR "${CMAKE_PLATFORM_INFO_DIR}/${PACKAGE_TARGET_NAME}.dir/")
484
+ endif(DEFINED CMAKE_PLATFORM_ROOT_BIN)
485
+ # Directory (absolute) where resource bundles are built: concatenation of RESOURCE_GENRB_CHDIR_DIR and package name
486
+ set(RESOURCE_OUTPUT_DIR "${RESOURCE_GENRB_CHDIR_DIR}/${PACKAGE_NAME_WE}/")
487
+ # Output (relative) path for built package
488
+ if(MSVC AND TYPE STREQUAL PKGDATA_LIBRARY_ALIAS)
489
+ set(PACKAGE_OUTPUT_PATH "${RESOURCE_GENRB_CHDIR_DIR}/${PACKAGE_NAME_WE}/${PKGDATA_${TYPE}_PREFIX}${PACKAGE_NAME_WE}${PKGDATA_${TYPE}_SUFFIX}")
490
+ else(MSVC AND TYPE STREQUAL PKGDATA_LIBRARY_ALIAS)
491
+ set(PACKAGE_OUTPUT_PATH "${RESOURCE_GENRB_CHDIR_DIR}/${PKGDATA_${TYPE}_PREFIX}${PACKAGE_NAME_WE}${PKGDATA_${TYPE}_SUFFIX}")
492
+ endif(MSVC AND TYPE STREQUAL PKGDATA_LIBRARY_ALIAS)
493
+ # Output (absolute) path for the list file
494
+ set(PACKAGE_LIST_OUTPUT_PATH "${RESOURCE_GENRB_CHDIR_DIR}/pkglist.txt")
495
+
496
+ file(MAKE_DIRECTORY "${RESOURCE_OUTPUT_DIR}")
497
+ else(PARSED_ARGS_PACKAGE)
498
+ set(RESOURCE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/")
499
+ # set(RESOURCE_GENRB_CHDIR_DIR "UNUSED")
500
+ endif(PARSED_ARGS_PACKAGE)
501
+
502
+ set(TARGET_RESOURCES )
503
+ set(COMPILED_RESOURCES_PATH )
504
+ set(COMPILED_RESOURCES_BASENAME )
505
+ foreach(RESOURCE_SOURCE ${PARSED_ARGS_FILES})
506
+ _icu_extract_locale_from_rb(${RESOURCE_SOURCE} RESOURCE_NAME_WE)
507
+ get_filename_component(SOURCE_BASENAME ${RESOURCE_SOURCE} NAME)
508
+ get_filename_component(ABSOLUTE_SOURCE ${RESOURCE_SOURCE} ABSOLUTE)
509
+
510
+ if(UPPER_FORMAT STREQUAL "XLIFF")
511
+ if(RESOURCE_NAME_WE STREQUAL "root")
512
+ set(XLIFF_LANGUAGE "en")
513
+ else(RESOURCE_NAME_WE STREQUAL "root")
514
+ string(REGEX REPLACE "[^a-z].*$" "" XLIFF_LANGUAGE "${RESOURCE_NAME_WE}")
515
+ endif(RESOURCE_NAME_WE STREQUAL "root")
516
+ endif(UPPER_FORMAT STREQUAL "XLIFF")
517
+
518
+ ##### <templates> #####
519
+ set(RESOURCE_TARGET_NAME "${RESOURCE_TARGET_PREFIX}${TARGET_SEPARATOR}${PARSED_ARGS_NAME}${TARGET_SEPARATOR}${RESOURCE_NAME_WE}")
520
+
521
+ set(RESOURCE_OUTPUT__PATH "${RESOURCE_NAME_WE}.res")
522
+ if(RESOURCE_NAME_WE STREQUAL "root")
523
+ set(RESOURCE_OUTPUT_JAVA_PATH "${PARSED_ARGS_BUNDLE}.java")
524
+ else(RESOURCE_NAME_WE STREQUAL "root")
525
+ set(RESOURCE_OUTPUT_JAVA_PATH "${PARSED_ARGS_BUNDLE}_${RESOURCE_NAME_WE}.java")
526
+ endif(RESOURCE_NAME_WE STREQUAL "root")
527
+ set(RESOURCE_OUTPUT_XLIFF_PATH "${RESOURCE_NAME_WE}.xlf")
528
+
529
+ set(GENRB__OPTIONS "")
530
+ set(GENRB_JAVA_OPTIONS "-j" "-b" "${PARSED_ARGS_BUNDLE}")
531
+ set(GENRB_XLIFF_OPTIONS "-x" "-l" "${XLIFF_LANGUAGE}")
532
+ ##### </templates> #####
533
+
534
+ # build <locale>.txt from <locale>.res
535
+ if(PARSED_ARGS_PACKAGE)
536
+ add_custom_command(
537
+ OUTPUT "${RESOURCE_OUTPUT_DIR}${RESOURCE_OUTPUT_${UPPER_FORMAT}_PATH}"
538
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RESOURCE_GENRB_CHDIR_DIR} ${${ICU_PUBLIC_VAR_NS}_GENRB_EXECUTABLE} ${GENRB_${UPPER_FORMAT}_OPTIONS} -d ${PACKAGE_NAME_WE} ${ABSOLUTE_SOURCE}
539
+ DEPENDS ${RESOURCE_SOURCE}
540
+ )
541
+ else(PARSED_ARGS_PACKAGE)
542
+ add_custom_command(
543
+ OUTPUT "${RESOURCE_OUTPUT_DIR}${RESOURCE_OUTPUT_${UPPER_FORMAT}_PATH}"
544
+ COMMAND ${${ICU_PUBLIC_VAR_NS}_GENRB_EXECUTABLE} ${GENRB_${UPPER_FORMAT}_OPTIONS} -d ${RESOURCE_OUTPUT_DIR} ${ABSOLUTE_SOURCE}
545
+ DEPENDS ${RESOURCE_SOURCE}
546
+ )
547
+ endif(PARSED_ARGS_PACKAGE)
548
+ # dummy target (ICU+RB+<name>+<locale>) for each locale to build the <locale>.res file from its <locale>.txt by the add_custom_command above
549
+ add_custom_target(
550
+ "${RESOURCE_TARGET_NAME}" ALL
551
+ COMMENT ""
552
+ DEPENDS "${RESOURCE_OUTPUT_DIR}${RESOURCE_OUTPUT_${UPPER_FORMAT}_PATH}"
553
+ SOURCES ${RESOURCE_SOURCE}
554
+ )
555
+
556
+ if(PARSED_ARGS_DESTINATION AND NOT PARSED_ARGS_PACKAGE)
557
+ install(FILES "${RESOURCE_OUTPUT_DIR}${RESOURCE_OUTPUT_${UPPER_FORMAT}_PATH}" DESTINATION ${PARSED_ARGS_DESTINATION} PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
558
+ endif(PARSED_ARGS_DESTINATION AND NOT PARSED_ARGS_PACKAGE)
559
+
560
+ list(APPEND TARGET_RESOURCES "${RESOURCE_TARGET_NAME}")
561
+ list(APPEND COMPILED_RESOURCES_PATH "${RESOURCE_OUTPUT_DIR}${RESOURCE_OUTPUT_${UPPER_FORMAT}_PATH}")
562
+ list(APPEND COMPILED_RESOURCES_BASENAME "${RESOURCE_NAME_WE}.${BUNDLES_${UPPER_FORMAT}_SUFFIX}")
563
+ endforeach(RESOURCE_SOURCE)
564
+ # convert semicolon separated list to a space separated list
565
+ # NOTE: if the pkglist.txt file starts (or ends?) with a whitespace, pkgdata add an undefined symbol (named <package>_) for it
566
+ string(REPLACE ";" " " COMPILED_RESOURCES_BASENAME "${COMPILED_RESOURCES_BASENAME}")
567
+
568
+ if(PARSED_ARGS_PACKAGE)
569
+ # create a text file (pkglist.txt) with the list of the *.res to package together
570
+ add_custom_command(
571
+ OUTPUT "${PACKAGE_LIST_OUTPUT_PATH}"
572
+ COMMAND ${CMAKE_COMMAND} -E echo "${COMPILED_RESOURCES_BASENAME}" > "${PACKAGE_LIST_OUTPUT_PATH}"
573
+ DEPENDS ${COMPILED_RESOURCES_PATH}
574
+ )
575
+ # run pkgdata from pkglist.txt
576
+ add_custom_command(
577
+ OUTPUT "${PACKAGE_OUTPUT_PATH}"
578
+ COMMAND ${CMAKE_COMMAND} -E chdir ${RESOURCE_GENRB_CHDIR_DIR} ${${ICU_PUBLIC_VAR_NS}_PKGDATA_EXECUTABLE} -F ${PKGDATA_${TYPE}_OPTIONS} -s ${PACKAGE_NAME_WE} -p ${PACKAGE_NAME_WE} ${PACKAGE_LIST_OUTPUT_PATH}
579
+ DEPENDS "${PACKAGE_LIST_OUTPUT_PATH}"
580
+ VERBATIM
581
+ )
582
+ if(PKGDATA_LIBRARY_${TYPE}_TYPE)
583
+ # assert(${PARSED_ARGS_DEPENDS} != "")
584
+ if(NOT PARSED_ARGS_DEPENDS)
585
+ message(FATAL_ERROR "${__FUNCTION__}(): static and library mode imply a list of targets to link to, DEPENDS parameter missing")
586
+ endif(NOT PARSED_ARGS_DEPENDS)
587
+ add_library(${PACKAGE_TARGET_NAME} ${PKGDATA_LIBRARY_${TYPE}_TYPE} IMPORTED)
588
+ if(MSVC)
589
+ string(REGEX REPLACE "${PKGDATA_LIBRARY_SUFFIX}\$" "${CMAKE_IMPORT_LIBRARY_SUFFIX}" PACKAGE_OUTPUT_LIB "${PACKAGE_OUTPUT_PATH}")
590
+ set_target_properties(${PACKAGE_TARGET_NAME} PROPERTIES IMPORTED_LOCATION ${PACKAGE_OUTPUT_PATH} IMPORTED_IMPLIB ${PACKAGE_OUTPUT_LIB})
591
+ else(MSVC)
592
+ set_target_properties(${PACKAGE_TARGET_NAME} PROPERTIES IMPORTED_LOCATION ${PACKAGE_OUTPUT_PATH})
593
+ endif(MSVC)
594
+ foreach(DEPENDENCY ${PARSED_ARGS_DEPENDS})
595
+ target_link_libraries(${DEPENDENCY} ${PACKAGE_TARGET_NAME})
596
+ if(NOT PARSED_ARGS_NO_SHARED_FLAGS)
597
+ get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
598
+ list(LENGTH "${ENABLED_LANGUAGES}" ENABLED_LANGUAGES_LENGTH)
599
+ if(ENABLED_LANGUAGES_LENGTH GREATER 1)
600
+ message(WARNING "Project has more than one language enabled, skip automatic shared flags appending")
601
+ else(ENABLED_LANGUAGES_LENGTH GREATER 1)
602
+ set_property(TARGET "${DEPENDENCY}" APPEND PROPERTY COMPILE_FLAGS "${${ICU_PUBLIC_VAR_NS}_${ENABLED_LANGUAGES}_SHARED_FLAGS}")
603
+ endif(ENABLED_LANGUAGES_LENGTH GREATER 1)
604
+ endif(NOT PARSED_ARGS_NO_SHARED_FLAGS)
605
+ endforeach(DEPENDENCY)
606
+ # http://www.mail-archive.com/cmake-commits@cmake.org/msg01135.html
607
+ set(PACKAGE_INTERMEDIATE_TARGET_NAME "${PACKAGE_TARGET_NAME}${TARGET_SEPARATOR}DUMMY")
608
+ # dummy intermediate target (ICU+PKG+<name>+DUMMY) to link the package to the produced library by running pkgdata (see add_custom_command above)
609
+ add_custom_target(
610
+ ${PACKAGE_INTERMEDIATE_TARGET_NAME}
611
+ COMMENT ""
612
+ DEPENDS "${PACKAGE_OUTPUT_PATH}"
613
+ )
614
+ add_dependencies("${PACKAGE_TARGET_NAME}" "${PACKAGE_INTERMEDIATE_TARGET_NAME}")
615
+ else(PKGDATA_LIBRARY_${TYPE}_TYPE)
616
+ # dummy target (ICU+PKG+<name>) to run pkgdata (see add_custom_command above)
617
+ add_custom_target(
618
+ "${PACKAGE_TARGET_NAME}" ALL
619
+ COMMENT ""
620
+ DEPENDS "${PACKAGE_OUTPUT_PATH}"
621
+ )
622
+ endif(PKGDATA_LIBRARY_${TYPE}_TYPE)
623
+ # dummy target (ICU+PKG+<name>+PKGLIST) to build the file pkglist.txt
624
+ add_custom_target(
625
+ "${PACKAGE_LIST_TARGET_NAME}" ALL
626
+ COMMENT ""
627
+ DEPENDS "${PACKAGE_LIST_OUTPUT_PATH}"
628
+ )
629
+ # package => pkglist.txt
630
+ add_dependencies("${PACKAGE_TARGET_NAME}" "${PACKAGE_LIST_TARGET_NAME}")
631
+ # pkglist.txt => *.res
632
+ add_dependencies("${PACKAGE_LIST_TARGET_NAME}" ${TARGET_RESOURCES})
633
+
634
+ if(PARSED_ARGS_DESTINATION)
635
+ install(FILES "${PACKAGE_OUTPUT_PATH}" DESTINATION ${PARSED_ARGS_DESTINATION} PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
636
+ endif(PARSED_ARGS_DESTINATION)
637
+ endif(PARSED_ARGS_PACKAGE)
638
+
639
+ endfunction(icu_generate_resource_bundle)
640
+
641
+ ########## </resource bundle support> ##########
642
+
643
+ ########## <debug> ##########
644
+
645
+ if(${ICU_PUBLIC_VAR_NS}_DEBUG)
646
+
647
+ function(icudebug _VARNAME)
648
+ if(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
649
+ message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = ${${ICU_PUBLIC_VAR_NS}_${_VARNAME}}")
650
+ else(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
651
+ message("${ICU_PUBLIC_VAR_NS}_${_VARNAME} = <UNDEFINED>")
652
+ endif(DEFINED ${ICU_PUBLIC_VAR_NS}_${_VARNAME})
653
+ endfunction(icudebug)
654
+
655
+ # IN (args)
656
+ icudebug("FIND_COMPONENTS")
657
+ icudebug("FIND_REQUIRED")
658
+ icudebug("FIND_QUIETLY")
659
+ icudebug("FIND_VERSION")
660
+
661
+ # OUT
662
+ # Found
663
+ icudebug("FOUND")
664
+ # Flags
665
+ icudebug("C_FLAGS")
666
+ icudebug("CPP_FLAGS")
667
+ icudebug("CXX_FLAGS")
668
+ icudebug("C_SHARED_FLAGS")
669
+ icudebug("CPP_SHARED_FLAGS")
670
+ icudebug("CXX_SHARED_FLAGS")
671
+ # Linking
672
+ icudebug("INCLUDE_DIRS")
673
+ icudebug("LIBRARIES")
674
+ # Version
675
+ icudebug("VERSION_MAJOR")
676
+ icudebug("VERSION_MINOR")
677
+ icudebug("VERSION_PATCH")
678
+ icudebug("VERSION")
679
+ # <COMPONENT>_(FOUND|LIBRARY)
680
+ set(${ICU_PRIVATE_VAR_NS}_COMPONENT_VARIABLES "FOUND" "LIBRARY" "LIBRARY_RELEASE" "LIBRARY_DEBUG")
681
+ foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT ${${ICU_PRIVATE_VAR_NS}_COMPONENTS})
682
+ string(TOUPPER "${${ICU_PRIVATE_VAR_NS}_COMPONENT}" ${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT)
683
+ foreach(${ICU_PRIVATE_VAR_NS}_COMPONENT_VARIABLE ${${ICU_PRIVATE_VAR_NS}_COMPONENT_VARIABLES})
684
+ icudebug("${${ICU_PRIVATE_VAR_NS}_UPPER_COMPONENT}_${${ICU_PRIVATE_VAR_NS}_COMPONENT_VARIABLE}")
685
+ endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT_VARIABLE)
686
+ endforeach(${ICU_PRIVATE_VAR_NS}_COMPONENT)
687
+
688
+ endif(${ICU_PUBLIC_VAR_NS}_DEBUG)
689
+
690
+ ########## </debug> ##########