From c15501bf8a5ab1a50b5ed860055ae1d80d2a3d14 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 22 Dec 2023 13:37:21 +0100 Subject: [PATCH] Re-add a fixed version of FindEXPAT.cmake to fix wxWidgets build Without this, wxWidgets will use the CMake default FindEXPAT which will not find our static expat correctly. This wrapper will do a config search first and always define EXPAT::EXPAT to point to the found library. --- cmake/modules/FindEXPAT.cmake | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 cmake/modules/FindEXPAT.cmake diff --git a/cmake/modules/FindEXPAT.cmake b/cmake/modules/FindEXPAT.cmake new file mode 100644 index 0000000000..b7a98a5a17 --- /dev/null +++ b/cmake/modules/FindEXPAT.cmake @@ -0,0 +1,35 @@ +set(_q "") +if(EXPAT_FIND_QUIETLY) + set(_q QUIET) +endif() +find_package(EXPAT ${EXPAT_FIND_VERSION} CONFIG ${_q}) + +if(NOT EXPAT_FIND_QUIETLY) + if (NOT EXPAT_FOUND) + message(STATUS "Falling back to MODULE search for EXPAT...") + else() + message(STATUS "EXPAT found in ${EXPAT_DIR}") + endif() +endif() + +if (NOT EXPAT_FOUND) + set(_modpath ${CMAKE_MODULE_PATH}) + set(CMAKE_MODULE_PATH "") + include(FindEXPAT) + set(CMAKE_MODULE_PATH ${_modpath}) + + if (NOT TARGET EXPAT::EXPAT) + add_library(EXPAT::EXPAT INTERFACE) + target_link_libraries(EXPAT::EXPAT INTERFACE ${EXPAT_LIBRARIES}) + target_include_directories(EXPAT::EXPAT INTERFACE ${EXPAT_INCLUDE_DIRS}) + endif () +endif() + +if (EXPAT_FOUND AND NOT TARGET EXPAT::EXPAT AND TARGET expat::expat) + add_library(libexpat_ps_namefix INTERFACE) + add_library(EXPAT::EXPAT ALIAS libexpat_ps_namefix) + target_link_libraries(libexpat_ps_namefix INTERFACE expat::expat) + if (NOT EXPAT_LIBRARIES) + set(EXPAT_LIBRARIES expat::expat CACHE STRING "") + endif () +endif ()