From 9cea606881bf145ce471ba36d62eb5e3085d4e71 Mon Sep 17 00:00:00 2001 From: proller Date: Tue, 31 Jan 2017 04:14:56 +0300 Subject: [PATCH] Fix linking iconv under macos and freebsd Partially Revert "Removed usage of glib [#CLICKHOUSE-2]." This reverts commit e4ff740ef156c5e44d610fa5b531bd2a2c796d31. --- cmake/find_iconv.cmake | 10 ++++++++++ dbms/CMakeLists.txt | 8 ++------ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 cmake/find_iconv.cmake diff --git a/cmake/find_iconv.cmake b/cmake/find_iconv.cmake new file mode 100644 index 00000000000..eb0eb2fc1f5 --- /dev/null +++ b/cmake/find_iconv.cmake @@ -0,0 +1,10 @@ +if (APPLE OR CMAKE_SYSTEM MATCHES "FreeBSD") + set (ICONV_INCLUDE_PATHS "/usr/local/opt/libiconv/lib") + find_path (ICONV_INCLUDE_DIR iconv.h PATHS ${ICONV_INCLUDE_PATHS}) + set (ICONV_PATHS "/usr/local/opt/libiconv/lib") + find_library (ICONV_LIBRARY iconv PATHS ${ICONV_PATHS}) + message (STATUS "Using iconv: ${ICONV_INCLUDE_DIR} : ${ICONV_LIBRARY}") + include_directories(${ICONV_INCLUDE_DIR}) +else () + set (ICONV_LIBRARY "") +endif () diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt index b19f55556b2..be924a385c4 100644 --- a/dbms/CMakeLists.txt +++ b/dbms/CMakeLists.txt @@ -114,11 +114,6 @@ if (NOT AARCH64) set (LINK_LIBRARIES_ONLY_ON_X86_64 cpuid) endif() -set (APPLE_ICONV_LIB "") -if (APPLE) - set(APPLE_ICONV_LIB iconv) -endif() - if (CMAKE_SYSTEM MATCHES "FreeBSD") set(PLATFORM_LIBS "execinfo") else() @@ -132,6 +127,7 @@ else() find_library (Z_LIB z HINTS ${Z_HINTS}) endif () +include (${CMAKE_SOURCE_DIR}/cmake/find_iconv.cmake) find_package (Threads) target_link_libraries(dbms @@ -151,7 +147,7 @@ target_link_libraries(dbms ${Poco_DataODBC_LIBRARY} ${Poco_MongoDB_LIBRARY} ${Poco_Foundation_LIBRARY} - ${APPLE_ICONV_LIB} + ${ICONV_LIBRARY} ${PLATFORM_LIBS} ${CMAKE_DL_LIBS} ${LTDL_LIB}