From d93102296349f46b81c159b9f2ebe9ec75f50cb8 Mon Sep 17 00:00:00 2001 From: xiphon Date: Tue, 7 Jul 2020 23:04:47 +0000 Subject: [PATCH] cmake: implement MacOS 'release' build + CI support --- .github/workflows/build.yml | 19 ++++++++++++++++--- CMakeLists.txt | 32 +++++++++++++++++++++++++++++--- src/CMakeLists.txt | 15 +++++++++------ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d0dd1d3..096b560f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,15 +6,28 @@ jobs: build-macos: runs-on: macOS-latest + strategy: + fail-fast: false + matrix: + toolchain: + - name: "qmake" + cmd: "export PATH=$PATH:/usr/local/opt/qt/bin && ./build.sh" + output: build/release/bin/monero-wallet-gui.app/Contents/MacOS/monero-wallet-gui + - name: "cmake" + cmd: "USE_SINGLE_BUILDDIR=ON DEV_MODE=ON make release -j3" + output: build/release/bin/monero-wallet-gui + name: build-macos-${{ matrix.toolchain.name }} steps: - uses: actions/checkout@v1 + with: + submodules: recursive - name: update brew and install dependencies - run: brew update && brew install boost hidapi zmq libpgm miniupnpc ldns expat libunwind-headers protobuf qt5 libgcrypt + run: brew update && brew install boost hidapi zmq libpgm miniupnpc ldns expat libunwind-headers protobuf qt5 pkg-config - name: build - run: export PATH=$PATH:/usr/local/opt/qt/bin && ./build.sh + run: ${{ matrix.toolchain.cmd }} - name: test qml - run: build/release/bin/monero-wallet-gui.app/Contents/MacOS/monero-wallet-gui --test-qml + run: ${{ matrix.toolchain.output }} --test-qml build-ubuntu: diff --git a/CMakeLists.txt b/CMakeLists.txt index 298902f8..b853d2cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,6 @@ endif() set(BUILD_GUI_DEPS ON) set(ARCH "x86-64") set(BUILD_64 ON) -set(INSTALL_VENDORED_LIBUNBOUND ${STATIC}) function (add_c_flag_if_supported flag var) string(REPLACE "-" "_" supported ${flag}_c) @@ -82,6 +81,7 @@ endif() add_subdirectory(monero) set_property(TARGET wallet_merged PROPERTY FOLDER "monero") get_directory_property(ARCH_WIDTH DIRECTORY "monero" DEFINITION ARCH_WIDTH) +get_directory_property(UNBOUND_LIBRARY DIRECTORY "monero" DEFINITION UNBOUND_LIBRARY) if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DQT_NO_DEBUG) @@ -139,6 +139,9 @@ monero_gui_add_library(gui_version SOURCES version.js DEPENDS genversiongui) message(STATUS "${CMAKE_MODULE_PATH}") # OpenSSL +if(APPLE AND NOT OPENSSL_ROOT_DIR) + execute_process(COMMAND brew --prefix openssl OUTPUT_VARIABLE OPENSSL_ROOT_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() find_package(OpenSSL REQUIRED) message(STATUS "OpenSSL: Version ${OPENSSL_VERSION}") message(STATUS "OpenSSL: include dir at ${OPENSSL_INCLUDE_DIR}") @@ -170,6 +173,9 @@ message(STATUS "libhidapi: libraries at ${HIDAPI_LIBRARIES}") if(DEBUG) set(Boost_DEBUG ON) endif() +if(APPLE AND NOT BOOST_ROOT) + execute_process(COMMAND brew --prefix boost OUTPUT_VARIABLE BOOST_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() find_package(Boost 1.58 REQUIRED COMPONENTS system filesystem @@ -222,6 +228,19 @@ if(WITH_SCANNER) list(APPEND QT5_LIBRARIES Qt5Multimedia) endif() +if(APPLE) + list(APPEND QT5_LIBRARIES Qt5MacExtras) + + if(NOT CMAKE_PREFIX_PATH) + execute_process(COMMAND brew --prefix qt5 OUTPUT_VARIABLE QT5_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) + list(APPEND CMAKE_PREFIX_PATH ${QT5_DIR}) + endif() + + if(CMAKE_PREFIX_PATH) + include_directories(${CMAKE_PREFIX_PATH}/include) + endif() +endif() + # TODO: drop this once we switch to Qt 5.14+ find_package(Qt5QmlModels QUIET) if(Qt5QmlModels_FOUND) @@ -247,6 +266,11 @@ if(QT5_PKG_CONFIG_FOUND) set(QT5_PKG_CONFIG "${QT5_PKG_CONFIG}_STATIC") endif() + if(APPLE) + list(JOIN ${QT5_PKG_CONFIG}_LDFLAGS_OTHER " " ${QT5_PKG_CONFIG}_LDFLAGS_OTHER) + list(JOIN ${QT5_PKG_CONFIG}_LIBRARIES " " ${QT5_PKG_CONFIG}_LIBRARIES) + endif() + set(QT5_LIBRARIES ${${QT5_PKG_CONFIG}_LIBRARIES} ${${QT5_PKG_CONFIG}_LDFLAGS_OTHER}) include_directories(${${QT5_PKG_CONFIG}_INCLUDE_DIRS}) link_directories(${${QT5_PKG_CONFIG}_LIBRARY_DIRS}) @@ -361,7 +385,9 @@ if(MINGW) else() set(ICU_LIBRARIES icuio icuin icuuc icudt icutu iconv) endif() -elseif(APPLE OR OPENBSD OR ANDROID) +elseif(APPLE) + set(EXTRA_LIBRARIES "-framework AppKit") +elseif(OPENBSD OR ANDROID) set(EXTRA_LIBRARIES "") elseif(FREEBSD) set(EXTRA_LIBRARIES execinfo) @@ -425,7 +451,7 @@ if (NOT (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VER endif() # linker -if (NOT (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU")) +if (NOT APPLE AND NOT (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU")) # Windows binaries die on startup with PIE when compiled with GCC add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8800c2fb..23af9a05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,13 +44,16 @@ file(GLOB SOURCE_FILES "libwalletqt/Subaddress.h" "libwalletqt/SubaddressAccount.h" "libwalletqt/UnsignedTransaction.h" - "daemon/*.h" - "daemon/*.cpp" - "model/*.h" - "model/*.cpp" - "qt/*.h" + "daemon/*.h" + "daemon/*.cpp" + "model/*.h" + "model/*.cpp" + "qt/*.h" "qt/*.cpp" ) +if(APPLE) + list(APPEND SOURCE_FILES "qt/macoshelper.mm") +endif() if(ENABLE_PASS_STRENGTH_METER) file(GLOB PASS_STRENGTH_FILES @@ -130,7 +133,7 @@ target_link_libraries(monero-wallet-gui wallet_merged ${LMDB_LIBRARY} epee - unbound + ${UNBOUND_LIBRARY} ${SODIUM_LIBRARY} easylogging blockchain_db