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 | ||||
get_target_property(QT_CORE_LIB_LOCATION Qt5::Core LOCATION) | get_target_property(QT_CORE_LIB_LOCATION Qt5::Core LOCATION) | ||||
get_filename_component(QT5_LIB_DIR "${QT_CORE_LIB_LOCATION}" DIRECTORY) | get_filename_component(QT5_LIB_DIR "${QT_CORE_LIB_LOCATION}" DIRECTORY) | ||||
set(STATIC_DEPENDENCIES_CMAKE_FILE "${CMAKE_BINARY_DIR}/QtStaticDependencies.cmake") | |||||
if(EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
file(REMOVE ${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
endif() | |||||
set(CONVERT_PRL_PATH "${CONTRIB_PATH}/qt/convert-prl-libs-to-cmake.pl") | |||||
macro(CONVERT_PRL_LIBS_TO_CMAKE _qt_component) | |||||
if(TARGET Qt5::${_qt_component}) | |||||
get_target_property(_lib_location Qt5::${_qt_component} LOCATION) | |||||
execute_process(COMMAND ${PERL_EXECUTABLE} "${CONVERT_PRL_PATH}" | |||||
--lib "${_lib_location}" | |||||
--qt_lib_install_dir "${QT5_LIB_DIR}" | |||||
--out "${STATIC_DEPENDENCIES_CMAKE_FILE}" | |||||
--component "${_qt_component}" | |||||
--compiler "${CMAKE_CXX_COMPILER_ID}" | |||||
) | |||||
endif() | |||||
endmacro() | |||||
if(QT_STATIC_BUILD) | |||||
foreach(qt_module ${QT_REQUIRED_COMPONENTS}) | |||||
CONVERT_PRL_LIBS_TO_CMAKE(${qt_module}) | |||||
endforeach() | |||||
# HACK: We must explicitly add LIB path of the Qt installation | |||||
# to correctly find qtpcre | |||||
link_directories("${QT5_LIB_DIR}") | |||||
# Now that we generated the dependencies, import them. | |||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CONVERT_PRL_PATH}") | |||||
if(NOT EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
message(FATAL_ERROR "Unable to find ${STATIC_DEPENDENCIES_CMAKE_FILE}") | |||||
endif() | |||||
include(${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
list(REMOVE_DUPLICATES STATIC_LIB_DEPENDENCIES) | |||||
endif() | |||||
# Localisation | # Localisation | ||||
add_subdirectory(locale) | add_subdirectory(locale) | ||||
add_custom_command(OUTPUT temp_bitcoin_locale.qrc | add_custom_command(OUTPUT temp_bitcoin_locale.qrc | ||||
COMMAND cmake | COMMAND cmake | ||||
ARGS | ARGS | ||||
-E copy | -E copy | ||||
"${CMAKE_CURRENT_SOURCE_DIR}/bitcoin_locale.qrc" | "${CMAKE_CURRENT_SOURCE_DIR}/bitcoin_locale.qrc" | ||||
▲ Show 20 Lines • Show All 100 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} | ||||
) | ) | ||||
set(STATIC_DEPENDENCIES_CMAKE_FILE "${CMAKE_BINARY_DIR}/QtStaticDependencies.cmake") | |||||
if(EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
file(REMOVE ${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
endif() | |||||
set(CONVERT_PRL_PATH "${CONTRIB_PATH}/qt/convert-prl-libs-to-cmake.pl") | |||||
macro(CONVERT_PRL_LIBS_TO_CMAKE _qt_component) | |||||
if(TARGET Qt5::${_qt_component}) | |||||
get_target_property(_lib_location Qt5::${_qt_component} LOCATION) | |||||
execute_process(COMMAND ${PERL_EXECUTABLE} "${CONVERT_PRL_PATH}" | |||||
--lib "${_lib_location}" | |||||
--qt_lib_install_dir "${QT5_LIB_DIR}" | |||||
--out "${STATIC_DEPENDENCIES_CMAKE_FILE}" | |||||
--component "${_qt_component}" | |||||
--compiler "${CMAKE_CXX_COMPILER_ID}" | |||||
) | |||||
endif() | |||||
endmacro() | |||||
deadalnix: Why has this whole block moved ? This makes it impossible to check what actually changed. There… | |||||
FabienAuthorUnsubmitted Done Inline ActionsIt get moved with the block to keep related things together. The static dependencies file and the macro are used just below. Fabien: It get moved with the block to keep related things together. The static dependencies file and… | |||||
deadalnixUnsubmitted Not Done Inline ActionsAnd the things that come together needs to be here because ? deadalnix: And the things that come together needs to be here because ? | |||||
FabienAuthorUnsubmitted Done Inline ActionsBecause the bitcoin-qt-base target needs to be defined Fabien: Because the bitcoin-qt-base target needs to be defined | |||||
if(QT_STATIC_BUILD) | |||||
foreach(qt_module ${QT_REQUIRED_COMPONENTS}) | |||||
CONVERT_PRL_LIBS_TO_CMAKE(${qt_module}) | |||||
endforeach() | |||||
# HACK: We must explicitly add LIB path of the Qt installation | |||||
# to correctly find qtpcre | |||||
link_directories("${QT5_LIB_DIR}") | |||||
# According to Qt documentation (https://doc.qt.io/qt-5/plugins-howto.html): | |||||
# "Plugins can be linked statically into your application. | |||||
# If you build the static version of Qt, this is the only option for | |||||
# including Qt's predefined plugins." | |||||
# So if the Qt build is static, the plugins should be statically linked. | |||||
foreach(qt_plugin ${QT_PLUGIN_COMPONENTS}) | |||||
CONVERT_PRL_LIBS_TO_CMAKE(${qt_plugin}) | |||||
endforeach() | |||||
deadalnixUnsubmitted Not Done Inline ActionsYou have two loops that do the exact same thing now. deadalnix: You have two loops that do the exact same thing now. | |||||
FabienAuthorUnsubmitted Done Inline ActionsThey are looping over 2 different lists. Fabien: They are looping over 2 different lists. | |||||
deadalnixUnsubmitted Not Done Inline ActionsI'm fairly confident that there are way to loop over two different lists without duplicating the whole loop and loop body. deadalnix: I'm fairly confident that there are way to loop over two different lists without duplicating… | |||||
FabienAuthorUnsubmitted Done Inline ActionsOK, I'll wrap this into some macro Fabien: OK, I'll wrap this into some macro | |||||
FabienAuthorUnsubmitted Done Inline ActionsOr better concat them then loop Fabien: Or better concat them then loop | |||||
# Now that we generated the dependencies, import them. | |||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CONVERT_PRL_PATH}") | |||||
if(NOT EXISTS ${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
message(FATAL_ERROR "Unable to find ${STATIC_DEPENDENCIES_CMAKE_FILE}") | |||||
endif() | |||||
include(${STATIC_DEPENDENCIES_CMAKE_FILE}) | |||||
list(REMOVE_DUPLICATES STATIC_LIB_DEPENDENCIES) | |||||
# If the build is static, the plugins should also be static and we need to | |||||
# define QT_STATICPLUGIN. | |||||
# 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() | |||||
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 |
Why has this whole block moved ? This makes it impossible to check what actually changed. There doesn't seems to be a good reason for moving this around.