aboutsummaryrefslogtreecommitdiff
path: root/vcpkg-ports/expat
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg-ports/expat')
-rw-r--r--vcpkg-ports/expat/mingw_static_fix.patch11
-rw-r--r--vcpkg-ports/expat/pkgconfig_fix.patch22
-rw-r--r--vcpkg-ports/expat/portfile.cmake49
-rw-r--r--vcpkg-ports/expat/vcpkg-cmake-wrapper.cmake27
-rw-r--r--vcpkg-ports/expat/vcpkg.json18
5 files changed, 127 insertions, 0 deletions
diff --git a/vcpkg-ports/expat/mingw_static_fix.patch b/vcpkg-ports/expat/mingw_static_fix.patch
new file mode 100644
index 00000000..b02634e8
--- /dev/null
+++ b/vcpkg-ports/expat/mingw_static_fix.patch
@@ -0,0 +1,11 @@
+--- a/expat/CMakeLists.txt
++++ b/expat/CMakeLists.txt
+@@ -459,7 +459,7 @@ if(NOT WIN32)
+ endif()
+ endif()
+
+-if(MINGW)
++if(MINGW AND EXPAT_SHARED_LIBS)
+ set_target_properties(expat PROPERTIES SUFFIX "-${LIBCURRENT_MINUS_AGE}.dll")
+ endif()
+
diff --git a/vcpkg-ports/expat/pkgconfig_fix.patch b/vcpkg-ports/expat/pkgconfig_fix.patch
new file mode 100644
index 00000000..40fe9d3c
--- /dev/null
+++ b/vcpkg-ports/expat/pkgconfig_fix.patch
@@ -0,0 +1,22 @@
+--- a/expat/CMakeLists.txt
++++ b/expat/CMakeLists.txt
+@@ -469,7 +469,7 @@ if(WIN32 AND NOT MINGW)
+ # Everything but MSVC is already adding prefix "lib", automatically.
+ # NOTE: "set_property(TARGET expat PROPERTY PREFIX lib)" would only affect *.dll
+ # files but not *.lib files, so we have to rely on property OUTPUT_NAME, instead.
+- # Property CMAKE_*_POSTFIX still applies.
++ # Property EXPAT_*_POSTFIX still applies.
+ set(_EXPAT_OUTPUT_NAME libexpat)
+ set_property(TARGET expat PROPERTY OUTPUT_NAME ${_EXPAT_OUTPUT_NAME})
+ else()
+@@ -520,8 +520,8 @@ if(EXPAT_BUILD_PKGCONFIG)
+ foreach(_build_type ${CMAKE_BUILD_TYPE} Debug Release RelWithDebInfo MinSizeRel)
+ string(TOLOWER "${_build_type}" _build_type_lower)
+ string(TOUPPER "${_build_type}" _build_type_upper)
+- set_property(TARGET expat PROPERTY "pkgconfig_${_build_type_lower}_name" "expat${CMAKE_${_build_type_upper}_POSTFIX}")
+- set_property(TARGET expat PROPERTY "pkgconfig_${_build_type_lower}_output_name" "${_EXPAT_OUTPUT_NAME}${CMAKE_${_build_type_upper}_POSTFIX}")
++ set_property(TARGET expat PROPERTY "pkgconfig_${_build_type_lower}_name" "expat${EXPAT_${_build_type_upper}_POSTFIX}")
++ set_property(TARGET expat PROPERTY "pkgconfig_${_build_type_lower}_output_name" "${_EXPAT_OUTPUT_NAME}${EXPAT_${_build_type_upper}_POSTFIX}")
+ if(_EXPAT_LIBM_FOUND)
+ set_property(TARGET expat PROPERTY "pkgconfig_libm" "-lm")
+ else()
diff --git a/vcpkg-ports/expat/portfile.cmake b/vcpkg-ports/expat/portfile.cmake
new file mode 100644
index 00000000..831599ff
--- /dev/null
+++ b/vcpkg-ports/expat/portfile.cmake
@@ -0,0 +1,49 @@
+file(READ ${CMAKE_CURRENT_LIST_DIR}/vcpkg.json vcpkg_json)
+string(JSON VERSION GET "${vcpkg_json}" "version")
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO libexpat/libexpat
+ REF R_2_4_9
+ SHA512 6bf92516ce2642b2cdcbc586aaac0f706f125394fa428670f9b8b042a1f393e3b9dda1a24e58e6c8ad8b4ff3303cb5a8700628c6c04a881a06251c08be3759d3
+ HEAD_REF master
+ PATCHES
+ "pkgconfig_fix.patch" # https://github.com/libexpat/libexpat/pull/656
+ "mingw_static_fix.patch" # https://github.com/libexpat/libexpat/pull/658
+)
+
+string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" EXPAT_LINKAGE)
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}/expat"
+ OPTIONS
+ -DEXPAT_BUILD_EXAMPLES=OFF
+ -DEXPAT_BUILD_TESTS=OFF
+ -DEXPAT_BUILD_TOOLS=OFF
+ -DEXPAT_BUILD_DOCS=OFF
+ -DEXPAT_SHARED_LIBS=${EXPAT_LINKAGE}
+ -DEXPAT_BUILD_PKGCONFIG=ON
+ -DEXPAT_CHAR_TYPE=wchar_t
+
+)
+
+vcpkg_cmake_install()
+
+vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/expat-${VERSION}")
+vcpkg_fixup_pkgconfig()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/doc")
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/expat_external.h"
+ "! defined(XML_STATIC)"
+ "/* vcpkg static build ! defined(XML_STATIC) */ 0"
+ )
+endif()
+
+vcpkg_copy_pdbs()
+
+file(COPY "${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+file(INSTALL "${SOURCE_PATH}/expat/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
diff --git a/vcpkg-ports/expat/vcpkg-cmake-wrapper.cmake b/vcpkg-ports/expat/vcpkg-cmake-wrapper.cmake
new file mode 100644
index 00000000..01ee1f8e
--- /dev/null
+++ b/vcpkg-ports/expat/vcpkg-cmake-wrapper.cmake
@@ -0,0 +1,27 @@
+include(SelectLibraryConfigurations)
+
+set(EXPATNAMES expat expatw libexpat libexpatw)
+set(DEBUGNAMES)
+foreach(_CRT "" MT MD)
+ foreach(name IN LISTS EXPATNAMES)
+ list(APPEND EXPATNAMES ${name}${_CRT})
+ list(APPEND DEBUGNAMES ${name}d${_CRT})
+ endforeach()
+endforeach()
+
+find_library(EXPAT_LIBRARY_DEBUG NAMES ${DEBUGNAMES} ${EXPATNAMES} NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH)
+find_library(EXPAT_LIBRARY_RELEASE NAMES ${EXPATNAMES} NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH)
+select_library_configurations(EXPAT)
+set(EXPAT_LIBRARY "${EXPAT_LIBRARIES}" CACHE STRING "" FORCE)
+_find_package(${ARGS})
+if(EXPAT_FOUND AND TARGET EXPAT::EXPAT)
+ if(EXPAT_LIBRARY_DEBUG)
+ set_target_properties(EXPAT::EXPAT PROPERTIES IMPORTED_LOCATION_DEBUG "${EXPAT_LIBRARY_DEBUG}")
+ endif()
+ if(EXPAT_LIBRARY_RELEASE)
+ set_target_properties(EXPAT::EXPAT PROPERTIES IMPORTED_LOCATION_RELEASE "${EXPAT_LIBRARY_RELEASE}")
+ endif()
+endif()
+
+unset(EXPATNAMES)
+unset(DEBUGNAMES)
diff --git a/vcpkg-ports/expat/vcpkg.json b/vcpkg-ports/expat/vcpkg.json
new file mode 100644
index 00000000..28501d71
--- /dev/null
+++ b/vcpkg-ports/expat/vcpkg.json
@@ -0,0 +1,18 @@
+{
+ "name": "expat",
+ "version": "2.4.9",
+ "port-version": 1,
+ "description": "XML parser library written in C",
+ "homepage": "https://github.com/libexpat/libexpat",
+ "license": "MIT",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ]
+}