Skip to content

Commit 20cec49

Browse files
committed
Link to iconv library.
1 parent be71520 commit 20cec49

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ endif(ENABLE_LOGGING)
6363

6464
find_package(Threads)
6565

66+
find_package(Iconv)
67+
if (ICONV_FOUND)
68+
include_directories(${ICONV_INCLUDE_DIRS})
69+
endif(ICONV_FOUND)
70+
6671
if(BUILD_TEST)
6772
find_package(GTest REQUIRED)
6873
if(GTEST_FOUND)

cmake/FindIconv.cmake

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Find iconv library
2+
#
3+
# Author: Eddy Xu <eddyxu at gmail.com>
4+
#
5+
# Released under BSD license
6+
#
7+
# ICONV_INCLUDE_DIRS - where to find iconv.h, etc
8+
# ICONV_LIBRARIES - Lists of libraries when using iconv
9+
# ICONV_FOUND - True if iconv found
10+
11+
12+
# Look for the header file
13+
FIND_PATH( ICONV_INCLUDE_DIR NAMES iconv.h )
14+
MARK_AS_ADVANCED( ICONV_INCLUDE_DIR )
15+
16+
# Look for the library
17+
FIND_LIBRARY( ICONV_LIBRARY NAMES iconv )
18+
MARK_AS_ADVANCED( ICONV_LIBRARY )
19+
20+
# Copy the result to output variables
21+
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
22+
SET(ICONV_FOUND 1)
23+
SET(ICONV_LIBRARIES ${ICONV_LIBRARY})
24+
SET(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR})
25+
ELSE(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
26+
SET(ICONV_FOUND 0)
27+
SET(ICONV_LIBRARIES)
28+
SET(ICONV_INCLUDE_DIRS)
29+
ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
30+
31+
# Report results
32+
IF(NOT ICONV_FOUND)
33+
SET(ICONV_DIR_MESSAGE
34+
"Iconv was not found. Make sure ICONV_LIBRARY and ICONV_INCLUDE_DIR are
35+
set.")
36+
IF(NOT ICONV_FIND_QUIETLY)
37+
MESSAGE(STATUS ${ICONV_DIR_MESSAGE})
38+
ELSE(NOT ICONV_FIND_QUIETLY)
39+
IF(ICONV_FIND_REQUIRED)
40+
MESSAGE(FETAL_ERROR ${ICONV_DIR_MESSAGE})
41+
ENDIF(ICONV_FIND_REQUIRED)
42+
ENDIF(NOT ICONV_FIND_QUIETLY)
43+
ENDIF(NOT ICONV_FOUND)

src/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if(Gflags_FOUND)
1919
endif(Gflags_FOUND)
2020

2121
set(RIME_CORE_DEPS ${Boost_LIBRARIES} ${Glog_LIBRARY} ${YamlCpp_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${RIME_OPTIONAL_DEPS})
22-
set(RIME_EXTRA_DEPS ${LevelDb_LIBRARY} ${Marisa_LIBRARY} ${Opencc_LIBRARY})
22+
set(RIME_EXTRA_DEPS ${ICONV_LIBRARIES} ${LevelDb_LIBRARY} ${Marisa_LIBRARY} ${Opencc_LIBRARY})
2323

2424
if(BUILD_SEPARATE_LIBS)
2525
set(RIME_DEPS ${RIME_CORE_DEPS})

0 commit comments

Comments
 (0)