Skip to content

Commit 5f9998b

Browse files
committed
CMake: Support legacy EXPAT Find package in the config file
Fix #494
1 parent 34db541 commit 5f9998b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,13 +389,14 @@ if(LIBLCF_WITH_XML)
389389
find_package(expat CONFIG)
390390
if(expat_FOUND)
391391
target_link_libraries(lcf expat::expat)
392+
set(LCF_SUPPORT_XML 1)
392393
else()
393394
# Fallback to old expat detection
394395
find_package(EXPAT REQUIRED)
395396
target_link_libraries(lcf EXPAT::EXPAT)
397+
set(LCF_SUPPORT_XML 2)
396398
endif()
397399
list(APPEND LIBLCF_DEPS "expat")
398-
set(LCF_SUPPORT_XML 1)
399400
endif()
400401

401402
# mime types

builds/cmake/liblcf-config.cmake.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ if(@LCF_SUPPORT_ICU@ EQUAL 1)
1313
find_dependency(ICU COMPONENTS i18n uc data REQUIRED)
1414
endif()
1515

16-
if(@LCF_SUPPORT_XML@)
16+
if(@LCF_SUPPORT_XML@ EQUAL 1)
1717
find_dependency(expat CONFIG REQUIRED)
18+
elseif(@LCF_SUPPORT_XML@ EQUAL 2)
19+
# Fallback to old expat detection
20+
find_dependency(EXPAT REQUIRED)
21+
22+
# Ensure correct target name when the expat config file is used
23+
if(TARGET expat::expat AND NOT TARGET EXPAT::EXPAT)
24+
add_library(EXPAT::EXPAT ALIAS expat::expat)
25+
endif()
1826
endif()
1927

2028
include(${CMAKE_CURRENT_LIST_DIR}/liblcf-targets.cmake)

0 commit comments

Comments
 (0)