Skip to content

Commit 2d6a6cf

Browse files
authored
[xmlsec] Build tools when requested (microsoft#48241)
Signed-off-by: Raul Metsma <[email protected]>
1 parent b02375d commit 2d6a6cf

File tree

5 files changed

+54
-51
lines changed

5 files changed

+54
-51
lines changed

ports/xmlsec/CMakeLists.txt

Lines changed: 38 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ project (xmlsec1 C CXX) # CXX needed when libxml2 is built with icu
33

44
include(CMakeDependentOption)
55

6+
option(INSTALL_HEADERS "Install headers" ON)
67
cmake_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

910
find_package(LibXml2 REQUIRED)
1011
find_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-
3022
message(STATUS "Reading version info from configure.ac")
3123

3224
file(STRINGS "configure.ac"
@@ -49,8 +41,15 @@ message(STATUS "XMLSEC_VERSION_SUBMINOR: ${XMLSEC_VERSION_SUBMINOR}")
4941
message(STATUS "XMLSEC_VERSION_INFO: ${XMLSEC_VERSION_INFO}")
5042

5143
message(STATUS "Generating version.h")
52-
5344
configure_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

5554
if(MSVC)
5655
add_compile_options(/wd4130 /wd4127 /wd4152)
@@ -71,20 +70,20 @@ target_link_libraries(xmlsec1 PUBLIC LibXml2::LibXml2)
7170
target_link_libraries(xmlsec1-openssl PUBLIC xmlsec1 OpenSSL::Crypto)
7271

7372
add_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

9089
set_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

ports/xmlsec/portfile.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ vcpkg_from_github(
1111
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
1212

1313
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
14-
FEATURES "with-dl" BUILD_WITH_DYNAMIC_LOADING
14+
FEATURES
15+
"tools" BUILD_WITH_TOOLS
16+
"with-dl" BUILD_WITH_DYNAMIC_LOADING
1517
)
1618
vcpkg_cmake_configure(
1719
SOURCE_PATH "${SOURCE_PATH}"
1820
OPTIONS ${FEATURE_OPTIONS}
19-
OPTIONS_DEBUG -DINSTALL_HEADERS_TOOLS=OFF
21+
OPTIONS_DEBUG
22+
-DINSTALL_HEADERS=OFF
23+
-DBUILD_WITH_TOOLS=OFF
2024
)
2125

2226
vcpkg_cmake_install()

ports/xmlsec/vcpkg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "xmlsec",
33
"version": "1.3.9",
4+
"port-version": 1,
45
"description": "XML Security Library is a C library based on LibXML2. The library supports major XML security standards.",
56
"homepage": "https://www.aleksey.com/xmlsec/",
67
"license": "X11 AND MPL-1.1",
@@ -21,6 +22,9 @@
2122
}
2223
],
2324
"features": {
25+
"tools": {
26+
"description": "Build tools"
27+
},
2428
"with-dl": {
2529
"description": "Build with dynamic loading of xmlsec-crypto libraries",
2630
"supports": "!static",

versions/baseline.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10658,7 +10658,7 @@
1065810658
},
1065910659
"xmlsec": {
1066010660
"baseline": "1.3.9",
10661-
"port-version": 0
10661+
"port-version": 1
1066210662
},
1066310663
"xnnpack": {
1066410664
"baseline": "2024-08-20",

versions/x-/xmlsec.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"versions": [
3+
{
4+
"git-tree": "47990f6bfcca4dde5fa2ce5f889ceb6f7ecdebba",
5+
"version": "1.3.9",
6+
"port-version": 1
7+
},
38
{
49
"git-tree": "c00a9209927ca456d9776b7ec175fe8ef83f8d6e",
510
"version": "1.3.9",

0 commit comments

Comments
 (0)