diff --git a/CMakeLists.txt b/CMakeLists.txt index 99a736d14e..33c0fd526f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,79 +1,79 @@ # Copyright (c) 2017 The Bitcoin developers cmake_minimum_required(VERSION 3.13) set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_SOURCE_DIR}/cmake/modules/OverrideInitFlags.cmake" ) project(bitcoin-abc VERSION 0.20.13 DESCRIPTION "Bitcoin ABC is a full node implementation of the Bitcoin Cash protocol." HOMEPAGE_URL "https://www.bitcoinabc.org" ) # Package information set(PACKAGE_NAME "Bitcoin ABC") # Copyright set(COPYRIGHT_YEAR 2019) set(COPYRIGHT_HOLDERS "The %s developers") set(COPYRIGHT_HOLDERS_SUBSTITUTION Bitcoin) string(REPLACE "%s" ${COPYRIGHT_HOLDERS_SUBSTITUTION} COPYRIGHT_HOLDERS_FINAL ${COPYRIGHT_HOLDERS}) # Add path for custom modules list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) # Make contrib script accessible. set(CONTRIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/contrib) # Default to RelWithDebInfo configuration if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Select the configuration for the build" FORCE) endif() # Find the python interpreter. This is required for several targets. -find_package(PythonInterp 3.5 REQUIRED) +find_package(Python 3.5 COMPONENTS Interpreter REQUIRED) # Add the magic targets `check-*` add_custom_target(check-all) add_custom_target(check) add_custom_target(check-extended) add_custom_target(check-upgrade-activated) add_custom_target(check-upgrade-activated-extended) add_custom_target(check-symbols) add_custom_target(check-security) include(PackageHelper) exclude_git_ignored_files_from_source_package() # Ignore hidden files and directories (starting with a '.') set_property(GLOBAL APPEND PROPERTY SOURCE_PACKAGE_IGNORE_FILES "/\\\\.") # If the build is out-of-tree, then the build directory can be ignored. if(NOT CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) set_property(GLOBAL APPEND PROPERTY SOURCE_PACKAGE_IGNORE_FILES "${CMAKE_BINARY_DIR}/" ) endif() exclude_from_source_package( # Subdirectories "arcanist/" "depends/" # Files "[^.]+[.]md$" "Dockerfile-doxygen" ) add_subdirectory(src) add_subdirectory(test) add_subdirectory(contrib) add_subdirectory(doc) include(PackageOptions) get_property(CPACK_SOURCE_IGNORE_FILES GLOBAL PROPERTY SOURCE_PACKAGE_IGNORE_FILES) include(CPack) diff --git a/cmake/modules/BinaryTest.cmake b/cmake/modules/BinaryTest.cmake index 4db5590c23..a175bac3a7 100644 --- a/cmake/modules/BinaryTest.cmake +++ b/cmake/modules/BinaryTest.cmake @@ -1,37 +1,37 @@ # Facilities to run tests on the executable binaries. macro(add_to_symbols_check BINARY) set(CUSTOM_TARGET_NAME "check-symbols-${BINARY}") add_custom_target("${CUSTOM_TARGET_NAME}" COMMAND ${CMAKE_COMMAND} -E echo "Running symbol-check.py on ${BINARY}..." COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/contrib/devtools/symbol-check.py" "$" DEPENDS "${BINARY}" ) if(TARGET check-symbols) add_dependencies(check-symbols "${CUSTOM_TARGET_NAME}") endif() endmacro() macro(add_to_security_check BINARY) set(CUSTOM_TARGET_NAME "check-security-${BINARY}") add_custom_target("${CUSTOM_TARGET_NAME}" COMMAND ${CMAKE_COMMAND} -E echo "Running security-check.py on ${BINARY}..." COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/contrib/devtools/security-check.py" "$" DEPENDS "${BINARY}" ) if(TARGET check-security) add_dependencies(check-security "${CUSTOM_TARGET_NAME}") endif() endmacro() diff --git a/contrib/devtools/CMakeLists.txt b/contrib/devtools/CMakeLists.txt index 762c295485..19005cf9f6 100644 --- a/contrib/devtools/CMakeLists.txt +++ b/contrib/devtools/CMakeLists.txt @@ -1,61 +1,61 @@ # Copyright (c) 2019 The Bitcoin developers set(SPLIT_DEBUG_SCRIPT_TMP "tmp/split-debug.sh") configure_file( "split-debug.sh.cmake.in" "${SPLIT_DEBUG_SCRIPT_TMP}" ) # Make the script executable by copying to the current build directory file(COPY "${CMAKE_CURRENT_BINARY_DIR}/${SPLIT_DEBUG_SCRIPT_TMP}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}" FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE ) add_custom_target(check-devtools) set(DEVTOOLS_TESTS_PYTHON ./chainparams/test_make_chainparams.py ) foreach(TEST ${DEVTOOLS_TESTS_PYTHON}) get_filename_component(TESTNAME ${TEST} NAME) get_filename_component(TESTPATH ${TEST} ABSOLUTE ${CMAKE_CURRENT_SOURCE_DIR}) get_filename_component(WORKDIR ${TESTPATH} DIRECTORY) add_custom_target("check-devtools-${TESTNAME}" WORKING_DIRECTORY ${WORKDIR} COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "./${TESTNAME}" ) add_dependencies(check-devtools "check-devtools-${TESTNAME}") endforeach() add_dependencies(check check-devtools) add_dependencies(check-all check-devtools) include(PackageHelper) exclude_from_source_package( # Files "bitcoind-exit-on-log.sh" "circular-dependencies.py" "copyright_header.py" "extract_strings_qt.py" "gitian-build.py" "optimize-pngs.py" "README.md" "test-security-check.py" "update-translations.py" ) diff --git a/src/bench/CMakeLists.txt b/src/bench/CMakeLists.txt index 8b78e740c6..afb517a7da 100644 --- a/src/bench/CMakeLists.txt +++ b/src/bench/CMakeLists.txt @@ -1,67 +1,67 @@ # Copyright (c) 2018 The Bitcoin developers project(bitcoin-bench) set(BENCH_DATA_RAW_FILES data/block413567.raw ) # Process raw files. file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/data") foreach(_raw_file ${BENCH_DATA_RAW_FILES}) string(APPEND _generated_header_output "${CMAKE_CURRENT_BINARY_DIR}/${_raw_file}" ".h" ) list(APPEND BENCH_DATA_GENERATED_HEADERS ${_generated_header_output}) get_filename_component(_test_name ${_raw_file} NAME_WE) add_custom_command( OUTPUT "${_generated_header_output}" COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "data/convert-raw-to-header.py" "${_test_name}" "${_raw_file}" > "${_generated_header_output}" COMMENT "Transforming raw file ${_raw_file} into header" MAIN_DEPEDENCY "${_raw_file}" DEPENDS "data/convert-raw-to-header.py" VERBATIM WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) endforeach() add_executable(bitcoin-bench EXCLUDE_FROM_ALL base58.cpp bench.cpp bench_bitcoin.cpp cashaddr.cpp ccoins_caching.cpp checkblock.cpp checkqueue.cpp crypto_aes.cpp crypto_hash.cpp duplicate_inputs.cpp examples.cpp gcs_filter.cpp lockedpool.cpp mempool_eviction.cpp merkle_root.cpp prevector.cpp rollingbloom.cpp rpc_mempool.cpp # Add the generated headers to trigger the conversion command ${BENCH_DATA_GENERATED_HEADERS} ) target_link_libraries(bitcoin-bench common bitcoinconsensus wallet server) if(BUILD_BITCOIN_WALLET) target_sources(bitcoin-bench PRIVATE coin_selection.cpp) endif() add_custom_target(bench-bitcoin COMMAND bitcoin-bench USES_TERMINAL) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index f8f9851220..6aed7084b2 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -1,589 +1,589 @@ # Copyright (c) 2018 The Bitcoin developers project(bitcoin-qt) # This ensure that AUTOMOC doesn't run on generated files. cmake_policy(SET CMP0071 OLD) include(BrewHelper) find_brew_prefix(QT5_PREFIX qt5) set(QT_REQUIRED_COMPONENTS Core Widgets Network Test) if(ENABLE_NOTIFICATIONS) list(APPEND QT_REQUIRED_COMPONENTS DBus) endif() find_package(Qt5 5.5.1 COMPONENTS ${QT_REQUIRED_COMPONENTS} REQUIRED HINTS "${QT5_PREFIX}") # Localisation add_subdirectory(locale) add_custom_command(OUTPUT temp_bitcoin_locale.qrc COMMAND cmake ARGS -E copy "${CMAKE_CURRENT_SOURCE_DIR}/bitcoin_locale.qrc" temp_bitcoin_locale.qrc MAIN_DEPENDENCY bitcoin_locale.qrc VERBATIM ) add_custom_command(OUTPUT qrc_bitcoin_locale.cpp COMMAND Qt5::rcc ARGS temp_bitcoin_locale.qrc -name bitcoin_locale -o qrc_bitcoin_locale.cpp MAIN_DEPENDENCY temp_bitcoin_locale.qrc DEPENDS locales VERBATIM ) # UI elements # qt5_wrap_ui() generates the files in the CMAKE_CURRENT_BINARY_DIR. As there # is no option to change the output directory, moving the files to the forms # subdirectory requires to override the variable. It is reset to its actual # value after the call so it does not impact the other sections of this # CMakeLists.txt file. set(SAVE_CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/forms") qt5_wrap_ui(UI_GENERATED_HEADERS forms/addressbookpage.ui forms/askpassphrasedialog.ui forms/coincontroldialog.ui forms/editaddressdialog.ui forms/helpmessagedialog.ui forms/intro.ui forms/modaloverlay.ui forms/openuridialog.ui forms/optionsdialog.ui forms/overviewpage.ui forms/receivecoinsdialog.ui forms/receiverequestdialog.ui forms/debugwindow.ui forms/sendcoinsdialog.ui forms/sendcoinsentry.ui forms/signverifymessagedialog.ui forms/transactiondescdialog.ui ) set(CMAKE_CURRENT_BINARY_DIR ${SAVE_CMAKE_CURRENT_BINARY_DIR}) # Qt MOC set(CMAKE_AUTOMOC ON) # Handle qrc resources qt5_add_resources(QRC_BITCOIN_CPP bitcoin.qrc) add_library(bitcoin-qt-base bantablemodel.cpp bitcoin.cpp bitcoinaddressvalidator.cpp bitcoinamountfield.cpp bitcoingui.cpp bitcoinunits.cpp clientmodel.cpp csvmodelwriter.cpp guiutil.cpp intro.cpp modaloverlay.cpp networkstyle.cpp notificator.cpp optionsdialog.cpp optionsmodel.cpp peertablemodel.cpp platformstyle.cpp qvalidatedlineedit.cpp qvaluecombobox.cpp rpcconsole.cpp splashscreen.cpp trafficgraphwidget.cpp utilitydialog.cpp # Handle ui files ${UI_GENERATED_HEADERS} # Translations ${BITCOIN_QM_FILES} # Handle qrc files ${QRC_BITCOIN_CPP} qrc_bitcoin_locale.cpp ) # 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) # Linux support if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") list(APPEND QT_PLUGIN_COMPONENTS QXcbIntegrationPlugin) list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_XCB=1) endif() # Windows support if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") list(APPEND QT_PLUGIN_COMPONENTS QWindowsIntegrationPlugin) list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_WINDOWS=1) target_sources(bitcoin-qt-base PRIVATE winshutdownmonitor.cpp) endif() # OSX support if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") list(APPEND QT_PLUGIN_COMPONENTS QCocoaIntegrationPlugin) list(APPEND QT_PLUGIN_PLATFORM_DEFINITIONS -DQT_QPA_PLATFORM_COCOA=1) target_sources(bitcoin-qt-base PRIVATE macdockiconhandler.mm macnotificationhandler.mm ) set_property(TARGET bitcoin-qt-base PROPERTY AUTOMOC_MOC_OPTIONS "-DQ_OS_MAC") target_link_libraries(bitcoin-qt-base "-framework Foundation" "-framework ApplicationServices" "-framework AppKit" ) endif() # Find out more about Qt. This is similar to # http://code.qt.io/cgit/qt/qtwebkit.git/tree/Source/cmake/OptionsQt.cmake get_target_property(QT_CORE_TYPE Qt5::Core TYPE) if(QT_CORE_TYPE MATCHES STATIC) set(QT_STATIC_BUILD ON) endif() # Determine the Qt libraries directory from the QT5::Core library location get_target_property(QT_CORE_LIB_LOCATION Qt5::Core LOCATION) 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) list(APPEND QT_REQUIRED_COMPONENTS ${QT_PLUGIN_COMPONENTS}) 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) # 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 also be static and we # need to define QT_STATICPLUGIN to tell the code to import . 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() target_link_libraries(bitcoin-qt-base server rpcclient Qt5::Widgets Qt5::Network ) if(ENABLE_NOTIFICATIONS) target_link_libraries(bitcoin-qt-base Qt5::DBus) endif() if(ENABLE_BIP70) # Do protobuf codegen find_package(Protobuf REQUIRED) protobuf_generate_cpp(PROTOBUF_SOURCES PROTOBUF_HEADERS paymentrequest.proto) add_library(bitcoin-qt-protobuf OBJECT # Protobuf codegen ${PROTOBUF_HEADERS} ${PROTOBUF_SOURCES} ) target_include_directories(bitcoin-qt-protobuf PUBLIC ${Protobuf_INCLUDE_DIRS}) target_link_libraries(bitcoin-qt-protobuf ${Protobuf_LIBRARIES}) # Don't run clang-tidy on generated files if(ENABLE_CLANG_TIDY) include(ClangTidy) target_disable_clang_tidy(bitcoin-qt-protobuf) endif() target_link_libraries(bitcoin-qt-base OpenSSL::SSL bitcoin-qt-protobuf ) endif() # Wallet if(BUILD_BITCOIN_WALLET) # Automoc option. set(AUTOMOC_MOC_OPTIONS -DENABLE_WALLET=1) # Add wallet functionality to bitcoin-qt target_sources(bitcoin-qt-base PRIVATE addressbookpage.cpp addresstablemodel.cpp askpassphrasedialog.cpp coincontroldialog.cpp coincontroltreewidget.cpp editaddressdialog.cpp openuridialog.cpp overviewpage.cpp paymentserver.cpp receivecoinsdialog.cpp receiverequestdialog.cpp recentrequeststablemodel.cpp sendcoinsdialog.cpp sendcoinsentry.cpp signverifymessagedialog.cpp transactiondesc.cpp transactiondescdialog.cpp transactionfilterproxy.cpp transactionrecord.cpp transactiontablemodel.cpp transactionview.cpp walletcontroller.cpp walletframe.cpp walletmodel.cpp walletmodeltransaction.cpp walletview.cpp ) # Add BIP70 functionality to bitcoin-qt if(ENABLE_BIP70) target_sources(bitcoin-qt-base PRIVATE paymentrequestplus.cpp ) endif() target_link_libraries(bitcoin-qt-base wallet) if(ENABLE_QRCODE) target_include_directories(bitcoin-qt-base PUBLIC ${QRENCODE_INCLUDE_DIR}) target_link_libraries(bitcoin-qt-base ${QRENCODE_LIBRARY}) endif() endif() # The executable add_executable(bitcoin-qt WIN32 main.cpp) if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") target_sources(bitcoin-qt PRIVATE res/bitcoin-qt-res.rc) endif() target_link_libraries(bitcoin-qt bitcoin-qt-base) include(BinaryTest) add_to_symbols_check(bitcoin-qt) add_to_security_check(bitcoin-qt) include(InstallationHelper) install_target(bitcoin-qt) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(BITCOINQT_BUNDLE_ICON "res/icons/bitcoin.icns") get_filename_component(BITCOINQT_BUNDLE_ICON_NAME "${BITCOINQT_BUNDLE_ICON}" NAME ) set(INFO_PLIST_STRINGS_FILE "Base.lproj/InfoPlist.strings") set(INFO_PLIST_STRINGS_PATH "${CMAKE_CURRENT_BINARY_DIR}/${INFO_PLIST_STRINGS_FILE}") file(WRITE "${INFO_PLIST_STRINGS_PATH}" "{ CFBundleDisplayName = \"${PACKAGE_NAME}\"; CFBundleName = \"${PACKAGE_NAME}\"; }" ) set(EMPTY_LPROJ_FILE "${CMAKE_CURRENT_BINARY_DIR}/empty.lproj") file(TOUCH "${EMPTY_LPROJ_FILE}") target_sources(bitcoin-qt PRIVATE "${BITCOINQT_BUNDLE_ICON}" "${INFO_PLIST_STRINGS_PATH}" "${EMPTY_LPROJ_FILE}" ) string(JOIN ";" BITCOINQT_BUNDLE_RESOURCES "${BITCOINQT_BUNDLE_ICON}" "${EMPTY_LPROJ_FILE}" ) set(BITCOIN_QT_OSX_BUNDLE_NAME "BitcoinABC-Qt") set_target_properties(bitcoin-qt PROPERTIES MACOSX_BUNDLE ON OUTPUT_NAME "${BITCOIN_QT_OSX_BUNDLE_NAME}" MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/share/qt/Info.plist.cmake.in" MACOSX_BUNDLE_BUNDLE_NAME "${BITCOIN_QT_OSX_BUNDLE_NAME}" MACOSX_BUNDLE_BUNDLE_VERSION "${bitcoin-abc_VERSION}" MACOSX_BUNDLE_GUI_IDENTIFIER "org.bitcoinabc.${BITCOIN_QT_OSX_BUNDLE_NAME}" MACOSX_BUNDLE_ICON_FILE "${BITCOINQT_BUNDLE_ICON_NAME}" MACOSX_BUNDLE_INFO_STRING "${bitcoin-abc_VERSION}, Copyright © 2009-${COPYRIGHT_YEAR} ${COPYRIGHT_HOLDERS_FINAL}" MACOSX_BUNDLE_LONG_VERSION_STRING "${bitcoin-abc_VERSION}" MACOSX_BUNDLE_SHORT_VERSION_STRING "${bitcoin-abc_VERSION}" RESOURCE "${BITCOINQT_BUNDLE_RESOURCES}" ) # The InfoPlist.strings files should be located in a resource subdirectory. # This is not supported by the RESOURCE property and require the use of the # MACOSX_PACKAGE_LOCATION property instead. The RESOURCE documentation has # an example demonstrating this behavior (see the appres.txt file): # https://cmake.org/cmake/help/latest/prop_tgt/RESOURCE.html set_source_files_properties( "${INFO_PLIST_STRINGS_PATH}" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/${INFO_PLIST_STRINGS_FILE}" ) # Create a stripped version of the application bundle to be used in the DMG. # Since the LOCATION property and the BundleUtilities package are deprecated # by cmake, only generator expressions can be used to determine the path to # the bundle and its executable. However the generator expressions are # solved at build time, making them unusable to do path computation at # configuration time. # The paths here are then hard-coded, which is safe since the structure of # an application bundle is well-known and specified by Apple. Note that this # will only work for building MacOS application bundle as the IOS structure # is slightly different. set(STRIPPED_BUNDLE "${CMAKE_CURRENT_BINARY_DIR}/stripped/${BITCOIN_QT_OSX_BUNDLE_NAME}.app") add_custom_command( OUTPUT "${STRIPPED_BUNDLE}" COMMAND ${CMAKE_COMMAND} -E copy_directory "$" "${STRIPPED_BUNDLE}" COMMAND ${CMAKE_STRIP} -u -r "${STRIPPED_BUNDLE}/Contents/MacOS/${BITCOIN_QT_OSX_BUNDLE_NAME}" DEPENDS bitcoin-qt ) include(DoOrFail) find_program_or_fail(CMAKE_INSTALL_NAME_TOOL "install_name_tool") find_program_or_fail(CMAKE_OTOOL "otool") set(QT_INSTALLER_SUPPORTED_LANGUAGES "da" "de" "es" "hu" "ru" "uk" "zh_CN" "zh_TW" ) string(JOIN "," QT_LOCALES ${QT_INSTALLER_SUPPORTED_LANGUAGES}) get_target_property(QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION) execute_process( COMMAND "${QMAKE_EXECUTABLE}" -query QT_INSTALL_TRANSLATIONS OUTPUT_VARIABLE QT_TRANSLATION_DIR OUTPUT_STRIP_TRAILING_WHITESPACE ) function(get_qt_translation_dir QT_TRANSLATION_DIR) foreach(_locale ${ARGN}) find_path(_qt_translation_dir "qt_${_locale}.qm" HINTS "${QT_TRANSLATION_DIR}" PATH_SUFFIXES "translations" ) # Ensure that all the translation files are found, and are located # in the same directory. if(NOT _qt_translation_dir OR (_qt_translation_dir_previous AND (NOT _qt_translation_dir_previous STREQUAL _qt_translation_dir))) return() endif() set(_qt_translation_dir_previous _qt_translation_dir) endforeach() set(QT_TRANSLATION_DIR ${_qt_translation_dir} PARENT_SCOPE) endfunction() get_qt_translation_dir(QT_TRANSLATION_DIR ${QT_INSTALLER_SUPPORTED_LANGUAGES}) if(NOT QT_TRANSLATION_DIR) message(FATAL_ERROR "Qt translation files are not found") endif() set(MACDEPLOY_DIR "${CMAKE_SOURCE_DIR}/contrib/macdeploy") set(MACDEPLOYQTPLUS "${MACDEPLOY_DIR}/macdeployqtplus") set(DMG_DIST "${CMAKE_BINARY_DIR}/dist") add_custom_command( OUTPUT "${DMG_DIST}" COMMAND "INSTALLNAMETOOL=${CMAKE_INSTALL_NAME_TOOL}" "OTOOL=${CMAKE_OTOOL}" "STRIP=${CMAKE_STRIP}" - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "${MACDEPLOYQTPLUS}" "${STRIPPED_BUNDLE}" -translations-dir "${QT_TRANSLATION_DIR}" -add-qt-tr "${QT_LOCALES}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" DEPENDS "${STRIPPED_BUNDLE}" ) # Building the DMG background image requires several steps: # 1/ The SVG file must be edited to display the package name # 2/ The SVG file should be transformed into a couple PNG files, on for # low resolution screens and one for high resolution screens. # 3/ The PNG files must be transformed into a multi-resolution TIFF file. # The names are not set arbitrarily, they follow Apple's guidelines for # resolution independent bitmap images (see `man tiffutil`). set(BACKGROUND_SVG "background.svg") configure_file( "${CMAKE_SOURCE_DIR}/contrib/macdeploy/background.svg.cmake.in" "${BACKGROUND_SVG}" ) include(ImageHelper) set(BACKGROUND_PNG_LOWRES "${CMAKE_CURRENT_BINARY_DIR}/background_temp.png") set(BACKGROUND_PNG_HIRES "${CMAKE_CURRENT_BINARY_DIR}/background_temp@2x.png") set(BACKGROUND_TIFF_LOWRES "${CMAKE_CURRENT_BINARY_DIR}/background_temp.tiff") set(BACKGROUND_TIFF_HIRES "${CMAKE_CURRENT_BINARY_DIR}/background_temp@2x.tiff") set(BACKGROUND_TIFF_NAME "background.tiff") set(BACKGROUND_TIFF_MULTIRES "${CMAKE_BINARY_DIR}/${BACKGROUND_TIFF_NAME}") convert_svg_to_png("${BACKGROUND_SVG}" "${BACKGROUND_PNG_LOWRES}" 36) convert_svg_to_png("${BACKGROUND_SVG}" "${BACKGROUND_PNG_HIRES}" 72) convert_png_to_tiff("${BACKGROUND_PNG_LOWRES}" "${BACKGROUND_TIFF_LOWRES}") convert_png_to_tiff("${BACKGROUND_PNG_HIRES}" "${BACKGROUND_TIFF_HIRES}") cat_multi_resolution_tiff("${BACKGROUND_TIFF_MULTIRES}" "${BACKGROUND_TIFF_LOWRES}" "${BACKGROUND_TIFF_HIRES}") set(BACKGROUND_DIST_DIR "${DMG_DIST}/.background") set(BACKGROUND_DIST_TIFF "${BACKGROUND_DIST_DIR}/${BACKGROUND_TIFF_NAME}") add_custom_command( OUTPUT "${BACKGROUND_DIST_TIFF}" COMMAND ${CMAKE_COMMAND} -E make_directory "${BACKGROUND_DIST_DIR}" COMMAND ${CMAKE_COMMAND} -E copy "${BACKGROUND_TIFF_MULTIRES}" "${BACKGROUND_DIST_TIFF}" DEPENDS "${BACKGROUND_TIFF_MULTIRES}" "${DMG_DIST}" ) string(REPLACE " " "-" OSX_VOLNAME "${PACKAGE_NAME}") file(WRITE "${CMAKE_BINARY_DIR}/osx_volname" "${OSX_VOLNAME}") set(DMG_DSSTORE "${DMG_DIST}/.DS_Store") set(GEN_DSSTORE "${MACDEPLOY_DIR}/custom_dsstore.py") add_custom_command( OUTPUT "${DMG_DSSTORE}" COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "${GEN_DSSTORE}" "${DMG_DSSTORE}" "${OSX_VOLNAME}" DEPENDS "${GEN_DSSTORE}" "${DMG_DIST}" ) set(OSX_APPLICATION_DIR "Applications") set(OSX_APPLICATION_SYMLINK "${DMG_DIST}/${OSX_APPLICATION_DIR}") add_custom_command( OUTPUT "${OSX_APPLICATION_SYMLINK}" COMMAND ${CMAKE_COMMAND} -E create_symlink "/${OSX_APPLICATION_DIR}" "${OSX_APPLICATION_SYMLINK}" DEPENDS "${DMG_DIST}" ) add_custom_target(osx-deploydir DEPENDS "${OSX_APPLICATION_SYMLINK}" "${DMG_DSSTORE}" "${BACKGROUND_DIST_TIFF}" ) if(CMAKE_CROSSCOMPILING) find_program_or_fail(GENISOIMAGE_EXECUTABLE genisoimage) add_custom_target(osx-dmg COMMAND "${GENISOIMAGE_EXECUTABLE}" -no-cache-inodes -D -l -probe -V "${OSX_VOLNAME}" -no-pad -r -dir-mode 0755 -apple -o "${OSX_VOLNAME}.dmg" "${DMG_DIST}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" ) add_dependencies(osx-dmg osx-deploydir) else() add_custom_target(osx-dmg COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "${MACDEPLOYQTPLUS}" "${STRIPPED_BUNDLE}" -translations-dir "${QT_TRANSLATION_DIR}" -add-qt-tr "${QT_LOCALES}" -dmg -fancy "${MACDEPLOY_DIR}/fancy.plist" -volname "${OSX_VOLNAME}" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" DEPENDS "${STRIPPED_BUNDLE}" "${BACKGROUND_TIFF_MULTIRES}" ) endif() endif() # Test tests add_subdirectory(test) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 82542b78c3..959a52f232 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,191 +1,191 @@ # Copyright (c) 2018 The Bitcoin developers project(bitcoin-test) # Process json files. file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/data") function(gen_json_header NAME) set(HEADERS "") foreach(f ${ARGN}) set(h "${CMAKE_CURRENT_BINARY_DIR}/${f}.h") # Get the proper name for the test variable. get_filename_component(TEST_NAME ${f} NAME_WE) add_custom_command(OUTPUT ${h} COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/data/generate_header.py" "${TEST_NAME}" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" > ${h} MAIN_DEPENDENCY ${f} DEPENDS "data/generate_header.py" VERBATIM ) list(APPEND HEADERS ${h}) endforeach(f) set(${NAME} "${HEADERS}" PARENT_SCOPE) endfunction() gen_json_header(JSON_HEADERS data/base58_encode_decode.json data/blockfilters.json data/key_io_valid.json data/key_io_invalid.json data/script_tests.json data/sighash.json data/tx_invalid.json data/tx_valid.json ) include(TestSuite) create_test_suite(bitcoin) add_dependencies(check check-bitcoin) if(BUILD_BITCOIN_WALLET) set(BITCOIN_WALLET_TEST_FIXTURE ../wallet/test/init_test_fixture.cpp ../wallet/test/wallet_test_fixture.cpp ) set(BITCOIN_WALLET_TESTS ../wallet/test/accounting_tests.cpp ../wallet/test/db_tests.cpp ../wallet/test/coinselector_tests.cpp ../wallet/test/init_tests.cpp ../wallet/test/psbt_wallet_tests.cpp ../wallet/test/wallet_tests.cpp ../wallet/test/walletdb_tests.cpp ../wallet/test/wallet_crypto_tests.cpp ) endif() add_boost_unit_tests_to_suite(bitcoin test_bitcoin jsonutil.cpp scriptflags.cpp sigutil.cpp test_bitcoin.cpp test_bitcoin_main.cpp # Tests generated from JSON ${JSON_HEADERS} # Wallet test fixture ${BITCOIN_WALLET_TEST_FIXTURE} TESTS activation_tests.cpp addrman_tests.cpp allocator_tests.cpp amount_tests.cpp arith_uint256_tests.cpp avalanche_tests.cpp base32_tests.cpp base58_tests.cpp base64_tests.cpp bip32_tests.cpp bitmanip_tests.cpp blockchain_tests.cpp blockcheck_tests.cpp blockencodings_tests.cpp blockfilter_tests.cpp blockindex_tests.cpp blockstatus_tests.cpp bloom_tests.cpp bswap_tests.cpp cashaddr_tests.cpp cashaddrenc_tests.cpp checkdatasig_tests.cpp checkpoints_tests.cpp checkqueue_tests.cpp coins_tests.cpp compress_tests.cpp config_tests.cpp core_io_tests.cpp crypto_tests.cpp cuckoocache_tests.cpp dbwrapper_tests.cpp denialofservice_tests.cpp descriptor_tests.cpp dstencode_tests.cpp excessiveblock_tests.cpp feerate_tests.cpp finalization_tests.cpp flatfile_tests.cpp getarg_tests.cpp hash_tests.cpp inv_tests.cpp key_io_tests.cpp key_tests.cpp lcg_tests.cpp limitedmap_tests.cpp mempool_policy_tests.cpp mempool_tests.cpp merkle_tests.cpp merkleblock_tests.cpp miner_tests.cpp monolith_opcodes_tests.cpp multisig_tests.cpp net_tests.cpp netbase_tests.cpp op_reversebytes_tests.cpp pmt_tests.cpp policyestimator_tests.cpp pow_tests.cpp prevector_tests.cpp radix_tests.cpp raii_event_tests.cpp random_tests.cpp rcu_tests.cpp reverselock_tests.cpp rpc_tests.cpp rpc_server_tests.cpp rwcollection_tests.cpp sanity_tests.cpp scheduler_tests.cpp schnorr_tests.cpp script_bitfield_tests.cpp script_commitment_tests.cpp script_p2sh_tests.cpp script_standard_tests.cpp script_tests.cpp scriptnum_tests.cpp serialize_tests.cpp sigcache_tests.cpp sigencoding_tests.cpp sighash_tests.cpp sighashtype_tests.cpp sigcheckcount_tests.cpp sigopcount_tests.cpp skiplist_tests.cpp streams_tests.cpp sync_tests.cpp timedata_tests.cpp torcontrol_tests.cpp transaction_tests.cpp txindex_tests.cpp txvalidation_tests.cpp txvalidationcache_tests.cpp uint256_tests.cpp undo_tests.cpp util_tests.cpp validation_block_tests.cpp validation_tests.cpp versionbits_tests.cpp work_comparator_tests.cpp # RPC Tests ../rpc/test/server_tests.cpp # Wallet tests ${BITCOIN_WALLET_TESTS} ) target_link_libraries(test_bitcoin rpcclient server) if(TARGET bitcoinconsensus-shared) target_link_libraries(test_bitcoin bitcoinconsensus-shared) else() target_link_libraries(test_bitcoin bitcoinconsensus) endif() add_subdirectory(fuzz) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bc24463f33..e339c02f40 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,124 +1,124 @@ ### # Create config.ini file for tests ### set(abs_top_srcdir ${CMAKE_SOURCE_DIR}) set(abs_top_builddir ${CMAKE_BINARY_DIR}) if(CMAKE_SYSTEM_NAME MATCHES "Windows") set(EXEEXT ".exe") endif() if(NOT BUILD_BITCOIN_WALLET) set(ENABLE_WALLET_TRUE "#") endif() if(NOT BUILD_BITCOIN_TX OR NOT BUILD_BITCOIN_TX) set(BUILD_BITCOIN_UTILS_TRUE "#") endif() if(NOT BUILD_BITCOIN_ZMQ) set(ENABLE_ZMQ_TRUE "#") endif() # Create build ini file configure_file(config.ini.in config.ini @ONLY) ### # Setup symlinks for testing ### include(SanitizeHelper) function(make_link file) set(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}") set(dest "${CMAKE_CURRENT_BINARY_DIR}/${file}") add_custom_command( OUTPUT "${dest}" COMMAND ${CMAKE_COMMAND} -E create_symlink "${src}" "${dest}" COMMENT "link ${file}" MAIN_DEPENDENCY "${src}" ) # Add a phony target to make sure the files are linked by default. sanitize_target_name("link-" "${file}" NAME) add_custom_target(${NAME} ALL DEPENDS "${dest}") endfunction() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/functional/) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/util/) make_link(functional/test_runner.py) make_link(util/bitcoin-util-test.py) make_link(util/rpcauth-test.py) macro(add_functional_test_check TARGET COMMENT) add_custom_target(${TARGET} COMMENT "${COMMENT}" COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" ./functional/test_runner.py ${ARGN} DEPENDS ../src/bitcoind ../src/bitcoin-cli ${CMAKE_CURRENT_BINARY_DIR}/functional/test_runner.py USES_TERMINAL VERBATIM ) endmacro() add_functional_test_check(check-functional "Run the functional tests" ) add_dependencies(check-all check-functional) add_functional_test_check(check-functional-extended "Run the extended functional tests" --extended ) add_dependencies(check-extended check-functional-extended) set(TEST_SUITE_NAME_UPGRADE_ACTIVATED "Bitcoin ABC functional tests with the next upgrade activated") add_functional_test_check(check-functional-upgrade-activated "Run the functional tests with the upgrade activated" --with-phononactivation -n "${TEST_SUITE_NAME_UPGRADE_ACTIVATED}" ) add_dependencies(check-upgrade-activated check-functional-upgrade-activated) add_functional_test_check(check-functional-upgrade-activated-extended "Run the extended functional tests with the upgrade activated" --extended --with-phononactivation -n "${TEST_SUITE_NAME_UPGRADE_ACTIVATED}" ) add_dependencies(check-upgrade-activated-extended check-functional-upgrade-activated-extended) if(BUILD_BITCOIN_TX) add_custom_target(check-bitcoin-util COMMENT "Test Bitcoin utilities..." COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" ./util/bitcoin-util-test.py DEPENDS ../src/bitcoin-tx ${CMAKE_CURRENT_BINARY_DIR}/util/bitcoin-util-test.py ) add_dependencies(check check-bitcoin-util) endif() add_custom_target(check-rpcauth COMMENT "Test Bitcoin RPC authentication..." COMMAND - "${PYTHON_EXECUTABLE}" + "${Python_EXECUTABLE}" ./util/rpcauth-test.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/util/rpcauth-test.py ) add_dependencies(check check-rpcauth) include(PackageHelper) exclude_from_source_package( # Subdirectories "cache/" "lint/" "sanitizer_suppressions/" )