* CMakeLists.txt <md4c, tidy>: Search for libraries in the system first, falling back to bundled copies in case they aren't found.
Fixes: <https://git.jami.net/savoirfairelinux/jami-client-qt/-/issues/1506> --- Changes in v2: - Rebased on top of master CMakeLists.txt | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e802357f..6d2dccfb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -600,20 +600,34 @@ add_subdirectory(3rdparty/SortFilterProxyModel) set(SFPM_OBJECTS $<TARGET_OBJECTS:SortFilterProxyModel>) # md4c -set(BUILD_MD2HTML_EXECUTABLE OFF CACHE BOOL "Don't build md2html executable" FORCE) -set(BUILD_SHARED_LIBS OFF CACHE BOOL "Don't build shared md4c library" FORCE) -add_subdirectory(3rdparty/md4c EXCLUDE_FROM_ALL) -list(APPEND CLIENT_LINK_DIRS ${MD4C_BINARY_DIR}/src) -list(APPEND CLIENT_INCLUDE_DIRS ${MD4C_SOURCE_DIR}/src) -list(APPEND CLIENT_LIBS md4c-html) +find_package(md4c) +if(md4c_FOUND) + message(STATUS "Using system-provided md4c-html") + list(APPEND CLIENT_LIBS md4c::md4c-html) +else() + message("Using bundled md4c-html library") + set(BUILD_MD2HTML_EXECUTABLE OFF CACHE BOOL "Don't build md2html executable" FORCE) + set(BUILD_SHARED_LIBS OFF CACHE BOOL "Don't build shared md4c library" FORCE) + add_subdirectory(3rdparty/md4c EXCLUDE_FROM_ALL) + list(APPEND CLIENT_LINK_DIRS ${MD4C_BINARY_DIR}/src) + list(APPEND CLIENT_INCLUDE_DIRS ${MD4C_SOURCE_DIR}/src) + list(APPEND CLIENT_LIBS md4c-html) +endif() # tidy-html5 -set(BUILD_SHARED_LIB OFF CACHE BOOL "Don't build shared tidy library" FORCE) -set(SUPPORT_CONSOLE_APP OFF CACHE BOOL "Don't build tidy console app" FORCE) -add_subdirectory(3rdparty/tidy-html5 EXCLUDE_FROM_ALL) -list(APPEND CLIENT_LINK_DIRS ${tidy_BINARY_DIR}/Release) -list(APPEND CLIENT_INCLUDE_DIRS ${tidy_SOURCE_DIR}/include) -list(APPEND CLIENT_LIBS tidy-static) +pkg_check_modules(tidy IMPORTED_TARGET tidy) +if(tidy_FOUND) + message(STATUS "Using system-provided tidy") + list(APPEND CLIENT_LIBS PkgConfig::tidy) +else() + message("Using bundled tidy library") + set(BUILD_SHARED_LIB OFF CACHE BOOL "Don't build shared tidy library" FORCE) + set(SUPPORT_CONSOLE_APP OFF CACHE BOOL "Don't build tidy console app" FORCE) + add_subdirectory(3rdparty/tidy-html5 EXCLUDE_FROM_ALL) + list(APPEND CLIENT_LINK_DIRS ${tidy_BINARY_DIR}/Release) + list(APPEND CLIENT_INCLUDE_DIRS ${tidy_SOURCE_DIR}/include) + list(APPEND CLIENT_LIBS tidy-static) +endif() # common executable sources qt_add_executable( base-commit: b88627d125b7d217a46f76f62edf4852bcffa36b -- 2.41.0
