Skip to content

Commit

Permalink
libxml2: Migrate to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
hmelder authored and triplef committed Jun 21, 2024
1 parent 7d320c1 commit 393e6a3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 38 deletions.
49 changes: 34 additions & 15 deletions patches/libxml2-windows-icu.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 723e2344..c513872e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,7 +102,7 @@ if(LIBXML2_WITH_ICONV)
endif()

if(LIBXML2_WITH_ICU)
- find_package(ICU REQUIRED COMPONENTS data i18n uc)
+ find_package(ICU REQUIRED COMPONENTS i18n uc)
endif()

if(LIBXML2_WITH_LZMA)
@@ -368,9 +368,9 @@ if(LIBXML2_WITH_ICONV)
endif()

if(LIBXML2_WITH_ICU)
- target_link_libraries(LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc)
+ target_link_libraries(LibXml2 PRIVATE ICU::i18n ICU::uc)
if(WIN32)
- set(ICU_LDFLAGS "-licudt -licuin -licuuc")
+ set(ICU_LDFLAGS "-licu")
else()
set(ICU_LDFLAGS "-licudata -licui18n -licuuc")
endif()
@@ -433,7 +433,6 @@ set_target_properties(
IMPORT_PREFIX lib
OUTPUT_NAME xml2
POSITION_INDEPENDENT_CODE ON
- PREFIX lib
VERSION ${PROJECT_VERSION}
SOVERSION ${LIBXML_MAJOR_VERSION}
)
diff --git a/encoding.c b/encoding.c
index 52bc15ac..99232887 100644
index 04c24e42..74305989 100644
--- a/encoding.c
+++ b/encoding.c
@@ -45,7 +45,7 @@
Expand All @@ -11,17 +44,3 @@ index 52bc15ac..99232887 100644
/* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */
#define ICU_PIVOT_BUF_SIZE 1024
typedef struct _uconv_t uconv_t;
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index 7cc25b84..107c180b 100644
--- a/win32/Makefile.msvc
+++ b/win32/Makefile.msvc
@@ -71,7 +71,7 @@ LIBS = $(LIBS) iconv.lib
!if "$(STATIC)" == "1"
LIBS = $(LIBS) advapi32.lib sicuuc.lib sicuin.lib sicudt.lib
!else
-LIBS = $(LIBS) icuuc.lib icuin.lib icudt.lib
+LIBS = $(LIBS) icu.lib
!endif
!endif
!if "$(WITH_ZLIB)" == "1"

42 changes: 19 additions & 23 deletions phases/16-libxml2.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,32 @@ for /f "usebackq delims=" %%i in (`call %BASH% '../scripts/get-latest-github-rel
:: load environment and prepare project
call "%~dp0\..\scripts\common.bat" prepare_project || exit /b 1

cd "%SRCROOT%\%PROJECT%" || exit \b 1
cd "win32" || exit /b 1
set BUILD_DIR="%SRCROOT%\%PROJECT%\build-%ARCH%-%BUILD_TYPE%"
if exist "%BUILD_DIR%" (rmdir /S /Q "%BUILD_DIR%" || exit /b 1)
mkdir "%BUILD_DIR%" || exit /b 1
cd "%BUILD_DIR%" || exit /b 1

SET UM_INCLUDE_DIR="%WindowsSdkDir%include\%WindowsSdkVersion%um"

echo.
echo ### Running configure
set CONFIGURE_OPTS=
if "%BUILD_TYPE%" == "Debug" (
set "CONFIGURE_OPTS=cruntime=/MDd debug=yes"
)
cscript configure.js ^
compiler=msvc ^
icu=yes xml_debug=no ^
%CONFIGURE_OPTS% ^
"prefix=%INSTALL_PREFIX%" ^
"include=%INSTALL_PREFIX%\include" ^
"lib=%INSTALL_PREFIX%\lib" ^
"sodir=%INSTALL_PREFIX%\lib" ^
echo ### Running cmake
cmake .. %CMAKE_OPTIONS% ^
-D BUILD_SHARED_LIBS=NO ^
-D LIBXML2_WITH_LZMA=NO ^
-D LIBXML2_WITH_PYTHON=NO ^
-D LIBXML2_WITH_ZLIB=NO ^
-D LIBXML2_WITH_TESTS=NO ^
-D LIBXML2_WITH_PROGRAMS=NO ^
-D LIBXML2_WITH_ICU=YES ^
-D ICU_INCLUDE_DIR=%UM_INCLUDE_DIR% ^
|| exit /b 1

echo.
echo ### Building
:: we only build the static library
nmake /f Makefile.msvc libxmla || exit /b 1
ninja || exit /b 1

echo.
echo ### Installing
:: rename libxml2_a.lib to xml2.lib to allow linking using -lxml2
:: (the wildcard suffix is required to suppress the "file or directory" prompt)
xcopy /Y /F "bin.msvc\libxml2_a.lib" "%INSTALL_PREFIX%\lib\xml2.lib*" || exit /b 1
xcopy /Y /F "%SRCROOT%\%PROJECT%\include\libxml\*.h" "%INSTALL_PREFIX%\include\libxml\" || exit /b 1

:: write pkgconfig file
call "%~dp0\..\scripts\common.bat" write_pkgconfig libxml-2.0 %TAG% -DLIBXML_STATIC -lxml2 -licu || exit /b 1
:: libxml2-export.cmake is generated while installing libxml2
ninja install || exit /b 1
1 change: 1 addition & 0 deletions phases/17-libxslt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cscript configure.js ^
%CONFIGURE_OPTS% ^
"prefix=%INSTALL_PREFIX%" ^
"include=%INSTALL_PREFIX%\include" ^
"include=%INSTALL_PREFIX%\include\libxml2" ^
"lib=%INSTALL_PREFIX%\lib" ^
"sodir=%INSTALL_PREFIX%\lib" ^
|| exit /b 1
Expand Down

0 comments on commit 393e6a3

Please sign in to comment.