Files
pay/CMakeLists.txt
T

378 lines
14 KiB
CMake
Raw Permalink Normal View History

2020-05-24 13:20:03 +02:00
# This file is part of the Flowee project
2022-04-29 22:43:46 +02:00
# Copyright (C) 2020-2022 Tom Zander <tom@flowee.org>
2020-05-24 13:20:03 +02:00
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2022-11-10 15:50:04 +01:00
cmake_minimum_required(VERSION 3.19)
2022-12-08 14:23:01 +01:00
project(flowee_pay VERSION 0.2 LANGUAGES CXX)
2020-05-24 13:20:03 +02:00
set(CMAKE_AUTOMOC ON)
2022-09-10 00:51:00 +02:00
set(CMAKE_CXX_STANDARD 17)
2020-05-24 13:20:03 +02:00
2022-11-30 11:16:19 +01:00
# calling find_package Qt two times seems to be needed to get the Qt version :shrug:
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
2022-11-28 16:21:42 +01:00
find_package(Qt6 COMPONENTS Core Quick Svg REQUIRED
OPTIONAL_COMPONENTS Multimedia)
2022-09-16 18:54:00 +02:00
find_package(flowee REQUIRED flowee_p2p)
find_package(OpenSSL REQUIRED)
2022-09-16 17:53:53 +02:00
if (ANDROID)
option(quick_deploy "Do not include the blockchain in the APK, for a smaller (developer ONLY) deployment" OFF)
2022-09-16 18:54:00 +02:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/android/cmake)
2022-12-01 21:22:59 +01:00
# Config ZXing here.
if (EXISTS "/opt/android-zxing/include/ZXing/DecodeHints.h")
add_library(ZXing::ZXing STATIC IMPORTED)
set_property(TARGET ZXing::ZXing PROPERTY INTERFACE_INCLUDE_DIRECTORIES
"/opt/android-zxing/include")
set_target_properties(ZXing::ZXing PROPERTIES IMPORTED_LOCATION
"/opt/android-zxing/lib/libZXing.a")
set_property(TARGET ZXing::ZXing PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES
"/opt/android-zxing/lib/libZXing.a")
2022-12-01 21:22:59 +01:00
set (ZXing_FOUND TRUE)
else ()
find_package(ZXing REQUIRED)
endif()
2022-09-16 17:53:53 +02:00
else ()
find_package(Qt6 COMPONENTS DBus LinguistTools)
2023-06-15 14:53:22 +02:00
find_package(ZXing REQUIRED)
2022-09-16 17:53:53 +02:00
endif()
2022-09-16 18:54:00 +02:00
find_package(Boost 1.67.0 REQUIRED filesystem chrono thread)
2023-10-17 22:02:08 +03:00
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
2020-05-24 13:20:03 +02:00
2022-11-13 16:58:19 +01:00
function(download_file url path)
if (NOT EXISTS "${path}")
get_filename_component(file "${path}" NAME)
message(STATUS "Downloading file ${file} from ${url}")
file(DOWNLOAD "${url}" "${path}" INACTIVITY_TIMEOUT 10 STATUS download_result)
list(GET download_result 0 status_code)
list(GET download_result 1 error_message)
if (NOT status_code EQUAL 0)
file(REMOVE "${path}")
message(FATAL_ERROR "Failed to download ${url}: ${error_message}")
endif()
endif()
endfunction()
# The cmake system name will hold values like Android, Linux or others.
add_compile_definitions(TARGET_OS_${CMAKE_SYSTEM_NAME})
2022-11-10 15:50:04 +01:00
###### Translations
2020-10-17 16:38:37 +02:00
2022-09-16 18:54:00 +02:00
if(NOT ANDROID)
2022-11-10 15:50:04 +01:00
# Skip for Android: Linguist is too big a dependency
# We check lower if they have magically appeared: just use the native-build
# and copy the resulting qm files to your android build.
set (TS_FILES
2022-09-16 18:54:00 +02:00
translations/floweepay-desktop_en.ts
translations/floweepay-desktop_nl.ts
translations/floweepay-desktop_pl.ts
2023-08-17 21:47:36 +02:00
translations/floweepay-desktop_de.ts
translations/floweepay-desktop_es.ts
2023-10-29 22:46:22 +01:00
translations/floweepay-desktop_pt.ts
2022-11-10 15:50:04 +01:00
2022-09-16 18:54:00 +02:00
translations/floweepay-common_en.ts
translations/floweepay-common_nl.ts
translations/floweepay-common_pl.ts
2023-08-17 21:47:36 +02:00
translations/floweepay-common_de.ts
translations/floweepay-common_es.ts
2023-10-29 22:46:22 +01:00
translations/floweepay-common_pt.ts
2023-03-02 18:04:01 +01:00
translations/floweepay-mobile_en.ts
2022-09-16 18:54:00 +02:00
translations/floweepay-mobile_nl.ts
translations/floweepay-mobile_pl.ts
2023-08-17 21:47:36 +02:00
translations/floweepay-mobile_de.ts
translations/floweepay-mobile_es.ts
2023-10-29 22:46:22 +01:00
translations/floweepay-mobile_pt.ts
translations/module-build-transaction_en.ts
2023-06-15 20:02:35 +02:00
translations/module-build-transaction_nl.ts
translations/module-build-transaction_pl.ts
2023-08-17 21:47:36 +02:00
translations/module-build-transaction_de.ts
translations/module-build-transaction_es.ts
2023-10-29 22:46:22 +01:00
translations/module-build-transaction_pt.ts
translations/module-peers-view_en.ts
translations/module-peers-view_nl.ts
translations/module-peers-view_pl.ts
2023-08-17 21:47:36 +02:00
translations/module-peers-view_de.ts
translations/module-peers-view_es.ts
2023-10-29 22:46:22 +01:00
translations/module-peers-view_pt.ts
2022-09-16 18:54:00 +02:00
)
2022-11-10 15:50:04 +01:00
qt6_add_translation(qmFiles ${TS_FILES})
2020-10-17 16:38:37 +02:00
2022-09-16 18:54:00 +02:00
add_custom_target(i18n
COMMAND lupdate guis/desktop.qrc -ts translations/floweepay-desktop.ts
COMMAND lupdate src guis/widgets.qrc
-ts translations/floweepay-common.ts
COMMAND lupdate guis/mobile.qrc -ts translations/floweepay-mobile.ts
2023-06-13 21:30:38 +02:00
COMMAND lupdate modules/build-transaction/build-transactions-data.qrc
modules/build-transaction/BuildTransactionModuleInfo.cpp
-ts translations/module-build-transaction.ts
COMMAND lupdate modules/peers-view/peers-page-data.qrc
modules/peers-view/PeersViewModuleInfo.cpp
-ts translations/module-peers-view.ts
2022-09-16 18:54:00 +02:00
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT
"Updating internationalization (i18n) translation files"
)
endif()
2021-11-20 22:20:08 +01:00
2023-11-03 16:10:11 +01:00
add_compile_definitions(LOG_DEFAULT_SECTION=10000)
add_compile_definitions(LOG_WALLET=10001)
if (NetworkLogClient)
add_compile_definitions(NETWORK_LOGGER)
2023-11-04 15:59:49 +01:00
elseif (ANDROID)
# include much less logging in the codebase, no point since we can't access it anyway
add_compile_definitions(BCH_NO_DEBUG_OUTPUT BCH_NO_INFO_OUTPUT BCH_NO_WARNING_OUTPUT)
2023-11-03 16:10:11 +01:00
endif()
2022-01-12 19:47:10 +01:00
###### Pay executable
2022-12-11 00:03:27 +01:00
include_directories(${CMAKE_SOURCE_DIR}/src)
2022-01-12 19:47:10 +01:00
2022-09-16 18:54:00 +02:00
if (NOT ANDROID)
set (NOT_ANDROID TRUE)
endif()
option (BUILD_DESKTOP_PAY
"Build the desktop (dev) client of Pay"
${NOT_ANDROID})
2022-11-28 16:21:42 +01:00
if (BUILD_DESKTOP_PAY)
2022-09-16 18:54:00 +02:00
# The qm files are generated in the build tree, but the qrc file is inside the
# source directory and the path to resources are relative to the location of
# the qrc file itself. We copy the qrc file in the build
2022-09-16 18:54:00 +02:00
# directory such that it can find the qm translations files. The qrc file is
# copied if it doesn't exist in the destination or if it is modified.
file(COPY translations/desktop-i18n.qrc DESTINATION ${CMAKE_BINARY_DIR})
2022-09-16 18:54:00 +02:00
if (local_qml)
2022-11-14 21:19:31 +01:00
set (QML_PATH ${CMAKE_SOURCE_DIR}/guis/)
2022-09-16 18:54:00 +02:00
endif()
2022-12-11 00:03:27 +01:00
configure_file(src/qml_path_helper.cpp.in guis/desktop/qml_path_helper.cpp)
set (SOURCES_PAY
2022-12-11 00:03:27 +01:00
src/main.cpp
2022-11-14 21:19:31 +01:00
guis/desktop/qml_path_helper.cpp
2023-06-11 19:06:16 +02:00
src/ModuleManager_empty.cpp # because we don't have modules in the desktop one
)
qt6_add_resources(SOURCES_PAY
2022-11-14 21:19:31 +01:00
guis/desktop.qrc
guis/widgets.qrc
${CMAKE_BINARY_DIR}/desktop-i18n.qrc
2022-09-16 18:54:00 +02:00
)
add_executable(pay ${SOURCES_PAY})
2022-11-13 21:56:44 +01:00
set_target_properties(pay PROPERTIES COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} DESKTOP")
target_link_libraries(pay PRIVATE pay_lib Qt6::Svg)
2022-09-16 18:54:00 +02:00
install(TARGETS pay DESTINATION bin)
endif()
2021-11-20 22:20:08 +01:00
2022-01-12 19:47:10 +01:00
###### Pay-mobile executable
2022-12-01 21:22:59 +01:00
option (BUILD_MOBILE_PAY "Build the mobile client of Pay" ON)
2023-06-15 14:53:22 +02:00
if (NOT "${Qt6Multimedia_FOUND}")
2022-12-01 21:22:59 +01:00
set (BUILD_MOBILE_PAY OFF)
endif ()
2022-01-12 19:47:10 +01:00
2023-06-11 19:06:16 +02:00
set (PAY_MOBILE_LIBS "")
2023-06-12 15:26:31 +02:00
set (PAY_MOBILE_RESOURCES "")
if (BUILD_MOBILE_PAY) # support modules, which get enabled currently for mobile only
2023-06-11 19:06:16 +02:00
add_subdirectory(modules)
# find all modules present in the source-tree and make sure we link them into the
# flowee-pay-mobile executable.
# Notice that the 'modules' subdir has similar code to actually compile these libs.
file(GLOB _module_sub_directories ${CMAKE_CURRENT_SOURCE_DIR}/modules/*)
foreach (child ${_module_sub_directories})
if (IS_DIRECTORY ${child} AND NOT IS_SYMLINK ${child})
file(GLOB subModule ${child}/*ModuleInfo.h)
file(RELATIVE_PATH moduleName ${CMAKE_CURRENT_SOURCE_DIR}/modules ${child})
list(APPEND PAY_MOBILE_LIBS "${moduleName}_module_lib")
2023-06-12 15:26:31 +02:00
file(GLOB resources ${child}/*qrc)
list(APPEND PAY_MOBILE_RESOURCES "${resources}")
2023-06-11 19:06:16 +02:00
endif()
endforeach()
include_directories(${CMAKE_SOURCE_DIR}/modules)
endif()
2022-11-10 15:50:04 +01:00
if (ANDROID AND BUILD_MOBILE_PAY)
2022-11-13 16:58:19 +01:00
# blockheaders to be included in the APK
2022-11-13 18:25:13 +01:00
set (ASSETS_DIR ${CMAKE_BINARY_DIR}/android-build/assets/)
if (NOT quick_deploy)
download_file(https://flowee.org/products/pay/blockheaders
${ASSETS_DIR}/blockheaders)
endif()
2022-11-13 18:25:13 +01:00
file(COPY ${CMAKE_SOURCE_DIR}/data/bip39-english
${CMAKE_SOURCE_DIR}/data/bip39-chinese_simplified
${CMAKE_SOURCE_DIR}/data/bip39-chinese_traditional
${CMAKE_SOURCE_DIR}/data/bip39-czech
${CMAKE_SOURCE_DIR}/data/bip39-french
${CMAKE_SOURCE_DIR}/data/bip39-italian
${CMAKE_SOURCE_DIR}/data/bip39-japanese
${CMAKE_SOURCE_DIR}/data/bip39-korean
${CMAKE_SOURCE_DIR}/data/bip39-portuguese
${CMAKE_SOURCE_DIR}/data/bip39-spanish
DESTINATION ${ASSETS_DIR})
2022-11-13 16:58:19 +01:00
2022-12-11 00:03:27 +01:00
configure_file(src/qml_path_helper.cpp.in guis/mobile/qml_path_helper.cpp)
set (SOURCES_PAY_MOBILE
2022-12-11 00:03:27 +01:00
src/main.cpp
src/CameraController.cpp
src/QRScanner.cpp
2022-11-14 21:19:31 +01:00
guis/mobile/qml_path_helper.cpp
2023-06-11 19:06:16 +02:00
${CMAKE_BINARY_DIR}/modules/modules-load.cpp
)
qt6_add_resources(SOURCES_PAY_MOBILE
2022-11-14 21:19:31 +01:00
guis/mobile.qrc
guis/widgets.qrc
2023-06-12 15:26:31 +02:00
${PAY_MOBILE_RESOURCES}
2022-09-16 18:54:00 +02:00
)
if (EXISTS "${CMAKE_BINARY_DIR}/floweepay-mobile_nl.qm")
message ("pay_mobile: Found pre-compiled translations")
file(COPY translations/mobile-i18n.qrc DESTINATION ${CMAKE_BINARY_DIR})
qt6_add_resources(SOURCES_PAY_MOBILE ${CMAKE_BINARY_DIR}/mobile-i18n.qrc)
endif()
qt6_add_executable(pay_mobile ${SOURCES_PAY_MOBILE})
2022-11-30 17:51:10 +01:00
target_link_libraries(pay_mobile PRIVATE pay_lib Qt6::Svg Qt6::Multimedia ${PAY_MOBILE_LIBS})
2022-11-10 15:50:04 +01:00
set_target_properties(pay_mobile PROPERTIES
2023-08-27 18:48:30 +02:00
QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/android
2022-11-13 21:56:44 +01:00
COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} MOBILE"
2023-05-31 15:12:17 +02:00
)
2022-11-10 15:50:04 +01:00
endif ()
if(NOT ANDROID AND BUILD_MOBILE_PAY)
if(local_qml)
2022-11-14 21:19:31 +01:00
set (QML_PATH ${CMAKE_SOURCE_DIR}/guis)
2022-11-10 15:50:04 +01:00
endif()
2022-12-11 00:03:27 +01:00
configure_file(src/qml_path_helper.cpp.in guis/mobile/qml_path_helper.cpp)
file(COPY translations/mobile-i18n.qrc DESTINATION ${CMAKE_BINARY_DIR})
2022-11-10 15:50:04 +01:00
set (SOURCES_PAY_MOBILE
2022-12-11 00:03:27 +01:00
src/main.cpp
src/CameraController.cpp
src/QRScanner.cpp
2023-06-11 19:06:16 +02:00
${CMAKE_BINARY_DIR}/modules/modules-load.cpp
2022-11-14 21:19:31 +01:00
guis/mobile/qml_path_helper.cpp
)
qt6_add_resources(SOURCES_PAY_MOBILE
2022-11-14 21:19:31 +01:00
guis/mobile.qrc
guis/widgets.qrc
${CMAKE_BINARY_DIR}/mobile-i18n.qrc
2023-06-12 15:26:31 +02:00
${PAY_MOBILE_RESOURCES}
2022-11-10 15:50:04 +01:00
)
add_executable(pay_mobile ${SOURCES_PAY_MOBILE})
2022-11-13 21:56:44 +01:00
set_target_properties(pay_mobile PROPERTIES
COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS} MOBILE"
)
2023-06-11 19:06:16 +02:00
target_link_libraries(pay_mobile PRIVATE pay_lib Qt6::Svg Qt6::Multimedia ${PAY_MOBILE_LIBS})
2022-09-16 18:54:00 +02:00
install(TARGETS pay_mobile DESTINATION bin)
endif()
2022-01-12 19:47:10 +01:00
###### blockheaders-meta-extractor executable
2022-09-16 18:54:00 +02:00
option (BUILD_PAY_TOOLS
"Build the tools Pay"
${NOT_ANDROID})
2022-11-10 15:50:04 +01:00
if (BUILD_PAY_TOOLS)
2022-09-16 18:54:00 +02:00
add_executable(blockheaders-meta-extractor
2022-12-11 00:03:27 +01:00
src/MetaExtractor.cpp
2022-09-16 18:54:00 +02:00
)
target_link_libraries(blockheaders-meta-extractor
flowee_p2p
flowee_utils
${OPENSSL_LIBRARIES}
${Boost_LIBRARIES}
)
install(TARGETS blockheaders-meta-extractor DESTINATION bin)
endif()
2022-01-12 19:47:10 +01:00
2022-11-14 21:19:31 +01:00
install(PROGRAMS guis/desktop/org.flowee.pay.desktop DESTINATION share/applications)
set (ICONIN guis/desktop/icons/hicolor/)
2021-11-20 22:20:08 +01:00
set (ICONOUT share/icons/hicolor/)
install(FILES ${ICONIN}16x16/apps/org.flowee.pay.png DESTINATION ${ICONOUT}16x16/apps)
install(FILES ${ICONIN}22x22/apps/org.flowee.pay.png DESTINATION ${ICONOUT}22x22/apps)
install(FILES ${ICONIN}24x24/apps/org.flowee.pay.png DESTINATION ${ICONOUT}24x24/apps)
install(FILES ${ICONIN}32x32/apps/org.flowee.pay.png DESTINATION ${ICONOUT}32x32/apps)
install(FILES ${ICONIN}48x48/apps/org.flowee.pay.png DESTINATION ${ICONOUT}48x48/apps)
install(FILES ${ICONIN}256x256/apps/org.flowee.pay.png DESTINATION ${ICONOUT}256x256/apps)
install(FILES ${CMAKE_SOURCE_DIR}/data/bip39-english DESTINATION share/floweepay)
if (EXISTS ${CMAKE_SOURCE_DIR}/data/blockheaders)
install(FILES ${CMAKE_SOURCE_DIR}/data/blockheaders DESTINATION share/floweepay)
endif()
2022-12-11 00:03:27 +01:00
add_subdirectory(src)
2022-09-16 18:54:00 +02:00
if (NOT ANDROID)
add_subdirectory(testing)
endif()
2022-04-29 22:43:46 +02:00
# Report ------
message("")
message("Configuration results:")
message("----------------------")
2023-06-23 12:48:22 +02:00
message("Target OS: ${CMAKE_SYSTEM_NAME}")
message("Qt version: ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
2022-11-28 16:21:42 +01:00
if (${local_qml})
message(" Using QML from source-dir. DO NOT DISTRIBUTE BINARIES!")
endif ()
2022-09-16 18:54:00 +02:00
if (${BUILD_DESKTOP_PAY})
message ("-> Building Desktop-Pay...")
if (${Qt6DBus_FOUND})
message(" Found optional lib: QtDBus")
else ()
message(" Missing QtDBus, skipping support for desktop notifications")
endif ()
endif()
2022-12-04 14:21:21 +01:00
if (NOT ${Qt6Multimedia_FOUND})
2022-12-01 21:22:59 +01:00
message("ww Missing QtMultimedia libs, not building Pay for mobile ")
endif ()
2022-09-16 18:54:00 +02:00
if (${BUILD_MOBILE_PAY})
message ("-> Building Pay for mobile")
2022-11-10 15:50:04 +01:00
if (ANDROID AND DEFINED MOBILE_PAY_I18N_QRC)
message (" Found translation files, including in package")
endif ()
2022-09-16 18:54:00 +02:00
endif()
2023-11-03 16:10:11 +01:00
if (NetworkLogClient)
message ("-> Including network-logging capability")
endif()
2022-09-16 18:54:00 +02:00
if (${BUILD_PAY_TOOLS})
message ("-> Building Pay tools")
endif()
2022-04-29 22:43:46 +02:00
if (${BUILD_MOBILE_PAY})
file(GLOB sub_directories ${CMAKE_SOURCE_DIR}/modules/*)
foreach (child ${sub_directories})
if (IS_DIRECTORY ${child})
file(GLOB subModule ${child}/*ModuleInfo.h)
if (EXISTS ${subModule})
file (RELATIVE_PATH module ${CMAKE_CURRENT_SOURCE_DIR} ${child})
message("-> Including module '${module}'")
get_filename_component(className ${subModule} NAME_WE)
message(" ${className}")
endif()
2023-06-23 12:48:22 +02:00
endif()
endforeach()
endif()
2023-06-23 12:48:22 +02:00
2022-04-29 22:43:46 +02:00
message("")
message("")