vcpkg/ports/libxml2/vcpkg-cmake-wrapper.cmake
Alexander Neumann e43557e665
[libxml2] Update to 2.9.12 and use upstream CMakeLists.txt (#17945)
* vcpkg_fixup_pkgconfig for allgero5

* version stuff

* Update port

* version stuff

* add missing patch

* version stuff

* deactivate ICU linkage

* add missing 2

* fix include issue in dependend ports.

* fix include dirs in wrapper

* always install wrapper for corrections

* target also needs fixing.

* fix install of wrapper

* version stuff

* libxml define LIBXML_STATIC in the header in static builds

* libxslt build only one type of library to avoid link issues

* version stuff

* add cmake policy

* version stuff

* remove accidental cmake_minimum_required(VERSION)

* version stuff

* version stuff

* add feature tools to build tools

* version stuff

* fix version stuff

* add ws2_32 to the target which was missing.

* version stuff

* add liblzma and zlib to the target

* no need to adjust in config mode

* version stuff

* apply some of the CR suggestions

* version update

* remove icu dependency.

* version stuff

* setting uwp builds of libxml2 to fail. (icu supports:!uwp)

* add !uwp into supports due to getenv call

* version stuff

* baseline stuff

* Restore old version record for libxml2.

Co-authored-by: Robert Schumacher <ras0219@outlook.com>
2021-07-15 17:19:56 -07:00

63 lines
3.6 KiB
CMake

_find_package(${ARGS})
if(LibXml2_FOUND)
list(APPEND LIBXML2_INCLUDE_DIRS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
list(APPEND LIBXML2_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") # This is wrong but downstream doesn't correctly use _DIR vs _DIRS variables
if(TARGET LibXml2::LibXml2)
target_include_directories(LibXml2::LibXml2 INTERFACE "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
endif()
endif()
if(LibXml2_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static" AND NOT ${ARGV0}_CONFIG)
find_package(LibLZMA)
find_package(ZLIB)
include(SelectLibraryConfigurations)
find_library(LIBXML2_LIBRARY_RELEASE NAMES xml2 libxml2 xml2s libxml2s xml2d libxml2d xml2sd libxml2sd NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_INSTALLED_DIR}/debug" NO_DEFAULT_PATH)
find_library(LIBXML2_LIBRARY_DEBUG NAMES xml2 libxml2 xml2s libxml2s NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH)
find_library(ICONV_LIBRARY_DEBUG NAMES iconvd libiconvd iconv libiconv NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_INSTALLED_DIR}/debug" NO_DEFAULT_PATH)
find_library(ICONV_LIBRARY_RELEASE NAMES iconv libiconv NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH)
find_library(ICONV_LIBRARY_RELEASE NAMES iconv libiconv NAMES_PER_DIR PATH_SUFFIXES lib)
find_library(CHARSET_LIBRARY_DEBUG NAMES charsetd libcharsetd charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH)
find_library(CHARSET_LIBRARY_RELEASE NAMES charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH)
find_library(CHARSET_LIBRARY_RELEASE NAMES charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib)
unset(LIBXML2_LIBRARIES)
unset(LIBXML2_LIBRARY CACHE)
select_library_configurations(LIBXML2)
select_library_configurations(ICONV)
select_library_configurations(CHARSET)
list(APPEND LIBXML2_LIBRARIES ${LIBLZMA_LIBRARIES} ${ZLIB_LIBRARIES})
if(TARGET LibXml2::LibXml2 AND LIBXML2_LIBRARY_RELEASE)
set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION_RELEASE "${LIBXML2_LIBRARY_RELEASE}")
endif()
if(TARGET LibXml2::LibXml2 AND LIBXML2_LIBRARY_DEBUG)
set_target_properties(LibXml2::LibXml2 PROPERTIES IMPORTED_LOCATION_DEBUG "${LIBXML2_LIBRARY_DEBUG}")
endif()
cmake_policy(PUSH)
cmake_policy(SET CMP0079 NEW)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
list(APPEND LIBXML2_LIBRARIES m)
if(TARGET LibXml2::LibXml2)
target_link_libraries(LibXml2::LibXml2 INTERFACE "m")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
list(APPEND LIBXML2_LIBRARIES ws2_32)
if(TARGET LibXml2::LibXml2)
target_link_libraries(LibXml2::LibXml2 INTERFACE "ws2_32")
endif()
endif()
if(ICONV_LIBRARIES)
list(APPEND LIBXML2_LIBRARIES ${ICONV_LIBRARIES})
if(TARGET LibXml2::LibXml2)
target_link_libraries(LibXml2::LibXml2 INTERFACE ${ICONV_LIBRARIES})
endif()
endif()
if(CHARSET_LIBRARIES)
list(APPEND LIBXML2_LIBRARIES ${CHARSET_LIBRARIES})
if(TARGET LibXml2::LibXml2)
target_link_libraries(LibXml2::LibXml2 INTERFACE ${CHARSET_LIBRARIES})
endif()
endif()
if(TARGET LibXml2::LibXml2)
target_link_libraries(LibXml2::LibXml2 INTERFACE ${LIBLZMA_LIBRARIES} ${ZLIB_LIBRARIES})
endif()
cmake_policy(POP)
endif()