Skip to content

Commit

Permalink
Merge #295: cmake: Temporarily revert removal of Q_IMPORT_PLUGIN ma…
Browse files Browse the repository at this point in the history
…cros

078294d fixup! cmake: Build `bitcoin-qt` executable (Hennadii Stepanov)
13167e6 Revert "qt: Drop `Q_IMPORT_PLUGIN` macros" (Hennadii Stepanov)

Pull request description:

  This PR aims to restore [compatibility](bitcoin#30454 (comment)) of the CMake staging branch and bitcoin#30454 with the Autotools-based build system.

  On the staging branch @ f63b200:
  ```
  $ make -C depends
  $ ./autogen.sh
  $ ./configure CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site
  $ make -C src qt/bitcoin-qt
  $ ./src/qt/bitcoin-qt
  qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
  This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

  Aborted (core dumped)
  ```

  This PR resolves this issue and adds a TODO comment for the further actions.

ACKs for top commit:
  m3dwards:
    ACK 078294d
  pablomartin4btc:
    tACK 078294d

Tree-SHA512: bd9440a4ea9fbce5a017abd14e9867d201b3270ddff7b061334f02acb6ed06bbe99ffacf567a3d837a13e1eec22a70e14b2201d87c1e25c9b8a5135d57a57097
  • Loading branch information
hebasto committed Aug 4, 2024
2 parents 30ac8c3 + 078294d commit a687016
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ endif()

get_target_property(qt_lib_type Qt5::Core TYPE)

# TODO: After the transition from Autotools to CMake,
# all `Q_IMPORT_PLUGIN` macros can be deleted from the
# qt/bitcoin.cpp and qt/test/test_main.cpp source files.
function(import_plugins target)
if(qt_lib_type STREQUAL "STATIC_LIBRARY")
set(plugins Qt5::QMinimalIntegrationPlugin)
Expand All @@ -24,8 +27,8 @@ function(import_plugins target)
list(APPEND plugins Qt5::QCocoaIntegrationPlugin Qt5::QMacStylePlugin)
endif()
qt5_import_plugins(${target}
INCLUDE ${plugins}
EXCLUDE_BY_TYPE imageformats iconengines
INCLUDE ${plugins}
EXCLUDE_BY_TYPE imageformats iconengines
)
endif()
endfunction()
Expand Down
15 changes: 15 additions & 0 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@
#include <QTranslator>
#include <QWindow>

#if defined(QT_STATIC)
#include <QtPlugin>
#if defined(QT_QPA_PLATFORM_XCB)
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_WINDOWS)
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin);
#elif defined(QT_QPA_PLATFORM_COCOA)
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
Q_IMPORT_PLUGIN(QMacStylePlugin);
#elif defined(QT_QPA_PLATFORM_ANDROID)
Q_IMPORT_PLUGIN(QAndroidPlatformIntegrationPlugin)
#endif
#endif

// Declare meta types used for QMetaObject::invokeMethod
Q_DECLARE_METATYPE(bool*)
Q_DECLARE_METATYPE(CAmount)
Expand Down
16 changes: 16 additions & 0 deletions src/qt/test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@

#include <functional>

#if defined(QT_STATIC)
#include <QtPlugin>
#if defined(QT_QPA_PLATFORM_MINIMAL)
Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin);
#endif
#if defined(QT_QPA_PLATFORM_XCB)
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_WINDOWS)
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_COCOA)
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
#elif defined(QT_QPA_PLATFORM_ANDROID)
Q_IMPORT_PLUGIN(QAndroidPlatformIntegrationPlugin)
#endif
#endif

const std::function<void(const std::string&)> G_TEST_LOG_FUN{};

const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUMENTS{};
Expand Down

0 comments on commit a687016

Please sign in to comment.