cmake: implement MacOS 'release' build + CI support

This commit is contained in:
xiphon 2020-07-07 23:04:47 +00:00
parent b7b1221221
commit d931022963
3 changed files with 54 additions and 12 deletions

View file

@ -6,15 +6,28 @@ jobs:
build-macos: build-macos:
runs-on: macOS-latest 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: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
with:
submodules: recursive
- name: update brew and install dependencies - 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 - name: build
run: export PATH=$PATH:/usr/local/opt/qt/bin && ./build.sh run: ${{ matrix.toolchain.cmd }}
- name: test qml - 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: build-ubuntu:

View file

@ -31,7 +31,6 @@ endif()
set(BUILD_GUI_DEPS ON) set(BUILD_GUI_DEPS ON)
set(ARCH "x86-64") set(ARCH "x86-64")
set(BUILD_64 ON) set(BUILD_64 ON)
set(INSTALL_VENDORED_LIBUNBOUND ${STATIC})
function (add_c_flag_if_supported flag var) function (add_c_flag_if_supported flag var)
string(REPLACE "-" "_" supported ${flag}_c) string(REPLACE "-" "_" supported ${flag}_c)
@ -82,6 +81,7 @@ endif()
add_subdirectory(monero) add_subdirectory(monero)
set_property(TARGET wallet_merged PROPERTY FOLDER "monero") set_property(TARGET wallet_merged PROPERTY FOLDER "monero")
get_directory_property(ARCH_WIDTH DIRECTORY "monero" DEFINITION ARCH_WIDTH) 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") if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DQT_NO_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}") message(STATUS "${CMAKE_MODULE_PATH}")
# OpenSSL # 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) find_package(OpenSSL REQUIRED)
message(STATUS "OpenSSL: Version ${OPENSSL_VERSION}") message(STATUS "OpenSSL: Version ${OPENSSL_VERSION}")
message(STATUS "OpenSSL: include dir at ${OPENSSL_INCLUDE_DIR}") message(STATUS "OpenSSL: include dir at ${OPENSSL_INCLUDE_DIR}")
@ -170,6 +173,9 @@ message(STATUS "libhidapi: libraries at ${HIDAPI_LIBRARIES}")
if(DEBUG) if(DEBUG)
set(Boost_DEBUG ON) set(Boost_DEBUG ON)
endif() 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 find_package(Boost 1.58 REQUIRED COMPONENTS
system system
filesystem filesystem
@ -222,6 +228,19 @@ if(WITH_SCANNER)
list(APPEND QT5_LIBRARIES Qt5Multimedia) list(APPEND QT5_LIBRARIES Qt5Multimedia)
endif() 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+ # TODO: drop this once we switch to Qt 5.14+
find_package(Qt5QmlModels QUIET) find_package(Qt5QmlModels QUIET)
if(Qt5QmlModels_FOUND) if(Qt5QmlModels_FOUND)
@ -247,6 +266,11 @@ if(QT5_PKG_CONFIG_FOUND)
set(QT5_PKG_CONFIG "${QT5_PKG_CONFIG}_STATIC") set(QT5_PKG_CONFIG "${QT5_PKG_CONFIG}_STATIC")
endif() 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}) set(QT5_LIBRARIES ${${QT5_PKG_CONFIG}_LIBRARIES} ${${QT5_PKG_CONFIG}_LDFLAGS_OTHER})
include_directories(${${QT5_PKG_CONFIG}_INCLUDE_DIRS}) include_directories(${${QT5_PKG_CONFIG}_INCLUDE_DIRS})
link_directories(${${QT5_PKG_CONFIG}_LIBRARY_DIRS}) link_directories(${${QT5_PKG_CONFIG}_LIBRARY_DIRS})
@ -361,7 +385,9 @@ if(MINGW)
else() else()
set(ICU_LIBRARIES icuio icuin icuuc icudt icutu iconv) set(ICU_LIBRARIES icuio icuin icuuc icudt icutu iconv)
endif() endif()
elseif(APPLE OR OPENBSD OR ANDROID) elseif(APPLE)
set(EXTRA_LIBRARIES "-framework AppKit")
elseif(OPENBSD OR ANDROID)
set(EXTRA_LIBRARIES "") set(EXTRA_LIBRARIES "")
elseif(FREEBSD) elseif(FREEBSD)
set(EXTRA_LIBRARIES execinfo) set(EXTRA_LIBRARIES execinfo)
@ -425,7 +451,7 @@ if (NOT (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VER
endif() endif()
# linker # 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 # Windows binaries die on startup with PIE when compiled with GCC
add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS) add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS)
endif() endif()

View file

@ -51,6 +51,9 @@ file(GLOB SOURCE_FILES
"qt/*.h" "qt/*.h"
"qt/*.cpp" "qt/*.cpp"
) )
if(APPLE)
list(APPEND SOURCE_FILES "qt/macoshelper.mm")
endif()
if(ENABLE_PASS_STRENGTH_METER) if(ENABLE_PASS_STRENGTH_METER)
file(GLOB PASS_STRENGTH_FILES file(GLOB PASS_STRENGTH_FILES
@ -130,7 +133,7 @@ target_link_libraries(monero-wallet-gui
wallet_merged wallet_merged
${LMDB_LIBRARY} ${LMDB_LIBRARY}
epee epee
unbound ${UNBOUND_LIBRARY}
${SODIUM_LIBRARY} ${SODIUM_LIBRARY}
easylogging easylogging
blockchain_db blockchain_db