mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 01:09:07 +08:00
[libxml2] Switch build to CMake for better triplet support. Add liblzma dependency.
This commit is contained in:
parent
fe81139bc0
commit
4143dc0c2b
@ -1,60 +0,0 @@
|
|||||||
---
|
|
||||||
win32/Makefile.msvc | 22 ++++++++++++----------
|
|
||||||
1 file changed, 12 insertions(+), 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
|
|
||||||
index d16c1a2..de9e22e 100644
|
|
||||||
--- a/win32/Makefile.msvc
|
|
||||||
+++ b/win32/Makefile.msvc
|
|
||||||
@@ -28,11 +28,11 @@ XML_A = $(XML_BASENAME)_a.lib
|
|
||||||
XML_A_DLL = $(XML_BASENAME)_a_dll.lib
|
|
||||||
|
|
||||||
# Place where we let the compiler put its output.
|
|
||||||
-BINDIR = bin.msvc
|
|
||||||
-XML_INTDIR = int.msvc
|
|
||||||
-XML_INTDIR_A = int.a.msvc
|
|
||||||
-XML_INTDIR_A_DLL = int.a.dll.msvc
|
|
||||||
-UTILS_INTDIR = int.utils.msvc
|
|
||||||
+BINDIR = $(OUTDIR)\bin.msvc
|
|
||||||
+XML_INTDIR = $(OUTDIR)\int.msvc
|
|
||||||
+XML_INTDIR_A = $(OUTDIR)\int.a.msvc
|
|
||||||
+XML_INTDIR_A_DLL = $(OUTDIR)\int.a.dll.msvc
|
|
||||||
+UTILS_INTDIR = $(OUTDIR)\int.utils.msvc
|
|
||||||
|
|
||||||
# The preprocessor and its options.
|
|
||||||
CPP = cl.exe /EP
|
|
||||||
@@ -72,16 +72,18 @@ LIBS =
|
|
||||||
LIBS = $(LIBS) wsock32.lib ws2_32.lib
|
|
||||||
!endif
|
|
||||||
!if "$(WITH_ICONV)" == "1"
|
|
||||||
-LIBS = $(LIBS) iconv.lib
|
|
||||||
+LIBS = $(LIBS) libiconv.lib libcharset.lib
|
|
||||||
!endif
|
|
||||||
!if "$(WITH_ICU)" == "1"
|
|
||||||
LIBS = $(LIBS) icu.lib
|
|
||||||
!endif
|
|
||||||
!if "$(WITH_ZLIB)" == "1"
|
|
||||||
-# could be named differently zdll or zlib
|
|
||||||
-# LIBS = $(LIBS) zdll.lib
|
|
||||||
+!if "$(DEBUG)" == "1"
|
|
||||||
+LIBS = $(LIBS) zlibd.lib
|
|
||||||
+!else
|
|
||||||
LIBS = $(LIBS) zlib.lib
|
|
||||||
!endif
|
|
||||||
+!endif
|
|
||||||
!if "$(WITH_LZMA)" == "1"
|
|
||||||
LIBS = $(LIBS) liblzma.lib
|
|
||||||
!endif
|
|
||||||
@@ -101,10 +103,10 @@ ARFLAGS = /nologo
|
|
||||||
CFLAGS = $(CFLAGS) /D "_DEBUG" /Od /Z7
|
|
||||||
LDFLAGS = $(LDFLAGS) /DEBUG
|
|
||||||
!else
|
|
||||||
CFLAGS = $(CFLAGS) /D "NDEBUG" /O2
|
|
||||||
# commented out as this break VC10 c.f. 634846
|
|
||||||
# LDFLAGS = $(LDFLAGS) /OPT:NOWIN98
|
|
||||||
-LDFLAGS = $(LDFLAGS)
|
|
||||||
+LDFLAGS = $(LDFLAGS) /DEBUG /OPT:REF /OPT:ICF
|
|
||||||
!endif
|
|
||||||
|
|
||||||
# Libxml object files.
|
|
||||||
--
|
|
110
ports/libxml2/CMakeLists.txt
Normal file
110
ports/libxml2/CMakeLists.txt
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(libxml2 C)
|
||||||
|
|
||||||
|
option(INSTALL_HEADERS "Install public header files" ON)
|
||||||
|
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(LibLZMA REQUIRED)
|
||||||
|
find_library(ICONV NAMES libiconv)
|
||||||
|
find_library(ICONV_CHARSET NAMES libcharset)
|
||||||
|
|
||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
# Generate xmlexports with fixed definition of LIBXML_STATIC
|
||||||
|
file(READ include/libxml/xmlexports.h XMLEXPORTS_H)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
string(REPLACE "!defined(LIBXML_STATIC)" "1" XMLEXPORTS_H "${XMLEXPORTS_H}")
|
||||||
|
else()
|
||||||
|
string(REPLACE "!defined(LIBXML_STATIC)" "0" XMLEXPORTS_H "${XMLEXPORTS_H}")
|
||||||
|
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)
|
||||||
|
|
||||||
|
add_library(libxml2 ${SOURCES})
|
||||||
|
if(INSTALL_HEADERS)
|
||||||
|
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_link_libraries(libxml2 PRIVATE
|
||||||
|
ZLIB::ZLIB
|
||||||
|
${LIBLZMA_LIBRARIES}
|
||||||
|
${ICONV}
|
||||||
|
${ICONV_CHARSET}
|
||||||
|
wsock32.lib
|
||||||
|
ws2_32.lib
|
||||||
|
)
|
||||||
|
target_compile_definitions(libxml2 PRIVATE
|
||||||
|
-D_CRT_SECURE_NO_DEPRECATE
|
||||||
|
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
-D_REENTRANT
|
||||||
|
-DNOLIBTOOL
|
||||||
|
-DHAVE_WIN32_THREADS
|
||||||
|
-DHAVE_ZLIB_H
|
||||||
|
-DHAVE_LZMA_H
|
||||||
|
)
|
||||||
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(libxml2 PRIVATE -DLIBXML_STATIC)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(TARGET_INSTALL_OPTIONS)
|
||||||
|
if(INSTALL_HEADERS)
|
||||||
|
set(TARGET_INSTALL_OPTIONS PUBLIC_HEADER DESTINATION include/libxml)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS libxml2
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
${TARGET_INSTALL_OPTIONS}
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
Source: libxml2
|
Source: libxml2
|
||||||
Version: 2.9.4
|
Version: 2.9.4-1
|
||||||
Description: Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform)
|
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
|
Build-Depends: zlib, libiconv, liblzma
|
||||||
|
@ -15,152 +15,15 @@ vcpkg_download_distfile(ARCHIVE
|
|||||||
)
|
)
|
||||||
vcpkg_extract_source_archive(${ARCHIVE})
|
vcpkg_extract_source_archive(${ARCHIVE})
|
||||||
|
|
||||||
find_program(NMAKE nmake)
|
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||||
|
|
||||||
vcpkg_apply_patches(
|
vcpkg_configure_cmake(
|
||||||
SOURCE_PATH ${SOURCE_PATH}/
|
SOURCE_PATH ${SOURCE_PATH}
|
||||||
PATCHES ${CMAKE_CURRENT_LIST_DIR}/0001-Fix-makefile.patch
|
PREFER_NINJA
|
||||||
|
OPTIONS_DEBUG -DINSTALL_HEADERS=OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
set(SCRIPTS_DIR ${SOURCE_PATH}/win32)
|
vcpkg_install_cmake()
|
||||||
|
|
||||||
set(CONFIGURE_COMMAND_TEMPLATE cscript configure.js
|
|
||||||
zlib=yes
|
|
||||||
cruntime=@CRUNTIME@
|
|
||||||
debug=@DEBUGMODE@
|
|
||||||
prefix=@INSTALL_DIR@
|
|
||||||
include=@INCLUDE_DIR@
|
|
||||||
lib=@LIB_DIR@
|
|
||||||
bindir=@INSTALL_BIN_DIR@
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Release
|
|
||||||
#
|
|
||||||
|
|
||||||
message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
|
|
||||||
|
|
||||||
if(VCPKG_CRT_LINKAGE STREQUAL dynamic)
|
|
||||||
set(CRUNTIME /MD)
|
|
||||||
else()
|
|
||||||
set(CRUNTIME /MT)
|
|
||||||
endif()
|
|
||||||
set(DEBUGMODE no)
|
|
||||||
set(LIB_DIR ${CURRENT_INSTALLED_DIR}/lib)
|
|
||||||
set(INCLUDE_DIR ${CURRENT_INSTALLED_DIR}/include)
|
|
||||||
set(INSTALL_DIR ${CURRENT_PACKAGES_DIR})
|
|
||||||
set(INSTALL_BIN_DIR "$(PREFIX)/tools")
|
|
||||||
file(TO_NATIVE_PATH "${LIB_DIR}" LIB_DIR)
|
|
||||||
file(TO_NATIVE_PATH "${INCLUDE_DIR}" INCLUDE_DIR)
|
|
||||||
file(TO_NATIVE_PATH "${INSTALL_DIR}" INSTALL_DIR)
|
|
||||||
file(TO_NATIVE_PATH "${INSTALL_BIN_DIR}" INSTALL_BIN_DIR)
|
|
||||||
string(CONFIGURE "${CONFIGURE_COMMAND_TEMPLATE}" CONFIGURE_COMMAND)
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND ${CONFIGURE_COMMAND}
|
|
||||||
WORKING_DIRECTORY ${SCRIPTS_DIR}
|
|
||||||
LOGNAME config-${TARGET_TRIPLET}-rel
|
|
||||||
)
|
|
||||||
# Handle build output directory
|
|
||||||
file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" OUTDIR)
|
|
||||||
file(MAKE_DIRECTORY "${OUTDIR}")
|
|
||||||
message(STATUS "Configuring ${TARGET_TRIPLET}-rel done")
|
|
||||||
|
|
||||||
message(STATUS "Building ${TARGET_TRIPLET}-rel")
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND ${NMAKE} /f Makefile.msvc rebuild OUTDIR=${OUTDIR}
|
|
||||||
WORKING_DIRECTORY ${SCRIPTS_DIR}
|
|
||||||
LOGNAME build-${TARGET_TRIPLET}-rel
|
|
||||||
)
|
|
||||||
message(STATUS "Building ${TARGET_TRIPLET}-rel done")
|
|
||||||
|
|
||||||
message(STATUS "Installing ${TARGET_TRIPLET}-rel")
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND ${NMAKE} /f Makefile.msvc install OUTDIR=${OUTDIR}
|
|
||||||
WORKING_DIRECTORY ${SCRIPTS_DIR}
|
|
||||||
LOGNAME install-${TARGET_TRIPLET}-rel
|
|
||||||
)
|
|
||||||
message(STATUS "Installing ${TARGET_TRIPLET}-rel done")
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Debug
|
|
||||||
#
|
|
||||||
|
|
||||||
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
|
|
||||||
|
|
||||||
if(VCPKG_CRT_LINKAGE STREQUAL dynamic)
|
|
||||||
set(CRUNTIME /MDd)
|
|
||||||
else()
|
|
||||||
set(CRUNTIME /MTd)
|
|
||||||
endif()
|
|
||||||
set(DEBUGMODE yes)
|
|
||||||
set(LIB_DIR ${CURRENT_INSTALLED_DIR}/debug/lib)
|
|
||||||
set(INSTALL_DIR ${CURRENT_PACKAGES_DIR}/debug)
|
|
||||||
file(TO_NATIVE_PATH "${LIB_DIR}" LIB_DIR)
|
|
||||||
file(TO_NATIVE_PATH "${INSTALL_DIR}" INSTALL_DIR)
|
|
||||||
string(CONFIGURE "${CONFIGURE_COMMAND_TEMPLATE}" CONFIGURE_COMMAND)
|
|
||||||
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND ${CONFIGURE_COMMAND}
|
|
||||||
WORKING_DIRECTORY ${SCRIPTS_DIR}
|
|
||||||
LOGNAME config-${TARGET_TRIPLET}-dbg
|
|
||||||
)
|
|
||||||
# Handle build output directory
|
|
||||||
file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" OUTDIR)
|
|
||||||
file(MAKE_DIRECTORY "${OUTDIR}")
|
|
||||||
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
|
|
||||||
|
|
||||||
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND ${NMAKE} /f Makefile.msvc rebuild OUTDIR=${OUTDIR}
|
|
||||||
WORKING_DIRECTORY ${SCRIPTS_DIR}
|
|
||||||
LOGNAME build-${TARGET_TRIPLET}-dbg
|
|
||||||
)
|
|
||||||
message(STATUS "Building ${TARGET_TRIPLET}-dbg done")
|
|
||||||
|
|
||||||
message(STATUS "Installing ${TARGET_TRIPLET}-dbg")
|
|
||||||
vcpkg_execute_required_process(
|
|
||||||
COMMAND ${NMAKE} /f Makefile.msvc install OUTDIR=${OUTDIR}
|
|
||||||
WORKING_DIRECTORY ${SCRIPTS_DIR}
|
|
||||||
LOGNAME install-${TARGET_TRIPLET}-dbg
|
|
||||||
)
|
|
||||||
message(STATUS "Installing ${TARGET_TRIPLET}-dbg done")
|
|
||||||
|
|
||||||
#
|
|
||||||
# Cleanup
|
|
||||||
#
|
|
||||||
|
|
||||||
# You have to define LIBXML_STATIC or not, depending on how you link
|
|
||||||
file(READ ${CURRENT_PACKAGES_DIR}/include/libxml2/libxml/xmlexports.h XMLEXPORTS_H)
|
|
||||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
|
||||||
string(REPLACE "!defined(LIBXML_STATIC)" "0" XMLEXPORTS_H "${XMLEXPORTS_H}")
|
|
||||||
else()
|
|
||||||
string(REPLACE "!defined(LIBXML_STATIC)" "1" XMLEXPORTS_H "${XMLEXPORTS_H}")
|
|
||||||
endif()
|
|
||||||
file(WRITE ${CURRENT_PACKAGES_DIR}/include/libxml2/libxml/xmlexports.h "${XMLEXPORTS_H}")
|
|
||||||
|
|
||||||
# Remove tools and debug include directories
|
|
||||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/tools)
|
|
||||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/tools)
|
|
||||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
|
||||||
|
|
||||||
# Move includes to the expected directory
|
|
||||||
file(RENAME ${CURRENT_PACKAGES_DIR}/include/libxml2/libxml ${CURRENT_PACKAGES_DIR}/include/libxml)
|
|
||||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/libxml2)
|
|
||||||
|
|
||||||
# The makefile builds both static and dynamic libraries, so remove the ones we don't want
|
|
||||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
|
||||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libxml2_a.lib ${CURRENT_PACKAGES_DIR}/lib/libxml2_a_dll.lib)
|
|
||||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/libxml2_a.lib ${CURRENT_PACKAGES_DIR}/debug/lib/libxml2_a_dll.lib)
|
|
||||||
else()
|
|
||||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/libxml2.lib ${CURRENT_PACKAGES_DIR}/lib/libxml2_a_dll.lib)
|
|
||||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/libxml2.lib ${CURRENT_PACKAGES_DIR}/debug/lib/libxml2_a_dll.lib)
|
|
||||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
|
|
||||||
# Rename the libs to match the dynamic lib names
|
|
||||||
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libxml2_a.lib ${CURRENT_PACKAGES_DIR}/lib/libxml2.lib)
|
|
||||||
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libxml2_a.lib ${CURRENT_PACKAGES_DIR}/debug/lib/libxml2.lib)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Handle copyright
|
# Handle copyright
|
||||||
file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libxml2)
|
file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libxml2)
|
||||||
|
Loading…
Reference in New Issue
Block a user