Skip to content
Browse files

Fix for FreeBSD (maybe others?) -- Libxml2 depends on libiconv.

  • Loading branch information...
1 parent 2c2d083 commit 642114daab87c5b317121949ae4044d0d7ae4698 @jeremytregunna jeremytregunna committed May 8, 2010
Showing with 48 additions and 4 deletions.
  1. +6 −4 addons/Libxml2/CMakeLists.txt
  2. +42 −0 modules/FindIconv.cmake
View
10 addons/Libxml2/CMakeLists.txt
@@ -3,6 +3,8 @@
#
# Builds the Libxml2 addon
+# Find Iconv
+find_package(Iconv)
# Find libxml2
find_package(LibXml2)
@@ -11,15 +13,15 @@ make_build_bundle(_build)
# Did we find libevent? if so, set up the targets and all the
# support variables.
-if(LIBXML2_FOUND)
+if(LIBXML2_FOUND AND ICONV_FOUND)
# Output our dynamic library to the top-level _build hierarchy
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/_build/dll)
# Add LibXml2 definitions
add_definitions(${LIBXML2_DEFINITIONS})
# Additional include directories
- include_directories(${LIBXML2_INCLUDE_DIR})
+ include_directories(${LIBXML2_INCLUDE_DIR} ${ICONV_INCLUDE_DIR})
# Generate the IoLibxml2Init.c file.
# Argument SHOULD ALWAYS be the exact name of the addon, case is
@@ -36,9 +38,9 @@ if(LIBXML2_FOUND)
# Now build the shared library
add_library(IoLibxml2 SHARED ${SRCS})
add_dependencies(IoLibxml2 iovmall)
- target_link_libraries(IoLibxml2 iovmall ${LIBXML2_LIBRARIES})
+ target_link_libraries(IoLibxml2 iovmall ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
# Install the addon to our global addons hierarchy.
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_build DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons/Libxml2)
-endif(LIBXML2_FOUND)
+endif(LIBXML2_FOUND AND ICONV_FOUND)
View
42 modules/FindIconv.cmake
@@ -0,0 +1,42 @@
+# - Try to find Iconv
+# Once done this will define
+#
+# ICONV_FOUND - system has Iconv
+# ICONV_INCLUDE_DIR - the Iconv include directory
+# ICONV_LIBRARIES - Link these to use Iconv
+# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
+#
+
+IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+ # Already in cache, be silent
+ SET(ICONV_FIND_QUIETLY TRUE)
+ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+
+FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
+
+FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
+
+IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+ SET(ICONV_FOUND TRUE)
+ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
+
+set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
+set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
+set(CMAKE_REQUIRED_INCLUDES)
+set(CMAKE_REQUIRED_LIBRARIES)
+
+IF(ICONV_FOUND)
+ IF(NOT ICONV_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
+ ENDIF(NOT ICONV_FIND_QUIETLY)
+ELSE(ICONV_FOUND)
+ IF(Iconv_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Iconv")
+ ENDIF(Iconv_FIND_REQUIRED)
+ENDIF(ICONV_FOUND)
+
+MARK_AS_ADVANCED(
+ ICONV_INCLUDE_DIR
+ ICONV_LIBRARIES
+ ICONV_SECOND_ARGUMENT_IS_CONST
+)

0 comments on commit 642114d

Please sign in to comment.
Something went wrong with that request. Please try again.