From 1f7d155b5fec22b7a04fa49de5672f8557c15cc7 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Tue, 3 Apr 2018 15:59:54 -0700 Subject: [PATCH] [libiconv][libxml2] Fix libxml2 on Linux and OSX --- ports/libiconv/CONTROL | 2 +- ports/libiconv/portfile.cmake | 2 +- ports/libiconv/unofficial-iconv-config.cmake | 2 + ports/libiconv/vcpkg-iconv-config.cmake | 2 - ports/libxml2/CMakeLists.txt | 84 ++++++-------------- ports/libxml2/CONTROL | 2 +- ports/libxml2/config.linux.h | 56 +++++++++++++ ports/libxml2/config.osx.h | 54 +++++++++++++ ports/libxml2/portfile.cmake | 1 + ports/libxml2/vcpkg-cmake-wrapper.cmake | 18 +++-- 10 files changed, 150 insertions(+), 73 deletions(-) create mode 100644 ports/libiconv/unofficial-iconv-config.cmake delete mode 100644 ports/libiconv/vcpkg-iconv-config.cmake create mode 100644 ports/libxml2/config.linux.h create mode 100644 ports/libxml2/config.osx.h diff --git a/ports/libiconv/CONTROL b/ports/libiconv/CONTROL index 8bb9625b9..37c1a0f0d 100644 --- a/ports/libiconv/CONTROL +++ b/ports/libiconv/CONTROL @@ -1,3 +1,3 @@ Source: libiconv -Version: 1.15-2 +Version: 1.15-3 Description: GNU Unicode text conversion diff --git a/ports/libiconv/portfile.cmake b/ports/libiconv/portfile.cmake index bded180db..5cc48da91 100644 --- a/ports/libiconv/portfile.cmake +++ b/ports/libiconv/portfile.cmake @@ -1,7 +1,7 @@ if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set(VCPKG_POLICY_EMPTY_PACKAGE enabled) file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/libiconv) - file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-iconv-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/libiconv) + file(COPY ${CMAKE_CURRENT_LIST_DIR}/unofficial-iconv-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/unofficial-iconv) return() endif() diff --git a/ports/libiconv/unofficial-iconv-config.cmake b/ports/libiconv/unofficial-iconv-config.cmake new file mode 100644 index 000000000..e272ce09e --- /dev/null +++ b/ports/libiconv/unofficial-iconv-config.cmake @@ -0,0 +1,2 @@ +add_library(unofficial::iconv::libcharset UNKNOWN IMPORTED) +add_library(unofficial::iconv::libiconv UNKNOWN IMPORTED) diff --git a/ports/libiconv/vcpkg-iconv-config.cmake b/ports/libiconv/vcpkg-iconv-config.cmake deleted file mode 100644 index 4befd4d15..000000000 --- a/ports/libiconv/vcpkg-iconv-config.cmake +++ /dev/null @@ -1,2 +0,0 @@ -add_library(unofficial::vcpkg::libcharset UNKNOWN IMPORTED) -add_library(unofficial::vcpkg::libiconv UNKNOWN IMPORTED) diff --git a/ports/libxml2/CMakeLists.txt b/ports/libxml2/CMakeLists.txt index 96ecb901d..3d49985ee 100644 --- a/ports/libxml2/CMakeLists.txt +++ b/ports/libxml2/CMakeLists.txt @@ -3,60 +3,16 @@ project(libxml2 C) option(INSTALL_HEADERS "Install public header files" ON) +set(CMAKE_SHARED_LIBRARY_PREFIX) +set(CMAKE_STATIC_LIBRARY_PREFIX) + find_package(ZLIB REQUIRED) find_package(LibLZMA REQUIRED) -if(WIN32) - find_library(ICONV NAMES libiconv) - find_library(ICONV_CHARSET NAMES libcharset) -endif() +find_package(unofficial-iconv REQUIRED) -set(SOURCES - buf.c - c14n.c - catalog.c - chvalid.c - debugXML.c - dict.c - DOCBparser.c - encoding.c - entities.c - error.c - globals.c - hash.c - HTMLparser.c - HTMLtree.c - legacy.c - list.c - nanoftp.c - nanohttp.c - parser.c - parserInternals.c - pattern.c - relaxng.c - SAX.c - SAX2.c - schematron.c - threads.c - tree.c - uri.c - valid.c - xinclude.c - xlink.c - xmlIO.c - xmlmemory.c - xmlreader.c - xmlregexp.c - xmlmodule.c - xmlsave.c - xmlschemas.c - xmlschemastypes.c - xmlstring.c - xmlunicode.c - xmlwriter.c - xpath.c - xpointer.c - xzlib.c -) +file(GLOB SOURCES *.c) +list(FILTER SOURCES EXCLUDE REGEX "/(run|test|trio)[^/]*$") +list(FILTER SOURCES EXCLUDE REGEX "xml(lint|catalog).c$") # Generate xmlexports with fixed definition of LIBXML_STATIC file(READ include/libxml/xmlexports.h XMLEXPORTS_H) @@ -67,25 +23,33 @@ else() endif() file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/xmlexports.h "${XMLEXPORTS_H}") -file(GLOB PUBLIC_HEADERS include/libxml/*.h) -list(FILTER PUBLIC_HEADERS EXCLUDE REGEX "xmlexports\\.h$") -list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/xmlexports.h) - -configure_file(include/win32config.h config.h COPYONLY) +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + configure_file(include/win32config.h config.h COPYONLY) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + configure_file("${PORT_DIR}/config.osx.h" config.h COPYONLY) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + configure_file("${PORT_DIR}/config.linux.h" config.h COPYONLY) +else() + message(FATAL_ERROR "No config.h checked in for the target platform. Please run ./configure for libxml2 and add the resulting config.h into this port.") +endif() add_library(libxml2 ${SOURCES}) if(INSTALL_HEADERS) + file(GLOB PUBLIC_HEADERS include/libxml/*.h) + list(FILTER PUBLIC_HEADERS EXCLUDE REGEX "xmlexports\\.h$") + list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/xmlexports.h) + set_target_properties(libxml2 PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") endif() -target_include_directories(libxml2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR} win32/vc10 include ${LIBLZMA_INCLUDE_DIRS}) +target_include_directories(libxml2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR} include ${LIBLZMA_INCLUDE_DIRS}) target_link_libraries(libxml2 PRIVATE + unofficial::iconv::libcharset unofficial::iconv::libiconv ZLIB::ZLIB ${LIBLZMA_LIBRARIES} ) -if(WIN32) +if(CMAKE_SYSTEM_NAME STREQUAL "Windows") + target_include_directories(libxml2 PRIVATE win32/vc10) target_link_libraries(libxml2 PRIVATE - ${ICONV} - ${ICONV_CHARSET} wsock32.lib ws2_32.lib ) diff --git a/ports/libxml2/CONTROL b/ports/libxml2/CONTROL index b8552e48e..f005d2367 100644 --- a/ports/libxml2/CONTROL +++ b/ports/libxml2/CONTROL @@ -1,4 +1,4 @@ Source: libxml2 -Version: 2.9.4-4 +Version: 2.9.4-5 Description: Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform) Build-Depends: zlib, libiconv, liblzma diff --git a/ports/libxml2/config.linux.h b/ports/libxml2/config.linux.h new file mode 100644 index 000000000..d029e95cf --- /dev/null +++ b/ports/libxml2/config.linux.h @@ -0,0 +1,56 @@ +#define GETHOSTBYNAME_ARG_CAST /**/ +#define HAVE_ANSIDECL_H 1 +#define HAVE_ARPA_INET_H 1 +#define HAVE_ARPA_NAMESER_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_DIRENT_H 1 +#define HAVE_DLFCN_H 1 +#define HAVE_DLOPEN /**/ +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_FTIME 1 +#define HAVE_GETADDRINFO /**/ +#define HAVE_GETTIMEOFDAY 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_ISASCII 1 +#define HAVE_LIMITS_H 1 +#define HAVE_LOCALTIME 1 +#define HAVE_LZMA_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MATH_H 1 +#define HAVE_MMAP 1 +#define HAVE_NETDB_H 1 +#define HAVE_NETINET_IN_H 1 +#define HAVE_POLL_H 1 +#define HAVE_PTHREAD_H /**/ +#define HAVE_PUTENV 1 +#define HAVE_RAND 1 +#define HAVE_RAND_R 1 +#define HAVE_RESOLV_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_SRAND 1 +#define HAVE_STAT 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRFTIME 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_MMAN_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TIMEB_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_TIME 1 +#define HAVE_TIME_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_VA_COPY 1 +#define HAVE_ZLIB_H 1 +#define ICONV_CONST +#define SEND_ARG2_CAST /**/ +#define SUPPORT_IP6 /**/ +#define VA_LIST_IS_ARRAY 1 +#define XML_SOCKLEN_T socklen_t diff --git a/ports/libxml2/config.osx.h b/ports/libxml2/config.osx.h new file mode 100644 index 000000000..95d83edc1 --- /dev/null +++ b/ports/libxml2/config.osx.h @@ -0,0 +1,54 @@ +#define GETHOSTBYNAME_ARG_CAST /**/ +#define HAVE_ARPA_INET_H 1 +#define HAVE_ARPA_NAMESER_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_DIRENT_H 1 +#define HAVE_DLFCN_H 1 +#define HAVE_DLOPEN /**/ +#define HAVE_ERRNO_H 1 +#define HAVE_FCNTL_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_FTIME 1 +#define HAVE_GETADDRINFO /**/ +#define HAVE_GETTIMEOFDAY 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_ISASCII 1 +#define HAVE_LIMITS_H 1 +#define HAVE_LOCALTIME 1 +#define HAVE_LZMA_H 1 +#define HAVE_MATH_H 1 +#define HAVE_MMAP 1 +#define HAVE_NETDB_H 1 +#define HAVE_NETINET_IN_H 1 +#define HAVE_POLL_H 1 +#define HAVE_PTHREAD_H /**/ +#define HAVE_PUTENV 1 +#define HAVE_RAND 1 +#define HAVE_RAND_R 1 +#define HAVE_RESOLV_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_SRAND 1 +#define HAVE_STAT 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRFTIME 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_MMAN_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SOCKET_H 1 +#define HAVE_SYS_STAT_H 1 +#define HAVE_SYS_TIMEB_H 1 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_TIME 1 +#define HAVE_TIME_H 1 +#define HAVE_UNISTD_H 1 +#define HAVE_VA_COPY 1 +#define HAVE_ZLIB_H 1 +#define ICONV_CONST +#define SEND_ARG2_CAST /**/ +#define SUPPORT_IP6 /**/ +#define VA_LIST_IS_ARRAY 1 +#define XML_SOCKLEN_T socklen_t diff --git a/ports/libxml2/portfile.cmake b/ports/libxml2/portfile.cmake index a300fcaf5..cdf10496e 100644 --- a/ports/libxml2/portfile.cmake +++ b/ports/libxml2/portfile.cmake @@ -12,6 +12,7 @@ file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA + OPTIONS -DPORT_DIR=${CMAKE_CURRENT_LIST_DIR} OPTIONS_DEBUG -DINSTALL_HEADERS=OFF ) diff --git a/ports/libxml2/vcpkg-cmake-wrapper.cmake b/ports/libxml2/vcpkg-cmake-wrapper.cmake index 6452af426..68bed6547 100644 --- a/ports/libxml2/vcpkg-cmake-wrapper.cmake +++ b/ports/libxml2/vcpkg-cmake-wrapper.cmake @@ -1,11 +1,13 @@ _find_package(${ARGS}) -if(LibXml2_FOUND AND (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")) +if(LibXml2_FOUND) find_package(LibLZMA) - list(APPEND LIBXML2_LIBRARIES - ${LIBLZMA_LIBRARIES} - debug ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/libiconv.lib - optimized ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libiconv.lib - debug ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/libcharset.lib - optimized ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libcharset.lib - ws2_32) + list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES}) + if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + list(APPEND LIBXML2_LIBRARIES + debug ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/libiconv.lib + optimized ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libiconv.lib + debug ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/libcharset.lib + optimized ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libcharset.lib + ws2_32) + endif() endif()