From 51d66ada79b3a19cb53cd2f86f26a333ba11e689 Mon Sep 17 00:00:00 2001 From: kovben2004 Date: Wed, 1 Jan 2025 17:08:56 +0100 Subject: [PATCH] Fix Linux build --- qt/CMakeLists.txt | 6 +++++- qt/visualizewindow.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 55297bc..5ee604b 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -87,6 +87,10 @@ set_target_properties(bibref-qt PROPERTIES MACOSX_BUNDLE TRUE ) +if(MINGW) +SET(EXTRA_LIBS -lgvplugin_dot_layout -lgvplugin_rsvg -lgvplugin_core -lgvplugin_pango) +endif(MINGW) + target_link_libraries(bibref-qt PRIVATE Qt6::Core Qt6::Gui @@ -95,7 +99,7 @@ target_link_libraries(bibref-qt PRIVATE Qt6::SvgWidgets ${sword_LIBRARIES} ${Boost_LIBRARIES} ${readline_LIBRARIES} ${ICU_LIBRARIES} ${LIBLZMA_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} - ${gvc_LIBRARIES} -lgvplugin_dot_layout -lgvplugin_rsvg -lgvplugin_core -lgvplugin_pango + ${gvc_LIBRARIES} ${EXTRA_LIBS} ) # If not set, XDG_DATA_HOME is set to $HOME: diff --git a/qt/visualizewindow.cpp b/qt/visualizewindow.cpp index b62fda2..c5bfbbd 100644 --- a/qt/visualizewindow.cpp +++ b/qt/visualizewindow.cpp @@ -21,9 +21,13 @@ VisualizeWindow::VisualizeWindow(QWidget *parent, string input) setCentralWidget(tile); GVC_t *gvc= gvContext(); - /* This seems to be required, at least on Windows. +#ifdef __MINGW32__ + /* This seems to be required on Windows, otherwise the + * executable will not know anything about the dot format, + * the svg export, and so on. * Also, in CMake's library settings these 4 dynamic libraries - * must be included. + * must be included. There seems to be no official way to + * do this elegantly. */ extern gvplugin_library_t gvplugin_dot_layout_LTX_library; extern gvplugin_library_t gvplugin_rsvg_LTX_library; @@ -33,6 +37,7 @@ VisualizeWindow::VisualizeWindow(QWidget *parent, string input) gvAddLibrary(gvc, &gvplugin_rsvg_LTX_library); gvAddLibrary(gvc, &gvplugin_core_LTX_library); gvAddLibrary(gvc, &gvplugin_pango_LTX_library); +#endif Agraph_t *g = agmemread((char*)input.c_str()); gvLayout(gvc, g, "dot");