diff options
author | Niclas Rosenvik <nros@netbsd.org> | 2021-05-28 11:59:37 +0000 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-06-03 20:08:32 +0200 |
commit | 7920c03ff1954355d588baa466820a60afc9b587 (patch) | |
tree | e2382b6a6f0d73159aaacf1b10ac615949f20444 | |
parent | 5cc3105807a7f1868b067e5d9757acab0a2bb8e8 (diff) |
Fix support for using system supplied md4c library
Add FindWrapSystemMd4c.cmake so that the old md4c target can be used
as well as the new one and set WrapSystemMd4c_FOUND.
Link to the imported target WrapSystemMd4c::WrapSystemMd4c if the
system library is used.
Add qt_find_package line to find the package in configure.cmake.
Fix the condition for enabling system-textmarkdownreader, it includes
testing for textmarkdownreader because even if the code would compile
correctly without it, it looks strange when the output says
"textmarkdownreader no" and under "using system libmd4c yes" even if
libmd4c is not used.
Use system include when system-markdownreader is enabled.
Add library mapping for libmd4c.
Change-Id: Id5d5b13d6691a8c1cdf627238887977c847c1e67
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | cmake/FindWrapSystemMd4c.cmake | 24 | ||||
-rw-r--r-- | src/gui/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/gui/configure.cmake | 3 | ||||
-rw-r--r-- | src/gui/configure.json | 2 | ||||
-rw-r--r-- | src/gui/text/qtextmarkdownimporter.cpp | 4 | ||||
-rw-r--r-- | util/cmake/helper.py | 1 |
6 files changed, 33 insertions, 3 deletions
diff --git a/cmake/FindWrapSystemMd4c.cmake b/cmake/FindWrapSystemMd4c.cmake new file mode 100644 index 0000000000..ea691a4590 --- /dev/null +++ b/cmake/FindWrapSystemMd4c.cmake @@ -0,0 +1,24 @@ +if(TARGET WrapSystemMd4c::WrapSystemMd4c) + set(WrapSystemMd4c_FOUND TRUE) + return() +endif() + +find_package(md4c CONFIG) + +# md4c provides a md4c::md4c target but +# older versions create a md4c target without +# namespace. If we find the old variant create +# a namespaced target out of the md4c target. +if(TARGET md4c AND NOT TARGET md4c::md4c) + add_library(md4c::md4c INTERFACE IMPORTED) + target_link_libraries(md4c::md4c INTERFACE md4c) +endif() + +if(TARGET md4c::md4c) + add_library(WrapSystemMd4c::WrapSystemMd4c INTERFACE IMPORTED) + target_link_libraries(WrapSystemMd4c::WrapSystemMd4c INTERFACE md4c::md4c) +endif() + +if(TARGET WrapSystemMd4c::WrapSystemMd4c) + set(WrapSystemMd4c_FOUND TRUE) +endif() diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 7eb901f778..5fe4d59d10 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -682,7 +682,7 @@ qt_internal_extend_target(Gui CONDITION QT_FEATURE_textmarkdownreader qt_internal_extend_target(Gui CONDITION QT_FEATURE_system_textmarkdownreader AND QT_FEATURE_textmarkdownreader LIBRARIES - libmd4c + WrapSystemMd4c::WrapSystemMd4c ) qt_internal_extend_target(Gui CONDITION QT_FEATURE_textmarkdownreader AND NOT QT_FEATURE_system_textmarkdownreader diff --git a/src/gui/configure.cmake b/src/gui/configure.cmake index 49b4753870..20c5b9624b 100644 --- a/src/gui/configure.cmake +++ b/src/gui/configure.cmake @@ -41,6 +41,7 @@ qt_find_package(gbm PROVIDED_TARGETS gbm::gbm MODULE_NAME gui QMAKE_LIB gbm) qt_find_package(WrapSystemHarfbuzz 2.6.0 PROVIDED_TARGETS WrapSystemHarfbuzz::WrapSystemHarfbuzz MODULE_NAME gui QMAKE_LIB harfbuzz) qt_find_package(Libinput PROVIDED_TARGETS Libinput::Libinput MODULE_NAME gui QMAKE_LIB libinput) qt_find_package(JPEG PROVIDED_TARGETS JPEG::JPEG MODULE_NAME gui QMAKE_LIB libjpeg) +qt_find_package(WrapSystemMd4c PROVIDED_TARGETS WrapSystemMd4c::WrapSystemMd4c MODULE_NAME gui QMAKE_LIB libmd4c) qt_find_package(WrapSystemPNG PROVIDED_TARGETS WrapSystemPNG::WrapSystemPNG MODULE_NAME gui QMAKE_LIB libpng) if(QT_FEATURE_system_zlib) qt_add_qmake_lib_dependency(libpng zlib) @@ -945,7 +946,7 @@ qt_feature("textmarkdownreader" PUBLIC qt_feature("system-textmarkdownreader" PUBLIC SECTION "Kernel" LABEL " Using system libmd4c" - CONDITION libs.libmd4c OR FIXME + CONDITION QT_FEATURE_textmarkdownreader AND WrapSystemMd4c_FOUND ENABLE INPUT_libmd4c STREQUAL 'system' DISABLE INPUT_libmd4c STREQUAL 'qt' ) diff --git a/src/gui/configure.json b/src/gui/configure.json index 47398c9a4e..8e3d647df6 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -1452,7 +1452,7 @@ "disable": "input.libmd4c == 'qt'", "enable": "input.libmd4c == 'system'", "section": "Kernel", - "condition": "libs.libmd4c", + "condition": "features.textmarkdownreader && libs.libmd4c", "output": [ "publicFeature" ] }, "textmarkdownwriter": { diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 1e18f31c30..75b5a324c8 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -48,7 +48,11 @@ #include <QTextDocumentFragment> #include <QTextList> #include <QTextTable> +#if QT_CONFIG(system_textmarkdownreader) +#include <md4c.h> +#else #include "../../3rdparty/md4c/md4c.h" +#endif QT_BEGIN_NAMESPACE diff --git a/util/cmake/helper.py b/util/cmake/helper.py index f22134c5ee..f385fca60c 100644 --- a/util/cmake/helper.py +++ b/util/cmake/helper.py @@ -457,6 +457,7 @@ _library_map = [ LibraryMapping("librt", "WrapRt", "WrapRt::WrapRt"), LibraryMapping("libudev", "Libudev", "PkgConfig::Libudev"), LibraryMapping("lttng-ust", "LTTngUST", "LTTng::UST", resultVariable="LTTNGUST"), + LibraryMapping("libmd4c", "WrapMd4c", "WrapMd4c::WrapMd4c", is_bundled_with_qt=True), LibraryMapping("mtdev", "Mtdev", "PkgConfig::Mtdev"), LibraryMapping("mysql", "MySQL", "MySQL::MySQL"), LibraryMapping("odbc", "ODBC", "ODBC::ODBC"), |