aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/FindHunspell.cmake
blob: 8b5883170c4e1ec0832304f8734d59f98cfbc0b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# We can't create the same interface imported target multiple times, CMake will complain if we do
# that. This can happen if the find_package call is done in multiple different subdirectories.
if(TARGET Hunspell::Hunspell)
    set(Hunspell_FOUND ON)
    return()
endif()

find_package(PkgConfig)

pkg_check_modules(hunspell hunspell IMPORTED_TARGET)
set(__hunspell_target_name "PkgConfig::hunspell")

if (NOT TARGET "${__hunspell_target_name}")
    set(Hunspell_FOUND 0)
    return()
endif()

add_library(Hunspell::Hunspell INTERFACE IMPORTED)
target_link_libraries(Hunspell::Hunspell INTERFACE ${__hunspell_target_name})
set(Hunspell_FOUND TRUE)
unset(__hunspell_target_name)