Changeset View
Changeset View
Standalone View
Standalone View
src/qt/CMakeLists.txt
# Copyright (c) 2018 The Bitcoin developers | # Copyright (c) 2018 The Bitcoin developers | ||||
project(bitcoin-qt) | project(bitcoin-qt) | ||||
# This ensure that AUTOMOC doesn't run on generated files. | # This ensure that AUTOMOC doesn't run on generated files. | ||||
cmake_policy(SET CMP0071 OLD) | cmake_policy(SET CMP0071 OLD) | ||||
include(BrewHelper) | include(BrewHelper) | ||||
find_brew_prefix(QT5_PREFIX qt5) | find_brew_prefix(QT5_PREFIX qt5) | ||||
set(QT_REQUIRED_COMPONENTS Core Widgets Network Test) | set(QT_REQUIRED_COMPONENTS Core Widgets Network Test) | ||||
find_package(Qt5 COMPONENTS ${QT_REQUIRED_COMPONENTS} REQUIRED HINTS "${QT5_PREFIX}") | find_package(Qt5 COMPONENTS ${QT_REQUIRED_COMPONENTS} REQUIRED HINTS "${QT5_PREFIX}") | ||||
# Add the minimal integration plugin, and other plugins according to the target | |||||
# platform. | |||||
set(QT_PLUGIN_COMPONENTS QMinimalIntegrationPlugin) | |||||
set(QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_MINIMAL=1) | |||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") | |||||
list(APPEND QT_PLUGIN_COMPONENTS QXcbIntegrationPlugin) | |||||
list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_XCB=1) | |||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | |||||
list(APPEND QT_PLUGIN_COMPONENTS QCocoaIntegrationPlugin) | |||||
list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_COCOA=1) | |||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | |||||
list(APPEND QT_PLUGIN_COMPONENTS QWindowsIntegrationPlugin) | |||||
list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_WINDOWS=1) | |||||
endif() | |||||
# Find out more about Qt. This is similar to | # Find out more about Qt. This is similar to | ||||
# http://code.qt.io/cgit/qt/qtwebkit.git/tree/Source/cmake/OptionsQt.cmake | # http://code.qt.io/cgit/qt/qtwebkit.git/tree/Source/cmake/OptionsQt.cmake | ||||
get_target_property(QT_CORE_TYPE Qt5::Core TYPE) | get_target_property(QT_CORE_TYPE Qt5::Core TYPE) | ||||
if(QT_CORE_TYPE MATCHES STATIC) | if(QT_CORE_TYPE MATCHES STATIC) | ||||
set(QT_STATIC_BUILD ON) | set(QT_STATIC_BUILD ON) | ||||
endif() | endif() | ||||
# Determine the Qt libraries directory from the QT5::Core library location | # Determine the Qt libraries directory from the QT5::Core library location | ||||
Show All 22 Lines | |||||
if(QT_STATIC_BUILD) | if(QT_STATIC_BUILD) | ||||
foreach(qt_module ${QT_REQUIRED_COMPONENTS}) | foreach(qt_module ${QT_REQUIRED_COMPONENTS}) | ||||
CONVERT_PRL_LIBS_TO_CMAKE(${qt_module}) | CONVERT_PRL_LIBS_TO_CMAKE(${qt_module}) | ||||
endforeach() | endforeach() | ||||
# HACK: We must explicitly add LIB path of the Qt installation | # HACK: We must explicitly add LIB path of the Qt installation | ||||
# to correctly find qtpcre | # to correctly find qtpcre | ||||
link_directories("${QT5_LIB_DIR}") | link_directories("${QT5_LIB_DIR}") | ||||
# If the build is static, consider that the plugins are also static. | |||||
# This simplification reduces by far the cmake script complexity, while | |||||
# still covering most if not all the use cases. | |||||
foreach(qt_plugin ${QT_PLUGIN_COMPONENTS}) | |||||
CONVERT_PRL_LIBS_TO_CMAKE(${qt_plugin}) | |||||
endforeach() | |||||
deadalnix: The fact you added this here but also felt the need to create a second block based on the exact… | |||||
# Now that we generated the dependencies, import them. | # Now that we generated the dependencies, import them. | ||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CONVERT_PRL_PATH}") | set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CONVERT_PRL_PATH}") | ||||
if(NOT EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE}) | if(NOT EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE}) | ||||
message(FATAL_ERROR "Unable to find ${STATIC_DEPENDENCIES_CMAKE_FILE}") | message(FATAL_ERROR "Unable to find ${STATIC_DEPENDENCIES_CMAKE_FILE}") | ||||
endif() | endif() | ||||
include(${STATIC_DEPENDENCIES_CMAKE_FILE}) | include(${STATIC_DEPENDENCIES_CMAKE_FILE}) | ||||
list(REMOVE_DUPLICATES STATIC_LIB_DEPENDENCIES) | list(REMOVE_DUPLICATES STATIC_LIB_DEPENDENCIES) | ||||
endif() | endif() | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | target_link_libraries(bitcoin-qt-base | ||||
server | server | ||||
rpcclient | rpcclient | ||||
Qt5::Widgets | Qt5::Widgets | ||||
Qt5::Network | Qt5::Network | ||||
OpenSSL::SSL | OpenSSL::SSL | ||||
${Protobuf_LIBRARIES} | ${Protobuf_LIBRARIES} | ||||
) | ) | ||||
if(QT_STATIC_BUILD) | |||||
# If the plugins are built static, we need to define QT_STATICPLUGIN. | |||||
deadalnixUnsubmitted Not Done Inline ActionsIt's not what you are checking for deadalnix: It's not what you are checking for | |||||
# Setting this definition tells the code to import <QTPlugin>. | |||||
target_compile_definitions(bitcoin-qt-base PUBLIC -DQT_STATICPLUGIN=1) | |||||
# Add the platform plugin definition if required | |||||
# Setting this definition tells the code what is the target for Q_IMPORT_PLUGIN(). | |||||
foreach(qt_platform_definition ${QT_PLUGIN_PLATFORM_DEFINITIONS}) | |||||
target_compile_definitions(bitcoin-qt-base PUBLIC "${qt_platform_definition}") | |||||
endforeach() | |||||
# Link the required plugins | |||||
foreach(qt_plugin ${QT_PLUGIN_COMPONENTS}) | |||||
target_link_libraries(bitcoin-qt-base Qt5::${qt_plugin}) | |||||
endforeach() | |||||
deadalnixUnsubmitted Not Done Inline ActionsPresumably, that would need this to happen also if the plugin are not static. deadalnix: Presumably, that would need this to happen also if the plugin are not static. | |||||
FabienAuthorUnsubmitted Done Inline ActionsMy understanding is that it is not necessary unless you build static. Fabien: My understanding is that it is not necessary unless you build static.
From https://doc.qt.io/qt… | |||||
endif() | |||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
set_property(TARGET bitcoin-qt-base PROPERTY AUTOMOC_MOC_OPTIONS "-DQ_OS_MAC") | set_property(TARGET bitcoin-qt-base PROPERTY AUTOMOC_MOC_OPTIONS "-DQ_OS_MAC") | ||||
endif() | endif() | ||||
# Wallet | # Wallet | ||||
if(BUILD_BITCOIN_WALLET) | if(BUILD_BITCOIN_WALLET) | ||||
# Automoc option. | # Automoc option. | ||||
set(AUTOMOC_MOC_OPTIONS -DENABLE_WALLET=1) | set(AUTOMOC_MOC_OPTIONS -DENABLE_WALLET=1) | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |
The fact you added this here but also felt the need to create a second block based on the exact same check is quite puzzling.