Skip to content

Commit 2296b0b

Browse files
authored
Merge pull request #496 from Ghabry/issue-494
CMake: Support legacy EXPAT Find package in the config file
2 parents d182256 + a759e18 commit 2296b0b

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,14 @@ if(LIBLCF_WITH_XML)
394394
find_package(expat CONFIG)
395395
if(expat_FOUND)
396396
target_link_libraries(lcf expat::expat)
397+
set(LCF_SUPPORT_XML 1)
397398
else()
398399
# Fallback to old expat detection
399400
find_package(EXPAT REQUIRED)
400401
target_link_libraries(lcf EXPAT::EXPAT)
402+
set(LCF_SUPPORT_XML 2)
401403
endif()
402404
list(APPEND LIBLCF_DEPS "expat")
403-
set(LCF_SUPPORT_XML 1)
404405
endif()
405406

406407
# mime types

builds/cmake/liblcf-config.cmake.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,22 @@ 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+
endif()
22+
23+
## Create aliases for common expat target names
24+
# The config file creates expat::expat
25+
if (TARGET expat::expat AND NOT TARGET EXPAT::EXPAT)
26+
add_library(EXPAT::EXPAT ALIAS expat::expat)
27+
endif()
28+
29+
# The find module creates EXPAT::EXPAT
30+
if (TARGET EXPAT::EXPAT AND NOT TARGET expat::expat)
31+
add_library(expat::expat ALIAS EXPAT::EXPAT)
1832
endif()
1933

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

0 commit comments

Comments
 (0)