@@ -3,8 +3,9 @@ project (xmlsec1 C CXX) # CXX needed when libxml2 is built with icu
33
44include (CMakeDependentOption)
55
6+ option (INSTALL_HEADERS "Install headers" ON )
67cmake_dependent_option(BUILD_WITH_DYNAMIC_LOADING "Enable dynamic loading of xmlsec-crypto libraries" OFF BUILD_SHARED_LIBS OFF )
7- option (INSTALL_HEADERS_TOOLS "Install public header files and tools" ON )
8+ option (BUILD_WITH_TOOLS "Build tools" ON )
89
910find_package (LibXml2 REQUIRED)
1011find_package (OpenSSL REQUIRED)
@@ -18,15 +19,6 @@ FILE(GLOB SOURCESXMLSECOPENSSL
1819 src/strings .c
1920)
2021
21- # Generate xmlexports with fixed definition of XMLSEC_STATIC
22- file (READ include /xmlsec/exports.h EXPORTS_H)
23- if (BUILD_SHARED_LIBS )
24- string (REPLACE "!defined(XMLSEC_STATIC)" "1" EXPORTS_H "${EXPORTS_H} " )
25- else ()
26- string (REPLACE "!defined(XMLSEC_STATIC)" "0" EXPORTS_H "${EXPORTS_H} " )
27- endif ()
28- file (WRITE ${CMAKE_CURRENT_BINARY_DIR} /exports.h "${EXPORTS_H} " )
29-
3022message (STATUS "Reading version info from configure.ac" )
3123
3224file (STRINGS "configure.ac"
@@ -49,8 +41,15 @@ message(STATUS "XMLSEC_VERSION_SUBMINOR: ${XMLSEC_VERSION_SUBMINOR}")
4941message (STATUS "XMLSEC_VERSION_INFO: ${XMLSEC_VERSION_INFO} " )
5042
5143message (STATUS "Generating version.h" )
52-
5344configure_file (include /xmlsec/version .h.in include /xmlsec/version .h)
45+ # Generate xmlexports with fixed definition of XMLSEC_STATIC
46+ file (READ include /xmlsec/exports.h EXPORTS_H)
47+ if (BUILD_SHARED_LIBS )
48+ string (REPLACE "!defined(XMLSEC_STATIC)" "1" EXPORTS_H "${EXPORTS_H} " )
49+ else ()
50+ string (REPLACE "!defined(XMLSEC_STATIC)" "0" EXPORTS_H "${EXPORTS_H} " )
51+ endif ()
52+ file (WRITE ${CMAKE_CURRENT_BINARY_DIR} /include /xmlsec/exports.h "${EXPORTS_H} " )
5453
5554if (MSVC )
5655 add_compile_options (/wd4130 /wd4127 /wd4152)
@@ -71,20 +70,20 @@ target_link_libraries(xmlsec1 PUBLIC LibXml2::LibXml2)
7170target_link_libraries (xmlsec1-openssl PUBLIC xmlsec1 OpenSSL::Crypto)
7271
7372add_compile_definitions (
74- inline=__inline
75- PACKAGE="xmlsec1"
76- HAVE_STDIO_H
77- HAVE_STDLIB_H
78- HAVE_STRING_H
79- HAVE_CTYPE_H
80- HAVE_MALLOC_H
81- HAVE_MEMORY_H
82- XMLSEC_DEFAULT_CRYPTO="openssl"
83- UNICODE
84- _UNICODE
85- _MBCS
86- _REENTRANT
87- WIN32_LEAN_AND_MEAN
73+ inline=__inline
74+ PACKAGE="xmlsec1"
75+ HAVE_STDIO_H
76+ HAVE_STDLIB_H
77+ HAVE_STRING_H
78+ HAVE_CTYPE_H
79+ HAVE_MALLOC_H
80+ HAVE_MEMORY_H
81+ XMLSEC_DEFAULT_CRYPTO="openssl"
82+ UNICODE
83+ _UNICODE
84+ _MBCS
85+ _REENTRANT
86+ WIN32_LEAN_AND_MEAN
8887)
8988
9089set_target_properties (xmlsec1 xmlsec1-openssl PROPERTIES VERSION ${XMLSEC_VERSION_MAJOR} .${XMLSEC_VERSION_MINOR} )
@@ -130,32 +129,23 @@ install(EXPORT unofficial-xmlsec-targets
130129 DESTINATION share/unofficial-xmlsec
131130)
132131
133- if (INSTALL_HEADERS_TOOLS)
134- file (GLOB PUBLIC_HEADERS
135- include /xmlsec/*.h
136- include /xmlsec/openssl/*.h)
137- list (FILTER PUBLIC_HEADERS EXCLUDE REGEX "exports\\ .h$" )
138-
139- foreach (file IN LISTS PUBLIC_HEADERS)
140- get_filename_component (dir ${file} DIRECTORY )
141- file (RELATIVE_PATH rel_dir ${CMAKE_SOURCE_DIR} /xmlsec/${LIB} ${dir} )
142- install (FILES ${file} DESTINATION "include/${rel_dir} " )
143- endforeach ()
144-
145- install (FILES ${CMAKE_CURRENT_BINARY_DIR} /include /xmlsec/version .h DESTINATION "include/xmlsec" )
146- install (FILES ${CMAKE_CURRENT_BINARY_DIR} /exports.h DESTINATION "include/xmlsec" )
132+ if (INSTALL_HEADERS)
133+ install (DIRECTORY include /xmlsec DESTINATION include FILES_MATCHING PATTERN "*.h" )
134+ install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} /include /xmlsec DESTINATION include )
135+ endif ()
147136
148- # xmlsec application
149- add_executable (xmlsec
150- apps/crypto.c
151- apps/cmdline.c
152- apps/xmlsec.c)
137+ if (BUILD_WITH_TOOLS)
138+ # xmlsec application
139+ add_executable (xmlsec
140+ apps/crypto.c
141+ apps/cmdline.c
142+ apps/xmlsec.c)
153143
154- if ( CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" )
155- target_link_libraries (xmlsec PRIVATE crypt32.lib)
156- endif ()
144+ if ( WIN32 )
145+ target_link_libraries (xmlsec PRIVATE crypt32.lib)
146+ endif ()
157147
158- target_link_libraries (xmlsec PRIVATE xmlsec1-openssl)
148+ target_link_libraries (xmlsec PRIVATE xmlsec1-openssl)
159149
160150 if (NOT BUILD_SHARED_LIBS )
161151 # needed when libxml2 is built with icu
0 commit comments