2023-04-29 20:43:54 +02:00
cmake_minimum_required ( VERSION 3.18 )
2020-04-21 00:53:12 +02:00
2021-06-04 09:57:46 +12:00
file ( STRINGS "configure.ac" CONFIGURE_AC_LINES )
foreach ( line ${ CONFIGURE_AC_LINES } )
2024-04-20 20:54:41 +02:00
if ( line MATCHES [[^m4_define\(\[(MAJOR_VERSION|MINOR_VERSION|MICRO_VERSION ) \ ] , [ \ t ] * ( [ 0 - 9 ] + ) \ ) $ ] ] )
set ( LIBXML_ ${ CMAKE_MATCH_1 } ${ CMAKE_MATCH_2 } )
elseif ( line MATCHES "^(LIBXML_MAJOR_VERSION|LIBXML_MINOR_VERSION|LIBXML_MICRO_VERSION)=([0-9]+)$" )
set ( ${ CMAKE_MATCH_1 } ${ CMAKE_MATCH_2 } )
endif ( )
2021-06-04 09:57:46 +12:00
endforeach ( )
set ( VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}" )
project ( libxml2 VERSION ${ VERSION } LANGUAGES C )
2020-04-21 00:53:12 +02:00
include ( CheckCSourceCompiles )
include ( CheckFunctionExists )
include ( CheckIncludeFiles )
include ( CheckLibraryExists )
2023-04-29 20:43:54 +02:00
include ( CheckLinkerFlag )
2020-04-21 00:53:12 +02:00
include ( CheckStructHasMember )
include ( CheckSymbolExists )
include ( CMakePackageConfigHelpers )
2023-09-03 22:14:01 +01:00
include ( FindPkgConfig )
2020-04-21 00:53:12 +02:00
include ( GNUInstallDirs )
option ( BUILD_SHARED_LIBS "Build shared libraries" ON )
set ( LIBXML2_WITH_AUTOMATA ON )
option ( LIBXML2_WITH_C14N "Add the Canonicalization support" ON )
option ( LIBXML2_WITH_CATALOG "Add the Catalog support" ON )
option ( LIBXML2_WITH_DEBUG "Add the debugging module" ON )
set ( LIBXML2_WITH_EXPR ON )
option ( LIBXML2_WITH_HTML "Add the HTML support" ON )
2024-05-20 23:51:01 +02:00
option ( LIBXML2_WITH_HTTP "Add the HTTP support" OFF )
2020-11-25 18:01:51 +01:00
option ( LIBXML2_WITH_ICONV "Add ICONV support" ON )
option ( LIBXML2_WITH_ICU "Add ICU support" OFF )
2020-04-21 00:53:12 +02:00
option ( LIBXML2_WITH_ISO8859X "Add ISO8859X support if no iconv" ON )
2022-04-13 16:46:58 +02:00
option ( LIBXML2_WITH_LEGACY "Add deprecated APIs for compatibility" OFF )
2024-04-02 12:56:11 +02:00
option ( LIBXML2_WITH_LZMA "Use liblzma" OFF )
2020-04-21 00:53:12 +02:00
option ( LIBXML2_WITH_MODULES "Add the dynamic modules support" ON )
option ( LIBXML2_WITH_OUTPUT "Add the serialization support" ON )
option ( LIBXML2_WITH_PATTERN "Add the xmlPattern selection interface" ON )
option ( LIBXML2_WITH_PROGRAMS "Build programs" ON )
option ( LIBXML2_WITH_PUSH "Add the PUSH parser interfaces" ON )
2020-11-25 18:01:51 +01:00
option ( LIBXML2_WITH_PYTHON "Build Python bindings" ON )
2020-04-21 00:53:12 +02:00
option ( LIBXML2_WITH_READER "Add the xmlReader parsing interface" ON )
option ( LIBXML2_WITH_REGEXPS "Add Regular Expressions support" ON )
option ( LIBXML2_WITH_SAX1 "Add the older SAX1 interface" ON )
option ( LIBXML2_WITH_SCHEMAS "Add Relax-NG and Schemas support" ON )
option ( LIBXML2_WITH_SCHEMATRON "Add Schematron support" ON )
option ( LIBXML2_WITH_TESTS "Build tests" ON )
2020-11-25 18:01:51 +01:00
option ( LIBXML2_WITH_THREADS "Add multithread support" ON )
2020-04-21 00:53:12 +02:00
option ( LIBXML2_WITH_THREAD_ALLOC "Add per-thread memory" OFF )
2023-12-05 20:40:20 +01:00
option ( LIBXML2_WITH_TLS "Enable thread-local storage" OFF )
2020-04-21 00:53:12 +02:00
set ( LIBXML2_WITH_UNICODE ON )
option ( LIBXML2_WITH_VALID "Add the DTD validation support" ON )
option ( LIBXML2_WITH_WRITER "Add the xmlWriter saving interface" ON )
option ( LIBXML2_WITH_XINCLUDE "Add the XInclude support" ON )
option ( LIBXML2_WITH_XPATH "Add the XPATH support" ON )
option ( LIBXML2_WITH_XPTR "Add the XPointer support" ON )
2024-04-02 12:56:11 +02:00
option ( LIBXML2_WITH_ZLIB "Use libz" OFF )
2020-11-25 18:01:51 +01:00
set ( LIBXML2_XMLCONF_WORKING_DIR ${ CMAKE_CURRENT_BINARY_DIR } CACHE PATH "Working directory for XML Conformance Test Suite" )
2020-04-21 00:53:12 +02:00
2020-11-25 18:01:51 +01:00
if ( LIBXML2_WITH_PYTHON )
2024-04-20 20:54:41 +02:00
find_package ( Python COMPONENTS Interpreter Development REQUIRED )
#set(LIBXML2_PYTHON_INSTALL_DIR ${Python_SITEARCH} CACHE PATH "Python bindings install directory")
set ( LIBXML2_PYTHON_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/python"
C A C H E P A T H " P y t h o n b i n d i n g s i n s t a l l d i r e c t o r y " )
2020-11-25 18:01:51 +01:00
endif ( )
2024-06-15 22:53:55 +02:00
foreach ( VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_EXPR WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB )
2024-04-20 20:54:41 +02:00
if ( LIBXML2_ ${ VARIABLE } )
set ( ${ VARIABLE } 1 )
else ( )
set ( ${ VARIABLE } 0 )
endif ( )
2020-04-21 00:53:12 +02:00
endforeach ( )
2022-04-07 02:05:41 +02:00
set ( LIBXML_VERSION ${ VERSION } )
2021-02-22 21:11:00 +01:00
set ( LIBXML_VERSION_EXTRA "" )
2022-04-07 02:05:41 +02:00
math ( EXPR LIBXML_VERSION_NUMBER "
$ { L I B X M L _ M A J O R _ V E R S I O N } * 1 0 0 0 0 +
$ { L I B X M L _ M I N O R _ V E R S I O N } * 1 0 0 +
$ { L I B X M L _ M I C R O _ V E R S I O N }
" )
2021-02-22 21:11:00 +01:00
2020-04-21 00:53:12 +02:00
set ( MODULE_EXTENSION "${CMAKE_SHARED_LIBRARY_SUFFIX}" )
set ( PACKAGE "libxml2" )
set ( PACKAGE_NAME "libxml2" )
set ( PACKAGE_STRING "libxml2 ${VERSION}" )
set ( PACKAGE_TARNAME "libxml2" )
2022-02-13 22:52:53 +01:00
set ( PACKAGE_URL "https://gitlab.gnome.org/GNOME/libxml2" )
2020-04-21 00:53:12 +02:00
set ( PACKAGE_VERSION ${ VERSION } )
2023-09-10 13:00:31 +01:00
if ( LIBXML2_WITH_ICONV )
2024-04-20 20:54:41 +02:00
find_package ( Iconv REQUIRED )
2023-09-10 13:00:31 +01:00
endif ( )
if ( LIBXML2_WITH_ICU )
2024-04-20 20:54:41 +02:00
find_package ( ICU REQUIRED COMPONENTS data i18n uc )
2023-09-10 13:00:31 +01:00
endif ( )
if ( LIBXML2_WITH_LZMA )
2024-04-20 20:54:41 +02:00
find_package ( LibLZMA REQUIRED )
2023-09-10 13:00:31 +01:00
endif ( )
2023-09-10 13:07:49 +01:00
if ( LIBXML2_WITH_THREADS )
2024-04-20 20:54:41 +02:00
find_package ( Threads REQUIRED )
set ( THREAD_LIBS ${ CMAKE_THREAD_LIBS_INIT } )
list ( APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads )
2023-09-10 13:07:49 +01:00
endif ( )
2023-09-10 13:00:31 +01:00
if ( LIBXML2_WITH_ZLIB )
2024-04-20 20:54:41 +02:00
find_package ( ZLIB REQUIRED )
2023-09-10 13:00:31 +01:00
endif ( )
2022-04-20 13:36:02 +02:00
if ( NOT MSVC )
2024-04-20 20:54:41 +02:00
check_c_source_compiles ( "
v o i d __attribute__ ( ( destructor ) )
f ( void ) { }
i n t main ( void ) { r e t u r n 0 ; }
" H A V E _ A T T R I B U T E _ D E S T R U C T O R )
if ( HAVE_ATTRIBUTE_DESTRUCTOR )
set ( ATTRIBUTE_DESTRUCTOR "__attribute__((destructor))" )
endif ( )
check_include_files ( arpa/inet.h HAVE_ARPA_INET_H )
check_function_exists ( class HAVE_CLASS )
check_include_files ( dlfcn.h HAVE_DLFCN_H )
check_library_exists ( dl dlopen "" HAVE_DLOPEN )
check_include_files ( dl.h HAVE_DL_H )
check_function_exists ( getentropy HAVE_GETENTROPY )
check_library_exists ( history append_history "" HAVE_LIBHISTORY )
check_library_exists ( readline readline "" HAVE_LIBREADLINE )
check_function_exists ( mmap HAVE_MMAP )
check_function_exists ( munmap HAVE_MUNMAP )
check_include_files ( netdb.h HAVE_NETDB_H )
check_include_files ( netinet/in.h HAVE_NETINET_IN_H )
check_include_files ( poll.h HAVE_POLL_H )
check_library_exists ( dld shl_load "" HAVE_SHLLOAD )
check_include_files ( stdint.h HAVE_STDINT_H )
check_include_files ( sys/mman.h HAVE_SYS_MMAN_H )
check_include_files ( sys/random.h HAVE_SYS_RANDOM_H )
check_include_files ( sys/select.h HAVE_SYS_SELECT_H )
check_include_files ( sys/socket.h HAVE_SYS_SOCKET_H )
2020-04-21 00:53:12 +02:00
endif ( )
2023-12-05 20:40:20 +01:00
if ( LIBXML2_WITH_TLS )
2024-04-20 20:54:41 +02:00
check_c_source_compiles (
" _ T h r e a d _ l o c a l i n t v ; i n t main ( ) { r e t u r n 0 ; } "
X M L _ T H R E A D _ L O C A L _ C 1 1
)
if ( XML_THREAD_LOCAL_C11 )
set ( XML_THREAD_LOCAL "_Thread_local" )
else ( )
check_c_source_compiles (
" _ _ t h r e a d i n t v ; i n t main ( ) { r e t u r n 0 ; } "
X M L _ T H R E A D _ L O C A L _ T H R E A D
)
if ( XML_THREAD_LOCAL_THREAD )
set ( XML_THREAD_LOCAL "__thread" )
else ( )
check_c_source_compiles (
" __declspec ( thread ) i n t v ; i n t main ( ) { r e t u r n 0 ; } "
X M L _ T H R E A D _ L O C A L _ D E C L S P E C
)
if ( XML_THREAD_LOCAL_DECLSPEC )
set ( XML_THREAD_LOCAL "__declspec(thread)" )
endif ( )
endif ( )
endif ( )
2023-09-01 14:52:11 +02:00
endif ( )
2020-04-21 21:04:23 +02:00
set (
2024-04-20 20:54:41 +02:00
L I B X M L 2 _ H D R S
i n c l u d e / l i b x m l / c 1 4 n . h
i n c l u d e / l i b x m l / c a t a l o g . h
i n c l u d e / l i b x m l / c h v a l i d . h
i n c l u d e / l i b x m l / d e b u g X M L . h
i n c l u d e / l i b x m l / d i c t . h
i n c l u d e / l i b x m l / e n c o d i n g . h
i n c l u d e / l i b x m l / e n t i t i e s . h
i n c l u d e / l i b x m l / g l o b a l s . h
i n c l u d e / l i b x m l / h a s h . h
i n c l u d e / l i b x m l / H T M L p a r s e r . h
i n c l u d e / l i b x m l / H T M L t r e e . h
i n c l u d e / l i b x m l / l i s t . h
i n c l u d e / l i b x m l / n a n o f t p . h
i n c l u d e / l i b x m l / n a n o h t t p . h
i n c l u d e / l i b x m l / p a r s e r . h
i n c l u d e / l i b x m l / p a r s e r I n t e r n a l s . h
i n c l u d e / l i b x m l / p a t t e r n . h
i n c l u d e / l i b x m l / r e l a x n g . h
i n c l u d e / l i b x m l / S A X . h
i n c l u d e / l i b x m l / S A X 2 . h
i n c l u d e / l i b x m l / s c h e m a s I n t e r n a l s . h
i n c l u d e / l i b x m l / s c h e m a t r o n . h
i n c l u d e / l i b x m l / t h r e a d s . h
i n c l u d e / l i b x m l / t r e e . h
i n c l u d e / l i b x m l / u r i . h
i n c l u d e / l i b x m l / v a l i d . h
i n c l u d e / l i b x m l / x i n c l u d e . h
i n c l u d e / l i b x m l / x l i n k . h
i n c l u d e / l i b x m l / x m l I O . h
i n c l u d e / l i b x m l / x m l a u t o m a t a . h
i n c l u d e / l i b x m l / x m l e r r o r . h
i n c l u d e / l i b x m l / x m l e x p o r t s . h
i n c l u d e / l i b x m l / x m l m e m o r y . h
i n c l u d e / l i b x m l / x m l m o d u l e . h
i n c l u d e / l i b x m l / x m l r e a d e r . h
i n c l u d e / l i b x m l / x m l r e g e x p . h
i n c l u d e / l i b x m l / x m l s a v e . h
i n c l u d e / l i b x m l / x m l s c h e m a s . h
i n c l u d e / l i b x m l / x m l s c h e m a s t y p e s . h
i n c l u d e / l i b x m l / x m l s t r i n g . h
i n c l u d e / l i b x m l / x m l u n i c o d e . h
i n c l u d e / l i b x m l / x m l w r i t e r . h
i n c l u d e / l i b x m l / x p a t h . h
i n c l u d e / l i b x m l / x p a t h I n t e r n a l s . h
i n c l u d e / l i b x m l / x p o i n t e r . h
2020-04-21 21:04:23 +02:00
)
2020-04-21 00:53:12 +02:00
set (
2024-04-20 20:54:41 +02:00
L I B X M L 2 _ S R C S
b u f . c
c 1 4 n . c
c a t a l o g . c
c h v a l i d . c
d e b u g X M L . c
d i c t . c
e n c o d i n g . c
e n t i t i e s . c
e r r o r . c
g l o b a l s . c
h a s h . c
H T M L p a r s e r . c
H T M L t r e e . c
l e g a c y . c
l i s t . c
n a n o h t t p . c
p a r s e r . c
p a r s e r I n t e r n a l s . c
p a t t e r n . c
r e l a x n g . c
S A X 2 . c
s c h e m a t r o n . c
t h r e a d s . c
t r e e . c
u r i . c
v a l i d . c
x i n c l u d e . c
x l i n k . c
x m l I O . c
x m l m e m o r y . c
x m l m o d u l e . c
x m l r e a d e r . c
x m l r e g e x p . c
x m l s a v e . c
x m l s c h e m a s . c
x m l s c h e m a s t y p e s . c
x m l s t r i n g . c
x m l u n i c o d e . c
x m l w r i t e r . c
x p a t h . c
x p o i n t e r . c
x z l i b . c
2020-04-21 00:53:12 +02:00
)
if ( WIN32 )
2024-04-20 20:54:41 +02:00
list ( APPEND LIBXML2_SRCS win32/libxml2.rc )
file (
W R I T E
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / r c V e r s i o n . h
" #define LIBXML_MAJOR_VERSION ${LIBXML_MAJOR_VERSION}\n"
" #define LIBXML_MINOR_VERSION ${LIBXML_MINOR_VERSION}\n"
" #define LIBXML_MICRO_VERSION ${LIBXML_MICRO_VERSION}\n"
" #define LIBXML_DOTTED_VERSION \"${VERSION}\"\n"
)
2020-04-21 00:53:12 +02:00
endif ( )
2020-04-21 21:04:23 +02:00
add_library ( LibXml2 ${ LIBXML2_HDRS } ${ LIBXML2_SRCS } )
2021-05-22 14:51:26 +02:00
add_library ( LibXml2::LibXml2 ALIAS LibXml2 )
2020-04-21 00:53:12 +02:00
2022-03-30 00:32:35 +02:00
target_compile_definitions ( LibXml2 PRIVATE SYSCONFDIR= "${CMAKE_INSTALL_FULL_SYSCONFDIR}" )
2020-06-07 16:06:17 +02:00
if ( LIBXML2_WITH_THREADS )
2024-04-20 20:54:41 +02:00
if ( NOT WIN32 )
check_include_files ( pthread.h HAVE_PTHREAD_H )
endif ( )
2020-06-07 16:06:17 +02:00
endif ( )
2020-04-21 00:53:12 +02:00
target_include_directories (
2024-04-20 20:54:41 +02:00
L i b X m l 2
P U B L I C
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } >
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e >
$ < I N S T A L L _ I N T E R F A C E : $ < I N S T A L L _ P R E F I X > / $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } / l i b x m l 2 >
2020-04-21 00:53:12 +02:00
)
2023-02-24 12:45:01 +00:00
if ( LIBXML2_WITH_MODULES )
2024-04-20 20:54:41 +02:00
if ( HAVE_DLOPEN )
target_link_libraries ( LibXml2 PRIVATE dl )
2024-06-21 03:26:54 +02:00
set ( MODULE_LIBS "-ldl" )
2024-04-20 20:54:41 +02:00
endif ( )
if ( HAVE_SHLLOAD )
target_link_libraries ( LibXml2 PRIVATE dld )
2024-06-21 03:26:54 +02:00
set ( MODULE_LIBS "-ldld" )
2024-04-20 20:54:41 +02:00
endif ( )
2020-04-21 00:53:12 +02:00
endif ( )
if ( UNIX )
2024-04-20 20:54:41 +02:00
target_link_libraries ( LibXml2 PRIVATE m )
set ( LIBM "-lm" )
2020-04-21 00:53:12 +02:00
endif ( )
if ( WIN32 )
2024-04-20 20:54:41 +02:00
target_link_libraries ( LibXml2 PRIVATE ws2_32 )
set ( WINSOCK_LIBS "-lws2_32" )
target_link_libraries ( LibXml2 PRIVATE bcrypt )
set ( CRYPTO_LIBS "-lbcrypt" )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_ICONV )
2024-04-20 20:54:41 +02:00
target_link_libraries ( LibXml2 PUBLIC Iconv::Iconv )
if ( NOT Iconv_IS_BUILT_IN )
set ( ICONV_LIBS "-liconv" )
endif ( )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_ICU )
2024-04-20 20:54:41 +02:00
target_link_libraries ( LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc )
if ( WIN32 )
set ( ICU_LDFLAGS "-licudt -licuin -licuuc" )
else ( )
set ( ICU_LDFLAGS "-licudata -licui18n -licuuc" )
endif ( )
list ( APPEND XML_PRIVATE_LIBS "${ICU_LDFLAGS}" )
pkg_check_modules ( ICU_PC IMPORTED_TARGET icu-i18n )
if ( ICU_PC_FOUND )
list ( APPEND XML_PC_REQUIRES icu-i18n )
else ( )
list ( APPEND XML_PC_LIBS "${ICU_LDFLAGS}" )
endif ( )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_LZMA )
2024-04-20 20:54:41 +02:00
target_link_libraries ( LibXml2 PRIVATE LibLZMA::LibLZMA )
set ( LibLZMA_LDFLAGS "-llzma" )
list ( APPEND XML_PRIVATE_LIBS "${LibLZMA_LDFLAGS}" )
pkg_check_modules ( LibLZMA_PC IMPORTED_TARGET liblzma )
if ( LibLZMA_PC_FOUND )
list ( APPEND XML_PC_REQUIRES liblzma )
else ( )
list ( APPEND XML_PC_LIBS "${LibLZMA_LDFLAGS}" )
endif ( )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_THREADS )
2024-04-20 20:54:41 +02:00
target_link_libraries ( LibXml2 PRIVATE Threads::Threads )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_ZLIB )
2024-04-20 20:54:41 +02:00
target_link_libraries ( LibXml2 PRIVATE ZLIB::ZLIB )
set ( ZLIB_LDFLAGS "-lz" )
list ( APPEND XML_PRIVATE_LIBS "${ZLIB_LDFLAGS}" )
pkg_check_modules ( ZLIB_PC IMPORTED_TARGET zlib )
if ( ZLIB_PC_FOUND )
list ( APPEND XML_PC_REQUIRES zlib )
else ( )
list ( APPEND XML_PC_LIBS "${ZLIB_LDFLAGS}" )
endif ( )
2023-09-03 22:14:01 +01:00
endif ( )
if ( CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU" )
2024-04-20 20:54:41 +02:00
# These compiler flags can break the checks above so keep them here.
set ( CMAKE_C_FLAGS " ${ CMAKE_C_FLAGS } -pedantic -Wall -Wextra -Wshadow \
2023-09-25 14:00:48 +02:00
- W p o i n t e r - a r i t h - W c a s t - a l i g n - W w r i t e - s t r i n g s \
2023-09-21 01:38:26 +02:00
- W s t r i c t - p r o t o t y p e s - W m i s s i n g - p r o t o t y p e s \
- W n o - l o n g - l o n g - W n o - f o r m a t - e x t r a - a r g s " )
2023-09-03 22:14:01 +01:00
2024-06-15 22:27:40 +02:00
if ( LIBXML2_WITH_LEGACY AND BUILD_SHARED_LIBS AND UNIX AND NOT APPLE )
2024-04-20 20:54:41 +02:00
check_linker_flag ( C "LINKER:--undefined-version" FLAG_UNDEFINED_VERSION )
if ( FLAG_UNDEFINED_VERSION )
target_link_options ( LibXml2 PRIVATE "LINKER:--undefined-version" )
endif ( )
target_link_options ( LibXml2 PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms" )
endif ( )
2020-04-21 00:53:12 +02:00
endif ( )
set_target_properties (
2024-04-20 20:54:41 +02:00
L i b X m l 2
P R O P E R T I E S
I M P O R T _ P R E F I X l i b
O U T P U T _ N A M E x m l 2
P O S I T I O N _ I N D E P E N D E N T _ C O D E O N
P R E F I X l i b
V E R S I O N $ { P R O J E C T _ V E R S I O N }
S O V E R S I O N $ { L I B X M L _ M A J O R _ V E R S I O N }
2020-04-21 00:53:12 +02:00
)
2021-03-15 13:44:34 -05:00
if ( MSVC )
2024-04-20 20:54:41 +02:00
if ( BUILD_SHARED_LIBS )
set_target_properties (
L i b X m l 2
P R O P E R T I E S
D E B U G _ P O S T F I X d
)
else ( )
set_target_properties (
L i b X m l 2
P R O P E R T I E S
D E B U G _ P O S T F I X s d
M I N S I Z E R E L _ P O S T F I X s
R E L E A S E _ P O S T F I X s
R E L W I T H D E B I N F O _ P O S T F I X s
)
endif ( )
2020-04-21 00:53:12 +02:00
endif ( )
2020-04-21 21:04:23 +02:00
install ( FILES ${ LIBXML2_HDRS } DESTINATION ${ CMAKE_INSTALL_INCLUDEDIR } /libxml2/libxml COMPONENT development )
2020-04-21 00:53:12 +02:00
install (
2024-04-20 20:54:41 +02:00
T A R G E T S L i b X m l 2
E X P O R T L i b X m l 2
A R C H I V E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } C O M P O N E N T d e v e l o p m e n t
L I B R A R Y D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } C O M P O N E N T r u n t i m e N A M E L I N K _ C O M P O N E N T d e v e l o p m e n t
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R } C O M P O N E N T r u n t i m e
2020-04-21 00:53:12 +02:00
)
if ( MSVC AND BUILD_SHARED_LIBS )
2024-04-20 20:54:41 +02:00
install ( FILES $< TARGET_PDB_FILE:LibXml2 > DESTINATION ${ CMAKE_INSTALL_BINDIR } CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_PROGRAMS )
2024-06-16 17:57:12 +02:00
add_executable ( xmllint xmllint.c shell.c )
add_executable ( xmlcatalog xmlcatalog.c )
2024-04-20 20:54:41 +02:00
set (
P R O G R A M S
x m l c a t a l o g
x m l l i n t
)
foreach ( PROGRAM ${ PROGRAMS } )
add_executable ( LibXml2:: ${ PROGRAM } ALIAS ${ PROGRAM } )
target_compile_definitions ( ${ PROGRAM } PRIVATE SYSCONFDIR= "${CMAKE_INSTALL_FULL_SYSCONFDIR}" )
target_link_libraries ( ${ PROGRAM } LibXml2 )
if ( HAVE_LIBHISTORY )
target_link_libraries ( ${ PROGRAM } history )
endif ( )
if ( HAVE_LIBREADLINE )
target_link_libraries ( ${ PROGRAM } readline )
endif ( )
install ( TARGETS ${ PROGRAM } EXPORT LibXml2 RUNTIME DESTINATION ${ CMAKE_INSTALL_BINDIR } COMPONENT programs )
endforeach ( )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_TESTS )
2024-04-20 20:54:41 +02:00
enable_testing ( )
set (
T E S T S
r u n t e s t
r u n x m l c o n f
r u n s u i t e
t e s t a p i
t e s t c h a r
t e s t d i c t
t e s t M o d u l e
t e s t l i m i t s
t e s t p a r s e r
t e s t r e c u r s e
)
foreach ( TEST ${ TESTS } )
add_executable ( ${ TEST } ${ TEST } .c )
target_compile_definitions ( ${ TEST } PRIVATE SYSCONFDIR= "${CMAKE_INSTALL_FULL_SYSCONFDIR}" )
target_link_libraries ( ${ TEST } LibXml2 )
endforeach ( )
if ( Threads_FOUND )
2024-06-16 16:30:54 +02:00
foreach ( TEST runtest )
2024-04-20 20:54:41 +02:00
target_link_libraries ( ${ TEST } Threads::Threads )
endforeach ( )
endif ( )
add_test ( NAME runtest COMMAND runtest --out ${ CMAKE_CURRENT_BINARY_DIR } WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } )
add_test ( NAME runsuite COMMAND runsuite WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } )
if ( EXISTS ${ LIBXML2_XMLCONF_WORKING_DIR } /xmlconf/xmlconf.xml )
add_test ( NAME runxmlconf COMMAND runxmlconf WORKING_DIRECTORY ${ LIBXML2_XMLCONF_WORKING_DIR } )
endif ( )
if ( NOT WIN32 )
add_test ( NAME testapi COMMAND testapi )
endif ( )
add_test ( NAME testchar COMMAND testchar )
add_test ( NAME testdict COMMAND testdict )
add_test ( NAME testparser COMMAND testparser )
add_test ( NAME testrecurse COMMAND testrecurse WORKING_DIRECTORY ${ CMAKE_CURRENT_SOURCE_DIR } )
2020-04-21 00:53:12 +02:00
endif ( )
if ( LIBXML2_WITH_PYTHON )
2024-04-20 20:54:41 +02:00
execute_process (
C O M M A N D
$ { P y t h o n _ E X E C U T A B L E }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / p y t h o n / g e n e r a t o r . p y
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d o c / l i b x m l 2 - a p i . x m l
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / p y t h o n / l i b x m l 2 - p y t h o n - a p i . x m l
W O R K I N G _ D I R E C T O R Y
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
)
file ( READ python/libxml.py LIBXML_PY )
file ( WRITE ${ CMAKE_CURRENT_BINARY_DIR } /libxml2.py.in "${LIBXML_PY}" )
file ( READ ${ CMAKE_CURRENT_BINARY_DIR } /libxml2class.py LIBXML2CLASS_PY )
file ( APPEND ${ CMAKE_CURRENT_BINARY_DIR } /libxml2.py.in "${LIBXML2CLASS_PY}" )
configure_file ( ${ CMAKE_CURRENT_BINARY_DIR } /libxml2.py.in libxml2.py COPYONLY )
add_library (
L i b X m l 2 M o d
l i b x m l 2 - p y . c
l i b x m l 2 - p y . h
p y t h o n / l i b x m l . c
p y t h o n / l i b x m l _ w r a p . h
p y t h o n / t y p e s . c
)
target_include_directories (
L i b X m l 2 M o d
P U B L I C
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / p y t h o n >
)
target_link_libraries ( LibXml2Mod LibXml2 Python::Python )
set_target_properties (
L i b X m l 2 M o d
P R O P E R T I E S
I M P O R T _ P R E F I X l i b
O U T P U T _ N A M E x m l 2 m o d
P R E F I X l i b
V E R S I O N $ { P R O J E C T _ V E R S I O N }
)
if ( WIN32 )
set_target_properties ( LibXml2Mod PROPERTIES SUFFIX ".pyd" )
endif ( )
install (
T A R G E T S L i b X m l 2 M o d
A R C H I V E D E S T I N A T I O N $ { L I B X M L 2 _ P Y T H O N _ I N S T A L L _ D I R } C O M P O N E N T d e v e l o p m e n t
L I B R A R Y D E S T I N A T I O N $ { L I B X M L 2 _ P Y T H O N _ I N S T A L L _ D I R } C O M P O N E N T r u n t i m e N A M E L I N K _ C O M P O N E N T d e v e l o p m e n t
R U N T I M E D E S T I N A T I O N $ { L I B X M L 2 _ P Y T H O N _ I N S T A L L _ D I R } C O M P O N E N T r u n t i m e
)
if ( MSVC AND BUILD_SHARED_LIBS )
install ( FILES $< TARGET_PDB_FILE:LibXml2Mod > DESTINATION ${ LIBXML2_PYTHON_INSTALL_DIR } CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug )
endif ( )
install ( FILES python/drv_libxml2.py DESTINATION ${ LIBXML2_PYTHON_INSTALL_DIR } COMPONENT runtime )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /libxml2.py DESTINATION ${ LIBXML2_PYTHON_INSTALL_DIR } COMPONENT runtime )
2020-04-21 00:53:12 +02:00
endif ( )
2022-04-03 18:30:26 +02:00
install ( FILES doc/xml2-config.1 DESTINATION ${ CMAKE_INSTALL_MANDIR } /man1 COMPONENT documentation )
2020-04-21 00:53:12 +02:00
install ( FILES doc/xmlcatalog.1 DESTINATION ${ CMAKE_INSTALL_MANDIR } /man1 COMPONENT documentation )
install ( FILES doc/xmllint.1 DESTINATION ${ CMAKE_INSTALL_MANDIR } /man1 COMPONENT documentation )
2022-04-08 15:46:26 +02:00
install ( DIRECTORY doc/ DESTINATION ${ CMAKE_INSTALL_DOCDIR } COMPONENT documentation
2024-04-20 20:54:41 +02:00
P A T T E R N " M a k e f i l e . * " E X C L U D E
P A T T E R N " * . 1 " E X C L U D E
P A T T E R N " * . p y " E X C L U D E
P A T T E R N " * . r e s " E X C L U D E
P A T T E R N " * . x m l " E X C L U D E
P A T T E R N " * . x s l " E X C L U D E )
2020-04-21 00:53:12 +02:00
configure_package_config_file (
2024-04-20 20:54:41 +02:00
l i b x m l 2 - c o n f i g . c m a k e . c m a k e . i n l i b x m l 2 - c o n f i g . c m a k e
I N S T A L L _ D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / c m a k e / l i b x m l 2 - $ { P R O J E C T _ V E R S I O N }
2020-04-21 00:53:12 +02:00
)
install (
2024-04-20 20:54:41 +02:00
F I L E S $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i b x m l 2 - c o n f i g . c m a k e
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / c m a k e / l i b x m l 2 - $ { P R O J E C T _ V E R S I O N }
C O M P O N E N T d e v e l o p m e n t
2020-04-21 00:53:12 +02:00
)
write_basic_package_version_file (
2024-04-20 20:54:41 +02:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i b x m l 2 - c o n f i g - v e r s i o n . c m a k e
V E R S I O N $ { P R O J E C T _ V E R S I O N }
C O M P A T I B I L I T Y E x a c t V e r s i o n
2020-04-21 00:53:12 +02:00
)
install (
2024-04-20 20:54:41 +02:00
F I L E S $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i b x m l 2 - c o n f i g - v e r s i o n . c m a k e
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / c m a k e / l i b x m l 2 - $ { P R O J E C T _ V E R S I O N }
C O M P O N E N T d e v e l o p m e n t
2020-04-21 00:53:12 +02:00
)
install (
2024-04-20 20:54:41 +02:00
E X P O R T L i b X m l 2
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R } / c m a k e / l i b x m l 2 - $ { P R O J E C T _ V E R S I O N }
N A M E S P A C E L i b X m l 2 : :
F I L E l i b x m l 2 - e x p o r t . c m a k e
C O M P O N E N T d e v e l o p m e n t
2020-04-21 00:53:12 +02:00
)
2024-06-22 02:34:36 +02:00
configure_file ( config.h.cmake.in config.h )
2020-04-21 00:53:12 +02:00
configure_file ( include/libxml/xmlversion.h.in libxml/xmlversion.h )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /libxml/xmlversion.h DESTINATION ${ CMAKE_INSTALL_INCLUDEDIR } /libxml2/libxml COMPONENT development )
if ( LIBXML2_WITH_PYTHON )
2024-04-20 20:54:41 +02:00
set ( prefix "${CMAKE_INSTALL_PREFIX}" )
configure_file ( python/setup.py.in setup.py @ONLY )
2020-04-21 00:53:12 +02:00
endif ( )
2024-06-21 03:26:54 +02:00
set ( NON_PC_LIBS "${THREAD_LIBS} ${ICONV_LIBS} ${LIBM} ${WINSOCK_LIBS} ${CRYPTO_LIBS} ${MODULE_LIBS}" )
2023-09-03 22:14:01 +01:00
list ( APPEND XML_PC_LIBS "${NON_PC_LIBS}" )
list ( APPEND XML_PRIVATE_LIBS "${NON_PC_LIBS}" )
list ( REMOVE_DUPLICATES XML_PC_LIBS )
list ( REMOVE_DUPLICATES XML_PRIVATE_LIBS )
list ( JOIN XML_PC_REQUIRES " " XML_PC_REQUIRES )
list ( JOIN XML_PC_LIBS " " XML_PC_LIBS )
list ( JOIN XML_PRIVATE_LIBS " " XML_PRIVATE_LIBS )
2020-11-19 22:06:36 +01:00
set ( XML_INCLUDEDIR "-I\${includedir}/libxml2" )
set ( XML_LIBDIR "-L\${libdir}" )
set ( XML_LIBS "-lxml2" )
2023-09-02 17:12:58 +01:00
if ( BUILD_SHARED_LIBS )
2024-04-20 20:54:41 +02:00
set ( XML_PC_PRIVATE ".private" )
set ( XML_PC_LIBS_PRIVATE "
2023-09-02 17:12:58 +01:00
L i b s . p r i v a t e : " )
else ( )
2024-04-20 20:54:41 +02:00
set ( XML_PRIVATE_LIBS_NO_SHARED "${XML_PRIVATE_LIBS}" )
2023-09-02 17:12:58 +01:00
endif ( )
2024-06-21 04:18:04 +02:00
if ( WIN32 )
set ( XML_STATIC_CFLAGS "-DLIBXML_STATIC" )
if ( BUILD_SHARED_LIBS )
set ( XML_PC_CFLAGS_PRIVATE "
C f l a g s . p r i v a t e : " )
else ( )
target_compile_definitions ( LibXml2 PUBLIC LIBXML_STATIC )
set ( XML_CFLAGS "${XML_STATIC_CFLAGS}" )
endif ( )
endif ( )
2020-11-19 22:06:36 +01:00
file ( RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}" )
string ( REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}" )
2022-04-02 22:23:44 +02:00
if ( WIN32 )
2024-04-20 20:54:41 +02:00
set ( prefix "\${pcfiledir}/${PACKAGE_RELATIVE_PATH}" )
2022-04-02 22:23:44 +02:00
else ( )
2024-04-20 20:54:41 +02:00
set ( prefix "${CMAKE_INSTALL_PREFIX}" )
2022-04-02 22:23:44 +02:00
endif ( )
2020-11-19 22:06:36 +01:00
set ( exec_prefix "\${prefix}" )
set ( libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}" )
set ( includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}" )
configure_file ( libxml-2.0.pc.in libxml-2.0.pc @ONLY )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /libxml-2.0.pc DESTINATION ${ CMAKE_INSTALL_LIBDIR } /pkgconfig COMPONENT development )
2022-04-02 22:23:44 +02:00
if ( WIN32 )
2024-04-20 20:54:41 +02:00
set ( prefix "\$(cd \" \$(dirname \"\$0\")\"; pwd -P ) / . . " )
2022-04-02 22:23:44 +02:00
endif ( )
2020-11-19 22:06:36 +01:00
configure_file ( xml2-config.in xml2-config @ONLY )
install ( PROGRAMS ${ CMAKE_CURRENT_BINARY_DIR } /xml2-config DESTINATION ${ CMAKE_INSTALL_BINDIR } COMPONENT development )
set ( XML_INCLUDEDIR "-I${CMAKE_INSTALL_FULL_INCLUDEDIR}/libxml2" )
set ( XML_LIBDIR "-L${CMAKE_INSTALL_FULL_LIBDIR}" )
2020-04-21 00:53:12 +02:00
set ( CPACK_COMPONENT_DEVELOPMENT_DEPENDS runtime )
set ( CPACK_COMPONENT_PROGRAMS_DEPENDS runtime )
set ( CPACK_DEB_COMPONENT_INSTALL ON )
set ( CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "${PACKAGE_TARNAME}" )
set ( CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "${PACKAGE_TARNAME}-dev" )
set ( CPACK_DEBIAN_DEVELOPMENT_PACKAGE_SECTION "libdevel" )
set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE ${ PACKAGE_URL } )
set ( CPACK_DEBIAN_PACKAGE_NAME ${ PACKAGE_TARNAME } )
set ( CPACK_DEBIAN_PACKAGE_SECTION "devel" )
set ( CPACK_DEBIAN_PROGRAMS_PACKAGE_DEPENDS "${PACKAGE_TARNAME}" )
set ( CPACK_DEBIAN_PROGRAMS_PACKAGE_NAME "${PACKAGE_TARNAME}-utils" )
set ( CPACK_DEBIAN_PROGRAMS_PACKAGE_SECTION "utils" )
set ( CPACK_DEBIAN_RUNTIME_PACKAGE_NAME ${ PACKAGE_TARNAME } )
set ( CPACK_DEBIAN_RUNTIME_PACKAGE_RECOMMENDS "${PACKAGE_TARNAME}-utils" )
set ( CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs" )
set ( CPACK_NSIS_PACKAGE_NAME ${ PACKAGE_STRING } )
set ( CPACK_NSIS_URL_INFO_ABOUT ${ PACKAGE_URL } )
set ( CPACK_PACKAGE_DISPLAY_NAME ${ PACKAGE_STRING } )
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "${PACKAGE_TARNAME}-${PACKAGE_VERSION}" )
set ( CPACK_PACKAGE_NAME ${ PACKAGE_TARNAME } )
set ( CPACK_PACKAGE_VERSION ${ PACKAGE_VERSION } )
set ( CPACK_PACKAGE_VERSION_MAJOR ${ LIBXML_MAJOR_VERSION } )
set ( CPACK_PACKAGE_VERSION_MINOR ${ LIBXML_MINOR_VERSION } )
set ( CPACK_PACKAGE_VERSION_PATCH ${ LIBXML_MICRO_VERSION } )
set ( CPACK_RESOURCE_FILE_LICENSE ${ CMAKE_CURRENT_SOURCE_DIR } /Copyright )
set ( CPACK_RPM_COMPONENT_INSTALL ON )
set ( CPACK_RPM_development_PACKAGE_NAME "${PACKAGE_NAME}-devel" )
set ( CPACK_RPM_development_PACKAGE_REQUIRES "${PACKAGE_NAME}" )
set ( CPACK_RPM_PACKAGE_GROUP "Development/Libraries" )
set ( CPACK_RPM_PACKAGE_NAME ${ PACKAGE_TARNAME } )
set ( CPACK_RPM_PACKAGE_URL ${ PACKAGE_URL } )
set ( CPACK_RPM_programs_PACKAGE_NAME "${PACKAGE_NAME}-utils" )
set ( CPACK_RPM_programs_PACKAGE_REQUIRES "${PACKAGE_NAME}" )
set ( CPACK_RPM_runtime_PACKAGE_NAME "${PACKAGE_NAME}" )
set ( CPACK_RPM_runtime_PACKAGE_SUGGESTS "${PACKAGE_NAME}-utils" )
include ( CPack )