cmake: use LibFindMacros for utf8proc (#11114)

Also update doc.
This commit is contained in:
Daniel Hahler 2019-09-29 04:44:02 +02:00 committed by GitHub
parent 34d55f8607
commit 0a2a1e241f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 56 deletions

View File

@ -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)

View File

@ -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

16
cmake/FindUTF8PROC.cmake Normal file
View File

@ -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)

View File

@ -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)

View File

@ -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.
#