소스 검색

CMake: Add missing iconv dependency

FreeBSD has two iconv systems: It ships an iconv.h itself,
and symbols for that in the libc. But there's also the port
of GNU libiconv, which unfortunately for us, Doxygen depends
on.

This changes things to prefer a separate libiconv library
over the system one; that is, the port on FreeBSD.

Gbp-Dch: ignore
Julian Andres Klode 10 년 전
부모
커밋
01d207a507
3개의 변경된 파일28개의 추가작업 그리고 2개의 파일을 삭제
  1. 20 0
      CMake/FindIconv.cmake
  2. 1 0
      CMakeLists.txt
  3. 7 2
      apt-pkg/CMakeLists.txt

+ 20 - 0
CMake/FindIconv.cmake

@@ -0,0 +1,20 @@
+find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
+
+find_library(ICONV_LIBRARY NAMES iconv)
+if (ICONV_LIBRARY)
+    set(ICONV_SYMBOL_FOUND "${ICONV_LIBRARY}")
+else()
+    check_function_exists(iconv_open ICONV_SYMBOL_FOUND)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Iconv DEFAULT_MESSAGE ICONV_INCLUDE_DIR ICONV_SYMBOL_FOUND)
+
+if(ICONV_LIBRARY)
+    set(ICONV_LIBRARIES "${ICONV_LIBRARY}")
+else()
+    set(ICONV_LIBRARIES)
+endif()
+set(ICONV_INCLUDE_DIRS "${ICONV_INCLUDE_DIR}")
+
+mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR)

+ 1 - 0
CMakeLists.txt

@@ -29,6 +29,7 @@ include(GNUInstallDirs)
 include(TestBigEndian)
 find_package(Threads)
 find_package(LFS REQUIRED)
+find_package(Iconv REQUIRED)
 
 if(USE_NLS)
   find_package(Intl REQUIRED)

+ 7 - 2
apt-pkg/CMakeLists.txt

@@ -28,14 +28,19 @@ target_include_directories(apt-pkg
                            PRIVATE ${ZLIB_INCLUDE_DIRS}
                                    ${BZIP2_INCLUDE_DIR}
                                    ${LZMA_INCLUDE_DIRS}
-                                   ${LZ4_INCLUDE_DIRS})
+                                   ${LZ4_INCLUDE_DIRS}
+                                   ${ICONV_DIRECTORIES}
+)
+
 target_link_libraries(apt-pkg
                       PRIVATE -lutil ${CMAKE_DL_LIBS} ${RESOLV_LIBRARIES}
                              ${CMAKE_THREAD_LIBS_INIT}
                              ${ZLIB_LIBRARIES}
                              ${BZIP2_LIBRARIES}
                              ${LZMA_LIBRARIES}
-                             ${LZ4_LIBRARIES})
+                             ${LZ4_LIBRARIES}
+                             ${ICONV_LIBRARIES}
+)
 set_target_properties(apt-pkg PROPERTIES VERSION ${MAJOR}.${MINOR})
 set_target_properties(apt-pkg PROPERTIES SOVERSION ${MAJOR})
 add_version_script(apt-pkg)