From 9344a40e741557948215dfeb4ae32b7c0d6d7b6b Mon Sep 17 00:00:00 2001 From: John Szakmeister Date: Sat, 8 Nov 2014 16:18:04 -0500 Subject: build: pull iconv detection into its own FindIconv.cmake file This will provide better control for those who may want to alter which one gets used. --- CMakeLists.txt | 5 +++++ cmake/FindIconv.cmake | 18 ++++++++++++++++++ config/CMakeLists.txt | 7 ++----- src/nvim/CMakeLists.txt | 4 ++-- 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 cmake/FindIconv.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 485eb4ae23..7b26b57e20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,6 +131,11 @@ if(LibIntl_FOUND) include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS}) endif() +find_package(Iconv) +if(Iconv_FOUND) + include_directories(SYSTEM ${Iconv_INCLUDE_DIRS}) +endif() + # Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD # explicitly to indicate a strong preference for pthread. set(CMAKE_THREAD_PREFER_PTHREAD ON) diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake new file mode 100644 index 0000000000..f3a54e9d6f --- /dev/null +++ b/cmake/FindIconv.cmake @@ -0,0 +1,18 @@ +# - Try to find iconv +# Once done, this will define +# +# Iconv_FOUND - system has iconv +# Iconv_INCLUDE_DIRS - the iconv include directories +# Iconv_LIBRARIES - link these to use iconv + +include(LibFindMacros) + +find_path(ICONV_INCLUDE_DIR NAMES iconv.h) +find_library(ICONV_LIBRARY NAMES iconv) + +set(Iconv_PROCESS_INCLUDES ICONV_INCLUDE_DIR) +if(ICONV_LIBRARY) + set(Iconv_PROCESS_LIBS ICONV_LIBRARY) +endif() + +libfind_process(Iconv) diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt index c48887548d..0f5dd7d984 100644 --- a/config/CMakeLists.txt +++ b/config/CMakeLists.txt @@ -44,12 +44,9 @@ check_function_exists(getpwent HAVE_GETPWENT) check_function_exists(getpwnam HAVE_GETPWNAM) check_function_exists(getpwuid HAVE_GETPWUID) -check_include_files(iconv.h HAVE_ICONV_H) -check_library_exists(iconv iconv "" HAVE_ICONV_LIB) -if(HAVE_ICONV_LIB) - set(CMAKE_REQUIRED_LIBRARIES iconv) +if(Iconv_FOUND) + set(HAVE_ICONV 1) endif() -check_function_exists(iconv HAVE_ICONV) check_function_exists(lstat HAVE_LSTAT) if(NOT HAVE_LSTAT) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 5b97cf5f40..4e0819cc0e 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -158,8 +158,8 @@ else() endif() endif() -if(HAVE_ICONV_LIB) - list(APPEND NVIM_LINK_LIBRARIES iconv) +if(Iconv_LIBRARIES) + list(APPEND NVIM_LINK_LIBRARIES ${Iconv_LIBRARIES}) endif() # Put these last on the link line, since multiple things may depend on them. -- cgit