mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 18:29:37 -06:00
FindEXPAT: add a EXPAT_USE_STATIC_LIBS hint
The effect of that hint is to restrict the candidate library names, but more essentially to set the `XML_STATIC` compile definitions which is required to get proper linking. Vcpkg-Issue: https://github.com/microsoft/vcpkg/issues/1100 GDAL-Issue: https://github.com/OSGeo/gdal/issues/7955
This commit is contained in:
5
Help/release/dev/FindEXPAT-static.rst
Normal file
5
Help/release/dev/FindEXPAT-static.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
FindEXPAT-static
|
||||
----------------
|
||||
|
||||
* The :module:`FindEXPAT` module gained a ``EXPAT_USE_STATIC_LIBS`` hint
|
||||
to select static libraries.
|
||||
@@ -30,6 +30,15 @@ This module will set the following variables in your project:
|
||||
``EXPAT_FOUND``
|
||||
true if the Expat headers and libraries were found.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
``EXPAT_USE_STATIC_LIBS``
|
||||
|
||||
.. versionadded:: 3.28
|
||||
|
||||
Set to ``TRUE`` to use static libraries.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
@@ -43,8 +52,13 @@ set(EXPAT_NAMES expat expatw)
|
||||
set(EXPAT_NAMES_DEBUG expatd expatwd)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND EXPAT_NAMES expatMT expatMD expatwMT expatwMD)
|
||||
list(APPEND EXPAT_NAMES_DEBUG expatdMT expatdMD expatwdMT expatwdMD)
|
||||
if(EXPAT_USE_STATIC_LIBS)
|
||||
list(APPEND EXPAT_NAMES expatMT expatwMT)
|
||||
list(APPEND EXPAT_NAMES_DEBUG expatdMT expatwdMT)
|
||||
else()
|
||||
list(APPEND EXPAT_NAMES expatMT expatMD expatwMT expatwMD)
|
||||
list(APPEND EXPAT_NAMES_DEBUG expatdMT expatdMD expatwdMT expatwdMD)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Allow EXPAT_LIBRARY to be set manually, as the location of the expat library
|
||||
@@ -115,6 +129,11 @@ if(EXPAT_FOUND)
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${EXPAT_INCLUDE_DIRS}")
|
||||
|
||||
if(EXPAT_USE_STATIC_LIBS)
|
||||
set_property(TARGET EXPAT::EXPAT APPEND PROPERTY
|
||||
INTERFACE_COMPILE_DEFINITIONS "XML_STATIC")
|
||||
endif()
|
||||
|
||||
if(EXPAT_LIBRARY_RELEASE)
|
||||
set_property(TARGET EXPAT::EXPAT APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
|
||||
Reference in New Issue
Block a user