summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2019-05-26 11:41:37 -0400
committerAllen Winter <allen.winter@kdab.com>2019-05-26 11:41:37 -0400
commit3eeae5d03c39982c7489921b481ebf73502775d8 (patch)
tree23eaded81fa02bd44d49f7fcc417bad430e3aaed
parent7dc9a9674120fa8be2fc33e627211b515475207f (diff)
downloadlibical-git-allen/findicu.tar.gz
Remove our hand-written FindICU.cmake with the CMake versionallen/findicu
-rw-r--r--CMakeLists.txt25
-rw-r--r--Install.txt4
-rw-r--r--ReleaseNotes.txt1
-rw-r--r--cmake/modules/FindICU.cmake132
-rw-r--r--config.h.cmake3
-rw-r--r--examples/CMakeLists.txt7
-rw-r--r--src/libical/CMakeLists.txt7
-rw-r--r--src/test/CMakeLists.txt7
8 files changed, 29 insertions, 157 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd8a8ef1..e7a5a062 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -170,7 +170,10 @@ endif()
# libicu is highly recommended for RSCALE support
# libicu can be found at http://www.icu-project.org
# RSCALE info at http://tools.ietf.org/html/rfc7529
-find_package(ICU)
+if(NOT "$ENV{ICU_BASE}" STREQUAL "") #support the old ICU_BASE env
+ set(ICU_ROOT $ENV{ICU_BASE})
+endif()
+find_package(ICU COMPONENTS uc i18n)
set_package_properties(ICU PROPERTIES
TYPE RECOMMENDED
PURPOSE "For RSCALE (RFC7529) support"
@@ -183,14 +186,26 @@ add_feature_info(
if(ICU_FOUND)
set(REQUIRES_PRIVATE_ICU "Requires.private: icu-i18n") #for libical.pc
set(HAVE_LIBICU 1)
- if(ICU_MAJOR_VERSION VERSION_GREATER 50)
+ if(ICU_VERSION VERSION_GREATER 50)
set(HAVE_ICU_DANGI TRUE)
else()
set(HAVE_ICU_DANGI FALSE)
endif()
-endif()
-if(ICU_I18N_FOUND)
- set(HAVE_LIBICU_I18N 1)
+ if(ICU_GENCCODE_EXECUTABLE)
+ get_filename_component(ICU_EXEC ${ICU_GENCCODE_EXECUTABLE} DIRECTORY)
+ elseif(ICU_UCONV_EXECUTABLE)
+ get_filename_component(ICU_EXEC ${ICU_UCONV_EXECUTABLE} DIRECTORY)
+ elseif(ICU_ICUINFO_EXECUTABLE)
+ get_filename_component(ICU_EXEC ${ICU_ICUINFO_EXECUTABLE} DIRECTORY)
+ elseif(ICU_ICU-CONFIG_EXECUTABLE)
+ get_filename_component(ICU_EXEC ${ICU_ICU-CONFIG_EXECUTABLE} DIRECTORY)
+ elseif(ICU_MAKECONV_EXECUTABLE)
+ get_filename_component(ICU_EXEC ${ICU_MAKECONV_EXECUTABLE} DIRECTORY)
+ else()
+ message(FATAL_ERROR
+ "Unable find locate the ICU runtime path. Is your ICU installation broken?")
+ endif()
+ set(ICU_BINARY_DIR ${ICU_EXEC} CACHE DOC "Runtime binaries directory for the ICU library")
endif()
# compile in Berkeley DB support
diff --git a/Install.txt b/Install.txt
index 5f179c75..40cbdf63 100644
--- a/Install.txt
+++ b/Install.txt
@@ -93,8 +93,8 @@ Homebrew:
libicu can be found at http://www.icu-project.org
If CMake doesn't locate your libicu installation try setting the
- ICU_BASE environment variable to the top folder where its installed
- and run cmake again.
+ ICU_ROOT or ICU_BASE environment variables to the top folder where
+ libicu is installed and run cmake again.
* Berkeley DB storage.
Optional for the Berkeley Database storage support.
diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt
index 8577ade0..190da77b 100644
--- a/ReleaseNotes.txt
+++ b/ReleaseNotes.txt
@@ -4,6 +4,7 @@ Release Highlights
Version 3.1.0 (NOT RELEASED YET):
--------------------------------
* Requires CMake v3.11.0 or higher
+ * Improved FindICU (from the official CMake)
* All ical*_new_clone() functions have been deprecated in favour of ical*_clone()
* New publicly available functions:
+ icalrecurrencetype_encode_day
diff --git a/cmake/modules/FindICU.cmake b/cmake/modules/FindICU.cmake
deleted file mode 100644
index 460db33f..00000000
--- a/cmake/modules/FindICU.cmake
+++ /dev/null
@@ -1,132 +0,0 @@
-# Finds the International Components for Unicode (ICU) Library
-#
-# ICU_FOUND - True if ICU found.
-# ICU_I18N_FOUND - True if ICU's internationalization library found.
-# ICU_BINARY_DIR - Directory with the runtime binaries
-# ICU_INCLUDE_DIR - Directory to include to get ICU headers
-# Note: always include ICU headers as, e.g.,
-# unicode/utypes.h
-# ICU_LIBRARY - Library to link against for the common ICU
-# ICU_I18N_LIBRARY - Library to link against for ICU internationaliation
-# (note: in addition to ICU_LIBRARY)
-# ICU_VERSION - ICU version MAJOR.MINOR
-# ICU_MAJOR_VERSION - ICU major version
-# ICO_MINOR_VERSION - ICU minor version
-#
-
-set_package_properties(ICU PROPERTIES
- DESCRIPTION "libicu (International Components for Unicode) libraries"
- URL "http://www.icu-project.org"
-)
-
-if(WIN32)
- file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _program_FILES_DIR)
-endif()
-
-file(TO_NATIVE_PATH "$ENV{ICU_BASE}" icu_root)
-if(DEFINED ICU_BASE)
- file(TO_NATIVE_PATH "${ICU_BASE}" icu_root)
-else()
- find_package(PkgConfig QUIET)
- pkg_check_modules(PC_LibICU QUIET icu-i18n)
-endif()
-
-# Look for the header file.
-find_path(
- ICU_INCLUDE_DIR
- NAMES unicode/utypes.h
- HINTS
- ${icu_root}/include
- ${_program_FILES_DIR}/icu/include
- ${PC_LibICU_INCLUDEDIR}
- /usr/local/opt/icu4c/include
- DOC "Include directory for the ICU library"
-)
-mark_as_advanced(ICU_INCLUDE_DIR)
-
-# Look for the library.
-find_library(
- ICU_LIBRARY
- NAMES icuuc cygicuuc cygicuuc32
- HINTS
- ${icu_root}/lib64/
- ${icu_root}/lib/
- ${_program_FILES_DIR}/icu/lib64/
- ${_program_FILES_DIR}/icu/lib/
- ${PC_LibICU_LIBDIR}
- /usr/local/opt/icu4c/lib/
- DOC "Libraries to link against for the common parts of ICU"
-)
-mark_as_advanced(ICU_LIBRARY)
-
-# Look for the binary path.
-find_program(
- tmp_DIR
- NAMES genccode uconv
- PATHS
- ${icu_root}/bin64/
- ${icu_root}/bin/
- ${_program_FILES_DIR}/icu/bin64/
- ${_program_FILES_DIR}/icu/bin/
- /usr/local/opt/icu4c/bin/
-)
-get_filename_component(tmp_DIR ${tmp_DIR} DIRECTORY)
-set(ICU_BINARY_DIR ${tmp_DIR} CACHE DOC STRING "Runtime binaries directory for the ICU library")
-mark_as_advanced(ICU_BINARY_DIR)
-
-# Copy the results to the output variables.
-if(ICU_INCLUDE_DIR AND ICU_LIBRARY)
- set(ICU_FOUND 1)
- set(ICU_LIBRARIES ${ICU_LIBRARY})
- set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
-
- set(ICU_VERSION 0)
- set(ICU_MAJOR_VERSION 0)
- set(ICU_MINOR_VERSION 0)
- file(READ "${ICU_INCLUDE_DIR}/unicode/uvernum.h" _ICU_VERSION_CONENTS)
- string(REGEX REPLACE ".*#define U_ICU_VERSION_MAJOR_NUM ([0-9]+).*" "\\1" ICU_MAJOR_VERSION "${_ICU_VERSION_CONENTS}")
- string(REGEX REPLACE ".*#define U_ICU_VERSION_MINOR_NUM ([0-9]+).*" "\\1" ICU_MINOR_VERSION "${_ICU_VERSION_CONENTS}")
-
- set(ICU_VERSION "${ICU_MAJOR_VERSION}.${ICU_MINOR_VERSION}")
-
- # Look for the ICU internationalization libraries
- find_library(
- ICU_I18N_LIBRARY
- NAMES icuin icui18n cygicuin cygicuin32
- HINTS
- ${icu_root}/lib/
- ${_program_FILES_DIR}/icu/lib/
- ${PC_LibICU_LIBDIR}
- /usr/local/opt/icu4c/lib/
- DOC "Libraries to link against for ICU internationalization"
- )
- mark_as_advanced(ICU_I18N_LIBRARY)
- if(ICU_I18N_LIBRARY)
- set(ICU_I18N_FOUND 1)
- set(ICU_LIBRARIES "${ICU_LIBRARIES} ${ICU_I18N_LIBRARY}")
- else()
- set(ICU_I18N_FOUND 0)
- endif()
-else()
- set(ICU_FOUND 0)
- set(ICU_I18N_FOUND 0)
- set(ICU_INCLUDE_DIRS)
- set(ICU_LIBRARIES)
- set(ICU_VERSION)
- set(ICU_MAJOR_VERSION)
- set(ICU_MINOR_VERSION)
-endif()
-
-if(ICU_FOUND)
- if(NOT ICU_FIND_QUIETLY)
- message(STATUS "Found ICU version ${ICU_VERSION}")
- message(STATUS "Found ICU header files in ${ICU_INCLUDE_DIRS}")
- message(STATUS "Found ICU libraries: ${ICU_LIBRARIES}")
- endif()
-else()
- if(ICU_FIND_REQUIRED)
- message(FATAL_ERROR "Could not find ICU")
- else()
- message(STATUS "Optional package ICU was not found")
- endif()
-endif()
diff --git a/config.h.cmake b/config.h.cmake
index 8fd3421b..2cea5dc9 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -3,9 +3,6 @@
/* Define if you have the ICU library. */
#cmakedefine HAVE_LIBICU 1
-/* Define if you have the ICU internationalization library. */
-#cmakedefine HAVE_LIBICU_I18N 1
-
/* Define if you have the Berkeley DB library. */
#cmakedefine HAVE_BDB 1
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 8a18cf97..0c241f4d 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -30,12 +30,9 @@ else()
)
target_link_libraries(doesnothing ${CMAKE_THREAD_LIBS_INIT})
if(ICU_FOUND)
- target_link_libraries(doesnothing ${ICU_LIBRARY})
+ target_link_libraries(doesnothing ${ICU_LIBRARIES})
endif()
- if(ICU_I18N_FOUND)
- target_link_libraries(doesnothing ${ICU_I18N_LIBRARY})
- endif()
- if(BDB_FOUND)
+ if(BDB_FOUND)
target_link_libraries(doesnothing ${BDB_LIBRARY})
endif()
endif()
diff --git a/src/libical/CMakeLists.txt b/src/libical/CMakeLists.txt
index f5922f18..f76012bb 100644
--- a/src/libical/CMakeLists.txt
+++ b/src/libical/CMakeLists.txt
@@ -14,7 +14,7 @@ include_directories(
)
if(ICU_FOUND)
- include_directories(${ICU_INCLUDE_DIR})
+ include_directories(${ICU_INCLUDE_DIRS})
endif()
set(PACKAGE_DATA_DIR "\\\"${CMAKE_INSTALL_PREFIX}/share/libical\\\"")
@@ -268,10 +268,7 @@ endif()
target_link_libraries(ical ${CMAKE_THREAD_LIBS_INIT})
if(ICU_FOUND)
- target_link_libraries(ical ${ICU_LIBRARY})
-endif()
-if(ICU_I18N_FOUND)
- target_link_libraries(ical ${ICU_I18N_LIBRARY})
+ target_link_libraries(ical ${ICU_LIBRARIES})
endif()
if(WINCE)
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index db478dcc..5f394617 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -8,7 +8,7 @@ include_directories(
)
if(ICU_FOUND)
- include_directories(${ICU_INCLUDE_DIR})
+ include_directories(${ICU_INCLUDE_DIRS})
endif()
if(BDB_FOUND)
@@ -66,10 +66,7 @@ macro(buildme _name _srcs)
target_link_libraries(${_name} ${CMAKE_THREAD_LIBS_INIT})
if(ICU_FOUND)
- target_link_libraries(${_name} ${ICU_LIBRARY})
- endif()
- if(ICU_I18N_FOUND)
- target_link_libraries(${_name} ${ICU_I18N_LIBRARY})
+ target_link_libraries(${_name} ${ICU_LIBRARIES})
endif()
if(BDB_FOUND)
target_link_libraries(${_name} ${BDB_LIBRARY})