@@ -24,10 +24,10 @@ platform-specific library name will be automatically selected.
2424This module reports information about the ICU installation in
2525several variables. General variables::
2626
27- ICU_VERSION - ICU release version
2827 ICU_FOUND - true if the main programs and libraries were found
29- ICU_LIBRARIES - component libraries to be linked
3028 ICU_INCLUDE_DIRS - the directories containing the ICU headers
29+ ICU_LIBRARIES - component libraries to be linked
30+ ICU_VERSION - ICU release version
3131
3232Imported targets::
3333
@@ -83,12 +83,10 @@ The following cache variables may also be set::
8383 In most cases none of the above variables will require setting,
8484 unless multiple ICU versions are available and a specific version
8585 is required.
86-
87- Other variables one may set to control this module are::
88-
89- ICU_DEBUG - Set to ON to enable debug output from FindICU.
9086#]=======================================================================]
9187
88+ cmake_policy (PUSH )
89+ cmake_policy (SET CMP0159 NEW ) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
9290# Written by Roger Leigh <rleigh@codelibre.net>
9391
9492set (icu_programs
@@ -136,6 +134,7 @@ function(_ICU_FIND)
136134 HINTS ${icu_roots}
137135 PATH_SUFFIXES ${icu_include_suffixes}
138136 DOC "ICU include directory" )
137+ mark_as_advanced (ICU_INCLUDE_DIR )
139138 set (ICU_INCLUDE_DIR "${ICU_INCLUDE_DIR} " PARENT_SCOPE )
140139
141140 # Get version
@@ -178,7 +177,6 @@ function(_ICU_FIND)
178177
179178 # Find all ICU libraries
180179 list (APPEND icu_library_suffixes "${_lib64} " "lib" )
181- set (ICU_REQUIRED_LIBS_FOUND ON )
182180 set (static_prefix )
183181 # static icu libraries compiled with MSVC have the prefix 's'
184182 if (MSVC )
@@ -189,8 +187,9 @@ function(_ICU_FIND)
189187 set (component_cache "ICU_${component_upcase} _LIBRARY" )
190188 set (component_cache_release "${component_cache} _RELEASE" )
191189 set (component_cache_debug "${component_cache} _DEBUG" )
192- set (component_found "ICU_${component_upcase } _FOUND" )
190+ set (component_found "ICU_${component } _FOUND" )
193191 set (component_found_compat "${component_upcase} _FOUND" )
192+ set (component_found_compat2 "ICU_${component_upcase} _FOUND" )
194193 set (component_libnames "icu${component} " )
195194 set (component_debug_libnames "icu${component} d" )
196195
@@ -253,27 +252,17 @@ function(_ICU_FIND)
253252 if (${component_cache} )
254253 set ("${component_found} " ON )
255254 set ("${component_found_compat} " ON )
255+ set ("${component_found_compat2} " ON )
256256 list (APPEND ICU_LIBRARY "${${component_cache} }" )
257- if (ICU_FIND_REQUIRED_${component} )
258- list (APPEND ICU_LIBS_FOUND "${component} (required): ${${component_cache} }" )
259- else ()
260- list (APPEND ICU_LIBS_FOUND "${component} (optional): ${${component_cache} }" )
261- endif ()
262- else ()
263- if (ICU_FIND_REQUIRED_${component} )
264- set (ICU_REQUIRED_LIBS_FOUND OFF )
265- list (APPEND ICU_LIBS_NOTFOUND "${component} (required)" )
266- else ()
267- list (APPEND ICU_LIBS_NOTFOUND "${component} (optional)" )
268- endif ()
269257 endif ()
270258 mark_as_advanced ("${component_found} " )
271259 mark_as_advanced ("${component_found_compat} " )
260+ mark_as_advanced ("${component_found_compat2} " )
272261 set ("${component_cache} " "${${component_cache} }" PARENT_SCOPE )
273262 set ("${component_found} " "${${component_found} }" PARENT_SCOPE )
274263 set ("${component_found_compat} " "${${component_found_compat} }" PARENT_SCOPE )
264+ set ("${component_found_compat2} " "${${component_found_compat2} }" PARENT_SCOPE )
275265 endforeach ()
276- set (_ICU_REQUIRED_LIBS_FOUND "${ICU_REQUIRED_LIBS_FOUND} " PARENT_SCOPE )
277266 set (ICU_LIBRARY "${ICU_LIBRARY} " PARENT_SCOPE )
278267
279268 # Find all ICU data files
@@ -302,43 +291,21 @@ function(_ICU_FIND)
302291 mark_as_advanced ("${cache_var} " )
303292 set ("${data_var} " "${${cache_var} }" PARENT_SCOPE )
304293 endforeach ()
305-
306- if (NOT ICU_FIND_QUIETLY)
307- if (ICU_LIBS_FOUND)
308- message (STATUS "Found the following ICU libraries:" )
309- foreach (found ${ICU_LIBS_FOUND} )
310- message (STATUS " ${found} " )
311- endforeach ()
312- endif ()
313- if (ICU_LIBS_NOTFOUND)
314- message (STATUS "The following ICU libraries were not found:" )
315- foreach (notfound ${ICU_LIBS_NOTFOUND} )
316- message (STATUS " ${notfound} " )
317- endforeach ()
318- endif ()
319- endif ()
320-
321- if (ICU_DEBUG)
322- message (STATUS "--------FindICU.cmake search debug--------" )
323- message (STATUS "ICU binary path search order: ${icu_roots} " )
324- message (STATUS "ICU include path search order: ${icu_roots} " )
325- message (STATUS "ICU library path search order: ${icu_roots} " )
326- message (STATUS "----------------" )
327- endif ()
328294endfunction ()
329295
330296_ICU_FIND ()
331297
332298include (${CMAKE_CURRENT_LIST_DIR} /FindPackageHandleStandardArgs.cmake )
333- FIND_PACKAGE_HANDLE_STANDARD_ARGS (ICU
334- FOUND_VAR ICU_FOUND
335- REQUIRED_VARS ICU_INCLUDE_DIR
336- ICU_LIBRARY
337- _ICU_REQUIRED_LIBS_FOUND
338- VERSION_VAR ICU_VERSION
339- FAIL_MESSAGE "Failed to find all ICU components" )
340-
341- unset (_ICU_REQUIRED_LIBS_FOUND)
299+ find_package_handle_standard_args (ICU
300+ REQUIRED_VARS
301+ ICU_INCLUDE_DIR
302+ ICU_LIBRARY
303+ VERSION_VAR
304+ ICU_VERSION
305+ HANDLE_COMPONENTS
306+ FAIL_MESSAGE
307+ "Failed to find all ICU components"
308+ )
342309
343310if (ICU_FOUND)
344311 set (ICU_INCLUDE_DIRS "${ICU_INCLUDE_DIR} " )
@@ -392,45 +359,5 @@ if(ICU_FOUND)
392359 endforeach ()
393360endif ()
394361
395- if (ICU_DEBUG)
396- message (STATUS "--------FindICU.cmake results debug--------" )
397- message (STATUS "ICU found: ${ICU_FOUND} " )
398- message (STATUS "ICU_VERSION number: ${ICU_VERSION} " )
399- message (STATUS "ICU_ROOT directory: ${ICU_ROOT} " )
400- message (STATUS "ICU_INCLUDE_DIR directory: ${ICU_INCLUDE_DIR} " )
401- message (STATUS "ICU_LIBRARIES: ${ICU_LIBRARIES} " )
402-
403- foreach (program IN LISTS icu_programs)
404- string (TOUPPER "${program} " program_upcase)
405- set (program_lib "ICU_${program_upcase} _EXECUTABLE" )
406- message (STATUS "${program} program: ${program_lib} =${${program_lib} }" )
407- unset (program_upcase)
408- unset (program_lib)
409- endforeach ()
410-
411- foreach (data IN LISTS icu_data)
412- string (TOUPPER "${data} " data_upcase)
413- string (REPLACE "." "_" data_upcase "${data_upcase} " )
414- set (data_lib "ICU_${data_upcase} " )
415- message (STATUS "${data} data: ${data_lib} =${${data_lib} }" )
416- unset (data_upcase)
417- unset (data_lib)
418- endforeach ()
419-
420- foreach (component IN LISTS ICU_FIND_COMPONENTS)
421- string (TOUPPER "${component} " component_upcase)
422- set (component_lib "ICU_${component_upcase} _LIBRARIES" )
423- set (component_found "ICU_${component_upcase} _FOUND" )
424- set (component_found_compat "${component_upcase} _FOUND" )
425- message (STATUS "${component} library found: ${component_found} =${${component_found} }" )
426- message (STATUS "${component} library found (compat name): ${component_found_compat} =${${component_found_compat} }" )
427- message (STATUS "${component} library: ${component_lib} =${${component_lib} }" )
428- unset (component_upcase)
429- unset (component_lib)
430- unset (component_found)
431- unset (component_found_compat)
432- endforeach ()
433- message (STATUS "----------------" )
434- endif ()
435-
436362unset (icu_programs)
363+ cmake_policy (POP )
0 commit comments