diff options
Diffstat (limited to 'vcpkg/ports/xmlsec')
| -rw-r--r-- | vcpkg/ports/xmlsec/CMakeLists.txt | 176 | ||||
| -rw-r--r-- | vcpkg/ports/xmlsec/pkgconfig_fixes.patch | 21 | ||||
| -rw-r--r-- | vcpkg/ports/xmlsec/portfile.cmake | 36 | ||||
| -rw-r--r-- | vcpkg/ports/xmlsec/unofficial-xmlsec-config.cmake | 4 | ||||
| -rw-r--r-- | vcpkg/ports/xmlsec/usage | 17 | ||||
| -rw-r--r-- | vcpkg/ports/xmlsec/vcpkg.json | 39 | ||||
| -rw-r--r-- | vcpkg/ports/xmlsec/xmlsec-config.cmake | 10 |
7 files changed, 303 insertions, 0 deletions
diff --git a/vcpkg/ports/xmlsec/CMakeLists.txt b/vcpkg/ports/xmlsec/CMakeLists.txt new file mode 100644 index 0000000..60ccc54 --- /dev/null +++ b/vcpkg/ports/xmlsec/CMakeLists.txt @@ -0,0 +1,176 @@ +cmake_minimum_required (VERSION 3.8) +project (xmlsec1 C CXX) # CXX needed when libxml2 is built with icu + +include(CMakeDependentOption) + +option(INSTALL_HEADERS "Install headers" ON) +cmake_dependent_option(BUILD_WITH_DYNAMIC_LOADING "Enable dynamic loading of xmlsec-crypto libraries" OFF BUILD_SHARED_LIBS OFF) +option(BUILD_WITH_TOOLS "Build tools" ON) + +find_package(LibXml2 REQUIRED) +find_package(OpenSSL REQUIRED) + +FILE(GLOB SOURCESXMLSEC + src/*.c +) + +FILE(GLOB SOURCESXMLSECOPENSSL + src/openssl/*.c + src/strings.c +) + +message(STATUS "Reading version info from configure.ac") + +file(STRINGS "configure.ac" + _xmlsec_version_defines REGEX "XMLSEC_VERSION_(MAJOR|MINOR|SUBMINOR)=([0-9]+)$") + +foreach(ver ${_xmlsec_version_defines}) + if(ver MATCHES "XMLSEC_VERSION_(MAJOR|MINOR|SUBMINOR)=([0-9]+)$") + set(XMLSEC_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") + endif() +endforeach() + +set(XMLSEC_VERSION ${XMLSEC_VERSION_MAJOR}.${XMLSEC_VERSION_MINOR}.${XMLSEC_VERSION_SUBMINOR}) +math(EXPR XMLSEC_VERSION_INFO_NUMBER "${XMLSEC_VERSION_MAJOR} + ${XMLSEC_VERSION_MINOR}") +set(XMLSEC_VERSION_INFO ${XMLSEC_VERSION_INFO_NUMBER}:${XMLSEC_VERSION_SUBMINOR}:${XMLSEC_VERSION_MINOR}) + +message(STATUS "XMLSEC_VERSION: ${XMLSEC_VERSION}") +message(STATUS "XMLSEC_VERSION_MAJOR: ${XMLSEC_VERSION_MAJOR}") +message(STATUS "XMLSEC_VERSION_MINOR: ${XMLSEC_VERSION_MINOR}") +message(STATUS "XMLSEC_VERSION_SUBMINOR: ${XMLSEC_VERSION_SUBMINOR}") +message(STATUS "XMLSEC_VERSION_INFO: ${XMLSEC_VERSION_INFO}") + +message(STATUS "Generating version.h") +configure_file(include/xmlsec/version.h.in include/xmlsec/version.h) +# Generate xmlexports with fixed definition of XMLSEC_STATIC +file(READ include/xmlsec/exports.h EXPORTS_H) +if(BUILD_SHARED_LIBS) + string(REPLACE "!defined(XMLSEC_STATIC)" "1" EXPORTS_H "${EXPORTS_H}") +else() + string(REPLACE "!defined(XMLSEC_STATIC)" "0" EXPORTS_H "${EXPORTS_H}") +endif() +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/include/xmlsec/exports.h "${EXPORTS_H}") + +if(MSVC) + add_compile_options(/wd4130 /wd4127 /wd4152) +endif() + +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") + +add_library(xmlsec1 ${SOURCESXMLSEC}) +add_library(xmlsec1-openssl ${SOURCESXMLSECOPENSSL}) + +target_include_directories(xmlsec1 PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:include> +) +target_link_libraries(xmlsec1 PUBLIC LibXml2::LibXml2) +target_link_libraries(xmlsec1-openssl PUBLIC xmlsec1 OpenSSL::Crypto) + +add_compile_definitions( + inline=__inline + PACKAGE="xmlsec1" + HAVE_STDIO_H + HAVE_STDLIB_H + HAVE_STRING_H + HAVE_CTYPE_H + HAVE_MALLOC_H + HAVE_MEMORY_H + XMLSEC_DEFAULT_CRYPTO="openssl" + UNICODE + _UNICODE + _MBCS + _REENTRANT + WIN32_LEAN_AND_MEAN +) + +set_target_properties(xmlsec1 xmlsec1-openssl PROPERTIES VERSION ${XMLSEC_VERSION_MAJOR}.${XMLSEC_VERSION_MINOR}) + +set(XMLSEC_CORE_CFLAGS XMLSEC_NO_XSLT XMLSEC_CRYPTO_OPENSSL XMLSEC_NO_FTP XMLSEC_NO_HTTP) +if(NOT BUILD_SHARED_LIBS) + list(APPEND XMLSEC_CORE_CFLAGS XMLSEC_STATIC) +endif() +set(XMLSEC_OPENSSL_CFLAGS XMLSEC_NO_MD5 XMLSEC_NO_RIPEMD160 XMLSEC_NO_GOST XMLSEC_NO_GOST2012) + +if(BUILD_WITH_DYNAMIC_LOADING) + if(NOT WIN32) + find_path(LTDL_INCLUDE_DIR NAMES ltdl.h) + find_library(LTDL_LIBRARY NAMES ltdl) + + if(NOT LTDL_INCLUDE_DIR OR NOT LTDL_LIBRARY) + message(FATAL_ERROR "libltdl not found (headers or library missing)") + endif() + + target_include_directories(xmlsec1 PRIVATE ${LTDL_INCLUDE_DIR}) + target_link_libraries(xmlsec1 PRIVATE ${LTDL_LIBRARY}) + endif() + list(APPEND XMLSEC_CORE_CFLAGS XMLSEC_CRYPTO_DYNAMIC_LOADING) +else() + list(APPEND XMLSEC_CORE_CFLAGS XMLSEC_NO_CRYPTO_DYNAMIC_LOADING) +endif() + +target_compile_definitions(xmlsec1 + PRIVATE $<IF:$<PLATFORM_ID:Windows>,XMLSEC_DL_WIN32,XMLSEC_DL_LIBLTDL> + PUBLIC ${XMLSEC_CORE_CFLAGS} +) +target_compile_definitions(xmlsec1-openssl PUBLIC ${XMLSEC_OPENSSL_CFLAGS}) + +install(TARGETS xmlsec1 xmlsec1-openssl + EXPORT unofficial-xmlsec-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) + +install(EXPORT unofficial-xmlsec-targets + NAMESPACE unofficial::xmlsec:: + DESTINATION share/unofficial-xmlsec +) + +if(INSTALL_HEADERS) + install(DIRECTORY include/xmlsec DESTINATION include FILES_MATCHING PATTERN "*.h") + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/xmlsec DESTINATION include) +endif() + +if(BUILD_WITH_TOOLS) + # xmlsec application + add_executable(xmlsec + apps/crypto.c + apps/cmdline.c + apps/xmlsec.c) + + if(WIN32) + target_link_libraries(xmlsec PRIVATE crypt32.lib) + endif() + + target_link_libraries(xmlsec PRIVATE xmlsec1-openssl) + + if(NOT BUILD_SHARED_LIBS) + # needed when libxml2 is built with icu + find_package(Threads REQUIRED) + target_link_libraries(xmlsec PRIVATE Threads::Threads) + endif() + install(TARGETS xmlsec DESTINATION tools/xmlsec) +endif() + +message(STATUS "Generating pkgconfig files") + +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix ${prefix}) +set(libdir ${prefix}/${CMAKE_INSTALL_LIBDIR}) +set(includedir ${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) +set(VERSION ${XMLSEC_VERSION}) +set(LIBXML_MIN_VERSION ${LIBXML2_VERSION_STRING}) +list(JOIN XMLSEC_CORE_CFLAGS " -D" XMLSEC_CORE_CFLAGS) +set(XMLSEC_CORE_CFLAGS "-D${XMLSEC_CORE_CFLAGS} -I\${includedir}/xmlsec1") +set(XMLSEC_CORE_LIBS "-lxmlsec1") +list(JOIN XMLSEC_OPENSSL_CFLAGS " -D" XMLSEC_OPENSSL_CFLAGS) +set(XMLSEC_OPENSSL_CFLAGS "${XMLSEC_CORE_CFLAGS} -D${XMLSEC_OPENSSL_CFLAGS}") +set(XMLSEC_OPENSSL_LIBS "-L\${libdir} -lxmlsec1-openssl ${XMLSEC_CORE_LIBS} -lcrypto") + +configure_file(${PROJECT_SOURCE_DIR}/xmlsec.pc.in ${PROJECT_BINARY_DIR}/xmlsec1.pc @ONLY) +configure_file(${PROJECT_SOURCE_DIR}/xmlsec-openssl.pc.in ${PROJECT_BINARY_DIR}/xmlsec1-openssl.pc @ONLY) +install(FILES ${PROJECT_BINARY_DIR}/xmlsec1.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/) +install(FILES ${PROJECT_BINARY_DIR}/xmlsec1-openssl.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/) diff --git a/vcpkg/ports/xmlsec/pkgconfig_fixes.patch b/vcpkg/ports/xmlsec/pkgconfig_fixes.patch new file mode 100644 index 0000000..6e5196f --- /dev/null +++ b/vcpkg/ports/xmlsec/pkgconfig_fixes.patch @@ -0,0 +1,21 @@ +diff --git a/xmlsec-openssl.pc.in b/xmlsec-openssl.pc.in +index af3ae29..40635cf 100644 +--- a/xmlsec-openssl.pc.in ++++ b/xmlsec-openssl.pc.in +@@ -8,5 +8,4 @@ Version: @VERSION@ + Description: XML Security Library implements XML Signature and XML Encryption standards + Requires: libxml-2.0 >= @LIBXML_MIN_VERSION@ @LIBXSLT_PC_FILE_COND@ + Cflags: @XMLSEC_OPENSSL_CFLAGS@ +-Cflags.private: -DXMLSEC_STATIC + Libs: @XMLSEC_OPENSSL_LIBS@ +diff --git a/xmlsec.pc.in b/xmlsec.pc.in +index 2d5a3ad..0f72d68 100644 +--- a/xmlsec.pc.in ++++ b/xmlsec.pc.in +@@ -7,5 +7,5 @@ Name: xmlsec1 + Version: @VERSION@ + Description: XML Security Library implements XML Signature and XML Encryption standards + Requires: libxml-2.0 >= @LIBXML_MIN_VERSION@ @LIBXSLT_PC_FILE_COND@ +-Cflags: -DXMLSEC_CRYPTO_DYNAMIC_LOADING=1 @XMLSEC_CORE_CFLAGS@ ++Cflags: @XMLSEC_CORE_CFLAGS@ + Libs: -L${libdir} @XMLSEC_CORE_LIBS@ diff --git a/vcpkg/ports/xmlsec/portfile.cmake b/vcpkg/ports/xmlsec/portfile.cmake new file mode 100644 index 0000000..be27419 --- /dev/null +++ b/vcpkg/ports/xmlsec/portfile.cmake @@ -0,0 +1,36 @@ +string(REPLACE "." "_" release_tag "xmlsec_${VERSION}") +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO lsh123/xmlsec + REF "${release_tag}" + SHA512 1c5f0c0dc667cabaedce9e26b988a82a19677647c530ea16959a499472eb1de2338a0b3b0d74a6ff5320efd65c6eae55f98919f371a89d0ad40e0253909d4fbe + HEAD_REF master + PATCHES + pkgconfig_fixes.patch +) +file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + "tools" BUILD_WITH_TOOLS + "with-dl" BUILD_WITH_DYNAMIC_LOADING +) +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS ${FEATURE_OPTIONS} + OPTIONS_DEBUG + -DINSTALL_HEADERS=OFF + -DBUILD_WITH_TOOLS=OFF +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-xmlsec) +vcpkg_fixup_pkgconfig() +vcpkg_copy_pdbs() + +# unofficial legacy usage +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/xmlsec-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/unofficial-xmlsec-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/unofficial-xmlsec") +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/Copyright") diff --git a/vcpkg/ports/xmlsec/unofficial-xmlsec-config.cmake b/vcpkg/ports/xmlsec/unofficial-xmlsec-config.cmake new file mode 100644 index 0000000..3a2b0c9 --- /dev/null +++ b/vcpkg/ports/xmlsec/unofficial-xmlsec-config.cmake @@ -0,0 +1,4 @@ +include(CMakeFindDependencyMacro) +find_dependency(LibXml2) +find_dependency(OpenSSL) +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-xmlsec-targets.cmake") diff --git a/vcpkg/ports/xmlsec/usage b/vcpkg/ports/xmlsec/usage new file mode 100644 index 0000000..2192f4a --- /dev/null +++ b/vcpkg/ports/xmlsec/usage @@ -0,0 +1,17 @@ +xmlsec can be imported via CMake FindPkgConfig module: + + find_package(PkgConfig) + # For dynamic loading of xmlsec crypto library + pkg_check_modules(XMLSEC1 REQUIRED IMPORTED_TARGET xmlsec1) + target_link_libraries(main PRIVATE PkgConfig::XMLSEC1) + # For selecting the openssl crypto engine at link time + pkg_check_modules(XMLSEC1_OPENSSL REQUIRED IMPORTED_TARGET xmlsec1-openssl) + target_link_libraries(main PRIVATE PkgConfig::XMLSEC1_OPENSSL) + +vcpkg provides proprietary CMake targets: + + find_package(unofficial-xmlsec CONFIG REQUIRED) + # For dynamic loading of xmlsec crypto library + target_link_libraries(main PRIVATE unofficial::xmlsec::xmlsec1) + # For selecting the openssl crypto engine at link time + target_link_libraries(main PRIVATE unofficial::xmlsec::xmlsec1-openssl) diff --git a/vcpkg/ports/xmlsec/vcpkg.json b/vcpkg/ports/xmlsec/vcpkg.json new file mode 100644 index 0000000..e8073a3 --- /dev/null +++ b/vcpkg/ports/xmlsec/vcpkg.json @@ -0,0 +1,39 @@ +{ + "name": "xmlsec", + "version": "1.3.9", + "port-version": 1, + "description": "XML Security Library is a C library based on LibXML2. The library supports major XML security standards.", + "homepage": "https://www.aleksey.com/xmlsec/", + "license": "X11 AND MPL-1.1", + "supports": "!xbox & !uwp", + "dependencies": [ + { + "name": "libxml2", + "default-features": false + }, + "openssl", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "tools": { + "description": "Build tools" + }, + "with-dl": { + "description": "Build with dynamic loading of xmlsec-crypto libraries", + "supports": "!static", + "dependencies": [ + { + "name": "libltdl", + "platform": "!windows" + } + ] + } + } +} diff --git a/vcpkg/ports/xmlsec/xmlsec-config.cmake b/vcpkg/ports/xmlsec/xmlsec-config.cmake new file mode 100644 index 0000000..5c8b6f3 --- /dev/null +++ b/vcpkg/ports/xmlsec/xmlsec-config.cmake @@ -0,0 +1,10 @@ +file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage) +message(WARNING "find_package(xmlsec) is deprecated.\n${usage}") +include(CMakeFindDependencyMacro) +find_dependency(unofficial-xmlsec CONFIG REQUIRED) +if(NOT TARGET xmlsec1) + add_library(xmlsec1 ALIAS unofficial::xmlsec::xmlsec1) +endif() +if(NOT TARGET xmlsec1-openssl) + add_library(xmlsec1-openssl ALIAS unofficial::xmlsec::xmlsec1-openssl) +endif() |