From 0a2a1e241fee64d8ceeca023dab4aca71b62dfbb Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 29 Sep 2019 04:44:02 +0200 Subject: [PATCH] cmake: use LibFindMacros for utf8proc (#11114) Also update doc. --- CMakeLists.txt | 2 +- README.md | 2 +- cmake/FindUTF8PROC.cmake | 16 ++++++++++++ cmake/FindUtf8proc.cmake | 54 ---------------------------------------- contrib/local.mk.example | 1 + 5 files changed, 19 insertions(+), 56 deletions(-) create mode 100644 cmake/FindUTF8PROC.cmake delete mode 100644 cmake/FindUtf8proc.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a4b21f4f6..26c82449b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -375,7 +375,7 @@ include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS}) find_package(LibLUV 1.30.0 REQUIRED) include_directories(SYSTEM ${LIBLUV_INCLUDE_DIRS}) -find_package(Utf8proc REQUIRED) +find_package(UTF8PROC REQUIRED) include_directories(SYSTEM ${UTF8PROC_INCLUDE_DIRS}) if(WIN32) add_definitions(-DUTF8PROC_STATIC) diff --git a/README.md b/README.md index 1bdf33d6bb..338c8df70e 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ To skip bundled (`third-party/*`) dependencies: 1. Install the dependencies using a package manager. ``` - sudo apt install gperf luajit luarocks libuv1-dev libluajit-5.1-dev libunibilium-dev libmsgpack-dev libtermkey-dev libvterm-dev + sudo apt install gperf luajit luarocks libuv1-dev libluajit-5.1-dev libunibilium-dev libmsgpack-dev libtermkey-dev libvterm-dev libutf8proc-dev sudo luarocks build mpack sudo luarocks build lpeg sudo luarocks build inspect diff --git a/cmake/FindUTF8PROC.cmake b/cmake/FindUTF8PROC.cmake new file mode 100644 index 0000000000..fdb462b779 --- /dev/null +++ b/cmake/FindUTF8PROC.cmake @@ -0,0 +1,16 @@ +# - Try to find utf8proc +# Once done this will define +# UTF8PROC_FOUND - System has utf8proc +# UTF8PROC_INCLUDE_DIRS - The utf8proc include directories +# UTF8PROC_LIBRARIES - The libraries needed to use utf8proc + +include(LibFindMacros) + +set(UTF8PROC_NAMES utf8proc) +if(MSVC) + # "utf8proc_static" is used for MSVC (when built statically from third-party). + # https://github.com/JuliaStrings/utf8proc/commit/0975bf9b6. + list(APPEND UTF8PROC_NAMES utf8proc_static) +endif() +libfind_pkg_detect(UTF8PROC utf8proc FIND_PATH utf8proc.h FIND_LIBRARY ${UTF8PROC_NAMES}) +libfind_process(UTF8PROC REQUIRED) diff --git a/cmake/FindUtf8proc.cmake b/cmake/FindUtf8proc.cmake deleted file mode 100644 index dc4f7016a1..0000000000 --- a/cmake/FindUtf8proc.cmake +++ /dev/null @@ -1,54 +0,0 @@ -# - Try to find utf8proc -# Once done this will define -# UTF8PROC_FOUND - System has utf8proc -# UTF8PROC_INCLUDE_DIRS - The utf8proc include directories -# UTF8PROC_LIBRARIES - The libraries needed to use utf8proc - -if(NOT USE_BUNDLED_UTF8PROC) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(PC_UTF8PROC QUIET utf8proc) - endif() -else() - set(PC_UTF8PROC_INCLUDEDIR) - set(PC_UTF8PROC_INCLUDE_DIRS) - set(PC_UTF8PROC_LIBDIR) - set(PC_UTF8PROC_LIBRARY_DIRS) - set(LIMIT_SEARCH NO_DEFAULT_PATH) -endif() - -set(UTF8PROC_DEFINITIONS ${PC_UTF8PROC_CFLAGS_OTHER}) - -find_path(UTF8PROC_INCLUDE_DIR utf8proc.h - PATHS ${PC_UTF8PROC_INCLUDEDIR} ${PC_UTF8PROC_INCLUDE_DIRS} - ${LIMIT_SEARCH}) - -# If we're asked to use static linkage, add libutf8proc.a as a preferred library name. -if(UTF8PROC_USE_STATIC) - list(APPEND UTF8PROC_NAMES - "${CMAKE_STATIC_LIBRARY_PREFIX}utf8proc${CMAKE_STATIC_LIBRARY_SUFFIX}") -if(MSVC) - list(APPEND UTF8PROC_NAMES - "${CMAKE_STATIC_LIBRARY_PREFIX}utf8proc_static${CMAKE_STATIC_LIBRARY_SUFFIX}") -endif() -endif() - -list(APPEND UTF8PROC_NAMES utf8proc) -if(MSVC) - list(APPEND UTF8PROC_NAMES utf8proc_static) -endif() - -find_library(UTF8PROC_LIBRARY NAMES ${UTF8PROC_NAMES} - HINTS ${PC_UTF8PROC_LIBDIR} ${PC_UTF8PROC_LIBRARY_DIRS} - ${LIMIT_SEARCH}) - -set(UTF8PROC_LIBRARIES ${UTF8PROC_LIBRARY}) -set(UTF8PROC_INCLUDE_DIRS ${UTF8PROC_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set UTF8PROC_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(Utf8proc DEFAULT_MSG - UTF8PROC_LIBRARY UTF8PROC_INCLUDE_DIR) - -mark_as_advanced(UTF8PROC_INCLUDE_DIR UTF8PROC_LIBRARY) diff --git a/contrib/local.mk.example b/contrib/local.mk.example index 4f7f077999..778e848d60 100644 --- a/contrib/local.mk.example +++ b/contrib/local.mk.example @@ -48,6 +48,7 @@ # DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LUAROCKS=OFF # DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_MSGPACK=OFF # DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_UNIBILIUM=OFF +# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_UTF8PROC=OFF # # Or disable all bundled dependencies at once. #