From 0c4fe1750f232805f604048340d64bd1a6a18a74 Mon Sep 17 00:00:00 2001 From: Vitaly Zaitsev Date: Mon, 24 Feb 2020 17:17:49 +0100 Subject: [PATCH] Allow to build against packaged version of hunspell library. Signed-off-by: Vitaly Zaitsev --- external/hunspell/CMakeLists.txt | 95 ++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 42 deletions(-) diff --git a/external/hunspell/CMakeLists.txt b/external/hunspell/CMakeLists.txt index 531e23e..6fec471 100644 --- a/external/hunspell/CMakeLists.txt +++ b/external/hunspell/CMakeLists.txt @@ -4,49 +4,60 @@ # For license and copyright information please follow this link: # https://github.com/desktop-app/legal/blob/master/LEGAL -add_library(external_hunspell OBJECT) -add_library(desktop-app::external_hunspell ALIAS external_hunspell) -init_target(external_hunspell "(external)") +if (DESKTOP_APP_USE_PACKAGED) + add_library(external_hunspell INTERFACE IMPORTED) + add_library(desktop-app::external_hunspell ALIAS external_hunspell) -set(hunspell_loc ${third_party_loc}/hunspell) -set(hunspell_src ${hunspell_loc}/src) + find_package(PkgConfig REQUIRED) + pkg_check_modules(HUNSPELL REQUIRED hunspell) -nice_target_sources(external_hunspell ${hunspell_src} -PRIVATE - hunspell/affentry.cxx - hunspell/affentry.hxx - hunspell/affixmgr.cxx - hunspell/affixmgr.hxx - hunspell/atypes.hxx - hunspell/baseaffix.hxx - hunspell/csutil.cxx - hunspell/csutil.hxx - hunspell/filemgr.cxx - hunspell/filemgr.hxx - hunspell/hashmgr.cxx - hunspell/hashmgr.hxx - hunspell/htypes.hxx - hunspell/hunspell.cxx - hunspell/hunspell.h - hunspell/hunspell.hxx - hunspell/hunvisapi.h - hunspell/hunzip.cxx - hunspell/hunzip.hxx - hunspell/phonet.cxx - hunspell/phonet.hxx - hunspell/replist.cxx - hunspell/replist.hxx - hunspell/suggestmgr.cxx - hunspell/suggestmgr.hxx - hunspell/utf_info.hxx -) + target_include_directories(external_hunspell INTERFACE ${HUNSPELL_INCLUDE_DIRS}) + target_link_libraries(external_hunspell INTERFACE ${HUNSPELL_LIBRARIES}) +else() + add_library(external_hunspell OBJECT) + add_library(desktop-app::external_hunspell ALIAS external_hunspell) + init_target(external_hunspell "(external)") -target_include_directories(external_hunspell -PUBLIC - ${hunspell_src} -) + set(hunspell_loc ${third_party_loc}/hunspell) + set(hunspell_src ${hunspell_loc}/src) -target_compile_definitions(external_hunspell -PUBLIC - HUNSPELL_STATIC -) + nice_target_sources(external_hunspell ${hunspell_src} + PRIVATE + hunspell/affentry.cxx + hunspell/affentry.hxx + hunspell/affixmgr.cxx + hunspell/affixmgr.hxx + hunspell/atypes.hxx + hunspell/baseaffix.hxx + hunspell/csutil.cxx + hunspell/csutil.hxx + hunspell/filemgr.cxx + hunspell/filemgr.hxx + hunspell/hashmgr.cxx + hunspell/hashmgr.hxx + hunspell/htypes.hxx + hunspell/hunspell.cxx + hunspell/hunspell.h + hunspell/hunspell.hxx + hunspell/hunvisapi.h + hunspell/hunzip.cxx + hunspell/hunzip.hxx + hunspell/phonet.cxx + hunspell/phonet.hxx + hunspell/replist.cxx + hunspell/replist.hxx + hunspell/suggestmgr.cxx + hunspell/suggestmgr.hxx + hunspell/utf_info.hxx + ) + + target_include_directories(external_hunspell + PUBLIC + ${hunspell_src} + ) + + target_compile_definitions(external_hunspell + PUBLIC + HUNSPELL_STATIC + ) +endif()