From 5fbb96618fb475a296e9f00f04b3bc79758efc4c Mon Sep 17 00:00:00 2001 From: shunf4 Date: Tue, 5 Oct 2021 12:49:06 +0800 Subject: [PATCH 01/17] adjust CMakeLists.txt, to prepare for win32 and macos builds --- CMakeLists.txt | 61 ++++++++++++++++++++++++++++++++++----- core/CMakeLists.txt | 22 +++++++++++++- signalcatcher_win32.cpp | 42 +++++++++++++++++++++++++++ squawk.rc | 1 + ui/CMakeLists.txt | 5 ++++ ui/widgets/CMakeLists.txt | 10 +++++++ 6 files changed, 132 insertions(+), 9 deletions(-) create mode 100644 signalcatcher_win32.cpp create mode 100644 squawk.rc diff --git a/CMakeLists.txt b/CMakeLists.txt index 771481f..194c88b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,15 +18,17 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug) endif() -set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") +if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra") + set(CMAKE_CXX_FLAGS_RELEASE "-O3") +endif(CMAKE_COMPILER_IS_GNUCXX) + message("Build type: ${CMAKE_BUILD_TYPE}") set(squawk_SRC main.cpp exception.cpp - signalcatcher.cpp shared/global.cpp shared/utils.cpp shared/message.cpp @@ -34,6 +36,13 @@ set(squawk_SRC shared/icons.cpp ) +if (WIN32) + list(APPEND squawk_SRC signalcatcher_win32.cpp) +else (WIN32) + list(APPEND squawk_SRC signalcatcher.cpp) +endif (WIN32) + + set(squawk_HEAD exception.h signalcatcher.h @@ -47,10 +56,40 @@ set(squawk_HEAD ) configure_file(resources/images/logo.svg squawk.svg COPYONLY) -execute_process(COMMAND convert -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -execute_process(COMMAND convert -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +if (WIN32) + set(CONVERT_BIN magick convert) +else(WIN32) + set(CONVERT_BIN convert) +endif(WIN32) + +execute_process(COMMAND ${CONVERT_BIN} -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND ${CONVERT_BIN} -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND ${CONVERT_BIN} -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +execute_process(COMMAND ${CONVERT_BIN} -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +if (WIN32) + execute_process(COMMAND ${CONVERT_BIN} squawk48.png squawk64.png squawk256.png squawk.ico WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc") +endif(WIN32) + +if (APPLE) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icns.iconset") + execute_process(COMMAND convert -background none -size 16x16 squawk.svg icns.iconset/icon_16x16.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_16x16@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_32x32.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !64x64 squawk.svg "icns.iconset/icon_32x32@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !128x128 squawk.svg "icns.iconset/icon_128x128.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !256x256 squawk.svg "icns.iconset/icon_128x128@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !256x256 squawk.svg "icns.iconset/icon_256x256.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_256x256@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_512x512.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND convert -background none -resize !1024x1024 squawk.svg "icns.iconset/icon_512x512@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + execute_process(COMMAND iconutil -c icns "icns.iconset" -o "squawk.icns" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + set(MACOSX_BUNDLE_ICON_FILE squawk.icns) + set(APP_ICON_MACOSX ${CMAKE_CURRENT_BINARY_DIR}/squawk.icns) + set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES + MACOSX_PACKAGE_LOCATION "Resources") +endif (APPLE) configure_file(packaging/squawk.desktop squawk.desktop COPYONLY) @@ -92,7 +131,13 @@ if (WITH_KWALLET) endif() endif() -add_executable(squawk ${squawk_SRC} ${squawk_HEAD} ${RCC}) +set(WIN32_FLAG "") +if (WIN32) + if (CMAKE_BUILD_TYPE STREQUAL "Release") + set(WIN32_FLAG WIN32) + endif() +endif(WIN32) +add_executable(squawk ${WIN32_FLAG} ${squawk_SRC} ${squawk_HEAD} ${RCC} ${SQUAWK_WIN_RC} ${APP_ICON_MACOSX}) target_link_libraries(squawk Qt5::Widgets) add_subdirectory(ui) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index b74a055..0377620 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -8,6 +8,19 @@ find_package(Qt5Gui CONFIG REQUIRED) find_package(Qt5Network CONFIG REQUIRED) find_package(Qt5Xml CONFIG REQUIRED) +# Find LMDB from system or ${LMDB_DIR} +find_path(LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "${LMDB_DIR}/include") + +if (UNIX AND NOT APPLE) + # Linux + find_library(LMDB_LIBRARIES NAMES liblmdb.a PATHS ${LMDB_DIR}) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) +else (UNIX AND NOT APPLE) + # Windows / macOS: LMDB_DIR has to be specified + set(LMDB_LIBRARIES "${LMDB_DIR}/lib/liblmdb.a") +endif (UNIX AND NOT APPLE) + set(squawkCORE_SRC squawk.cpp account.cpp @@ -27,6 +40,7 @@ add_subdirectory(passwordStorageEngines) # Tell CMake to create the helloworld executable add_library(squawkCORE ${squawkCORE_SRC}) +target_include_directories(squawkCORE PUBLIC ${LMDB_INCLUDE_DIR}) if(SYSTEM_QXMPP) get_target_property(QXMPP_INTERFACE_INCLUDE_DIRECTORIES QXmpp::QXmpp INTERFACE_INCLUDE_DIRECTORIES) @@ -39,7 +53,13 @@ target_link_libraries(squawkCORE Qt5::Network) target_link_libraries(squawkCORE Qt5::Gui) target_link_libraries(squawkCORE Qt5::Xml) target_link_libraries(squawkCORE qxmpp) -target_link_libraries(squawkCORE lmdb) + +target_link_libraries(squawkCORE ${LMDB_LIBRARIES}) +if (UNIX AND NOT APPLE) + # Linux + target_link_libraries(squawkCORE Threads::Threads) +endif (UNIX AND NOT APPLE) + target_link_libraries(squawkCORE simpleCrypt) if (WITH_KWALLET) target_link_libraries(squawkCORE kwalletPSE) diff --git a/signalcatcher_win32.cpp b/signalcatcher_win32.cpp new file mode 100644 index 0000000..ca7b5a2 --- /dev/null +++ b/signalcatcher_win32.cpp @@ -0,0 +1,42 @@ +/* + * Squawk messenger. + * Copyright (C) 2021 Shunf4 + * + * 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 . + */ + +#include "signalcatcher.h" +#include + +SignalCatcher::SignalCatcher(QCoreApplication *p_app, QObject *parent): + QObject(parent), + app(p_app) +{ +} + +SignalCatcher::~SignalCatcher() +{} + +void SignalCatcher::handleSigInt() +{ +} + +void SignalCatcher::intSignalHandler(int unused) +{ +} + +int SignalCatcher::setup_unix_signal_handlers() +{ + return 0; +} diff --git a/squawk.rc b/squawk.rc new file mode 100644 index 0000000..6061f20 --- /dev/null +++ b/squawk.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON "squawk.ico" diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt index 52913a8..8fd04ff 100644 --- a/ui/CMakeLists.txt +++ b/ui/CMakeLists.txt @@ -36,6 +36,11 @@ set(squawkUI_SRC utils/dropshadoweffect.cpp ) +# Add squawk.ui to squawkUI_SRC so that the .ui files are displayed in Qt Creator +qt5_wrap_ui(squawkUI_SRC + squawk.ui +) + # Tell CMake to create the helloworld executable add_library(squawkUI ${squawkUI_SRC}) diff --git a/ui/widgets/CMakeLists.txt b/ui/widgets/CMakeLists.txt index 29e2dbc..ffd661e 100644 --- a/ui/widgets/CMakeLists.txt +++ b/ui/widgets/CMakeLists.txt @@ -21,6 +21,16 @@ set(squawkWidgets_SRC joinconference.cpp ) +# Add to squawkUI_SRC so that the .ui files are displayed in Qt Creator +qt5_wrap_ui(squawkWidgets_SRC + account.ui + accounts.ui + conversation.ui + joinconference.ui + newcontact.ui + vcard/vcard.ui +) + # Tell CMake to create the helloworld executable add_library(squawkWidgets ${squawkWidgets_SRC}) From 6764d8ea1104b8cd5787bb87ed3bdc8c5867edf2 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Tue, 5 Oct 2021 12:56:36 +0800 Subject: [PATCH 02/17] remove dependency libuuid --- CMakeLists.txt | 1 - shared/utils.cpp | 8 ++------ shared/utils.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 194c88b..290568f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,6 @@ add_subdirectory(external/simpleCrypt) target_link_libraries(squawk squawkUI) target_link_libraries(squawk squawkCORE) -target_link_libraries(squawk uuid) add_dependencies(${CMAKE_PROJECT_NAME} translations) diff --git a/shared/utils.cpp b/shared/utils.cpp index 924be85..a7a4ecb 100644 --- a/shared/utils.cpp +++ b/shared/utils.cpp @@ -17,15 +17,11 @@ */ #include "utils.h" +#include QString Shared::generateUUID() { - uuid_t uuid; - uuid_generate(uuid); - - char uuid_str[36]; - uuid_unparse_lower(uuid, uuid_str); - return uuid_str; + return QUuid::createUuid().toString(); } diff --git a/shared/utils.h b/shared/utils.h index e9e3d29..8e1e6dd 100644 --- a/shared/utils.h +++ b/shared/utils.h @@ -23,7 +23,6 @@ #include #include -#include #include namespace Shared { From c55b7c6baf932c7f8ac82f2fa5f16658bf6889ea Mon Sep 17 00:00:00 2001 From: shunf4 Date: Tue, 5 Oct 2021 15:11:43 +0800 Subject: [PATCH 03/17] update docs for removed uuid dep and LMDB_DIR var --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 30c6473..987ca53 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ ### Prerequisites - QT 5.12 *(lower versions might work but it wasn't tested)* -- uuid _(usually included in some other package, for example it's ***libutil-linux*** in archlinux)_ - lmdb - CMake 3.0 or higher - qxmpp 1.1.0 or higher @@ -44,7 +43,7 @@ $ git clone https://git.macaw.me/blue/squawk $ cd squawk $ mkdir build $ cd build -$ cmake .. +$ cmake .. [-DLMDB_DIR:PATH=/path/to/lmdb] $ cmake --build . ``` @@ -57,7 +56,7 @@ $ git clone --recurse-submodules https://git.macaw.me/blue/squawk $ cd squawk $ mkdir build $ cd build -$ cmake .. -D SYSTEM_QXMPP=False +$ cmake .. -D SYSTEM_QXMPP=False [-DLMDB_DIR:PATH=/path/to/lmdb] $ cmake --build . ``` From faa7d396a5665e385470f15ebc7841bcabb03f11 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Tue, 5 Oct 2021 16:09:31 +0800 Subject: [PATCH 04/17] add liblmdb.so as possible lmdb lib name --- core/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 0377620..306b4f5 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -13,7 +13,7 @@ find_path(LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "${LMDB_DIR}/include") if (UNIX AND NOT APPLE) # Linux - find_library(LMDB_LIBRARIES NAMES liblmdb.a PATHS ${LMDB_DIR}) + find_library(sudo rLMDB_LIBRARIES NAMES liblmdb.a liblmdb.so PATHS ${LMDB_DIR}) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) else (UNIX AND NOT APPLE) From a1f3c00a5454c7908949625ed4be87bfff966951 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 00:15:25 +0800 Subject: [PATCH 05/17] remove dependency uuid --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fb09fc..7b71aea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,6 @@ find_package(LMDB REQUIRED) target_link_libraries(squawk PRIVATE Qt5::Core Qt5::Widgets Qt5::DBus Qt5::Network Qt5::Gui Qt5::Xml) target_link_libraries(squawk PRIVATE lmdb) target_link_libraries(squawk PRIVATE simpleCrypt) -target_link_libraries(squawk PRIVATE uuid) # Build type if (NOT CMAKE_BUILD_TYPE) From 1e37aa762c7aae7400d2aa3c16b7a76050d8aec7 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 00:48:25 +0800 Subject: [PATCH 06/17] generate app bundle for macOS --- CMakeLists.txt | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b71aea..fe4ba01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,13 +13,27 @@ include(GNUInstallDirs) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(WIN32_FLAG "") -if (WIN32) - if (CMAKE_BUILD_TYPE STREQUAL "Release") - set(WIN32_FLAG WIN32) - endif() -endif(WIN32) -add_executable(squawk ${WIN32_FLAG}) +set(MACOSX_BUNDLE_FLAG "") +if (CMAKE_BUILD_TYPE STREQUAL "Release") + if (WIN32) + set(WIN32_FLAG WIN32) + endif(WIN32) + if (APPLE) + set(MACOSX_BUNDLE_FLAG MACOSX_BUNDLE) + endif(APPLE) +endif() + +add_executable(squawk ${WIN32_FLAG} ${MACOSX_BUNDLE_FLAG}) target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}) +if (CMAKE_BUILD_TYPE STREQUAL "Release") + if (APPLE) + set_target_properties(squawk PROPERTIES + MACOSX_BUNDLE_EXECUTABLE_NAME "Squawk" + MACOSX_BUNDLE_ICON_FILE "" # TODO + MACOSX_BUNDLE_BUNDLE_NAME "Squawk" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/CMake/Info.plist.in) + endif(APPLE) +endif() option(SYSTEM_QXMPP "Use system qxmpp lib" ON) option(WITH_KWALLET "Build KWallet support module" ON) From d1f108e69dc145579f459f491d7301454ffa0eae Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 00:53:50 +0800 Subject: [PATCH 07/17] update docs for win32 build --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 892168c..e94972f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ - qxmpp 1.1.0 or higher - KDE Frameworks: kwallet (optional) - KDE Frameworks: KIO (optional) +- Boost ### Getting @@ -33,6 +34,26 @@ You can also clone the repo and build it from source Squawk requires Qt with SSL enabled. It uses CMake as build system. +Please check the prerequisites and install them before installation. + +#### For Windows (Mingw-w64) build + +You need Qt for mingw64 (MinGW 64-bit) platform when installing Qt. + +The best way to acquire library `lmdb` and `boost` is through Msys2. + +First install Msys2, and then install `mingw-w64-x86_64-lmdb` and `mingw-w64-x86_64-boost` by pacman. + +Then you need to provide the cmake cache entry when calling cmake for configuration: + +``` +cmake .. -D LMDB_ROOT_DIR:PATH= -D BOOST_ROOT:PATH= +``` + +``: e.g. `C:/msys64/mingw64`. + +--- + There are two ways to build, it depends whether you have qxmpp installed in your system #### Building with system qxmpp @@ -44,7 +65,7 @@ $ git clone https://git.macaw.me/blue/squawk $ cd squawk $ mkdir build $ cd build -$ cmake .. [-DLMDB_DIR:PATH=/path/to/lmdb] +$ cmake .. [-D LMDB_ROOT_DIR:PATH=...] [-D BOOST_ROOT:PATH=...] $ cmake --build . ``` @@ -57,10 +78,12 @@ $ git clone --recurse-submodules https://git.macaw.me/blue/squawk $ cd squawk $ mkdir build $ cd build -$ cmake .. -D SYSTEM_QXMPP=False [-DLMDB_DIR:PATH=/path/to/lmdb] +$ cmake .. -D SYSTEM_QXMPP=False [-D LMDB_ROOT_DIR:PATH=...] [-D BOOST_ROOT:PATH=...] $ cmake --build . ``` +You can always refer to `appveyor.yml` to see how AppVeyor build squawk. + ### List of keys Here is the list of keys you can pass to configuration phase of `cmake ..`. From 261b34b7125ad00ccb244786fe11bfdf6d0373b3 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 00:55:39 +0800 Subject: [PATCH 08/17] add forgotten cmake/MacOSXBundleInfo.plist.in --- cmake/MacOSXBundleInfo.plist.in | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cmake/MacOSXBundleInfo.plist.in diff --git a/cmake/MacOSXBundleInfo.plist.in b/cmake/MacOSXBundleInfo.plist.in new file mode 100644 index 0000000..ac4bbec --- /dev/null +++ b/cmake/MacOSXBundleInfo.plist.in @@ -0,0 +1,41 @@ + + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + + NSPrincipalClass + NSApplication + NSHighResolutionCapable + True + + + From 41d9fa7a1cd4029834eb9eb4e5f84b98abd36d4a Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 01:07:47 +0800 Subject: [PATCH 09/17] fix macos bundle build --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe4ba01..96df523 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,9 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release") if (APPLE) set_target_properties(squawk PROPERTIES MACOSX_BUNDLE_EXECUTABLE_NAME "Squawk" - MACOSX_BUNDLE_ICON_FILE "" # TODO + MACOSX_BUNDLE_ICON_FILE "${MACOSX_BUNDLE_ICON_FILE}" # TODO MACOSX_BUNDLE_BUNDLE_NAME "Squawk" - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/CMake/Info.plist.in) + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in) endif(APPLE) endif() From f3153ef1dbcbf95ed4071aa11ff439532abc23e8 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 01:17:30 +0800 Subject: [PATCH 10/17] ci: add appveyor.yml --- appveyor.yml | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..763a751 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,113 @@ +image: + - Visual Studio 2019 + - "Previous Ubuntu1804" + - macOS + +branches: + except: + - gh-pages + +for: +- + matrix: + only: + - image: Visual Studio 2019 + + environment: + QTDIR: C:\Qt\5.15.2\mingw81_64 + QTTOOLDIR: C:\Qt\Tools\mingw810_64\bin + QTNINJADIR: C:\Qt\Tools\Ninja + + install: + - set PATH=%QTTOOLDIR%;%QTNINJADIR%;%QTDIR%\bin;%PATH% + - git submodule update --init --recursive + + before_build: + - choco install --yes zstandard + - choco install --yes --version=7.1.0.2 imagemagick.app + - set PATH=C:\Program Files\ImageMagick-7.1.0-Q16-HDRI;%PATH% + + - mkdir lmdb + - cd lmdb + - curl -OL https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-lmdb-0.9.27-1-any.pkg.tar.zst + - zstd -d ./mingw-w64-x86_64-lmdb-0.9.27-1-any.pkg.tar.zst + - tar -xvf ./mingw-w64-x86_64-lmdb-0.9.27-1-any.pkg.tar + - cd .. + + - mkdir boost + - cd boost + - curl -OL https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-boost-1.77.0-2-any.pkg.tar.zst + - zstd -d ./mingw-w64-x86_64-boost-1.77.0-2-any.pkg.tar.zst + - tar -xvf ./mingw-w64-x86_64-boost-1.77.0-2-any.pkg.tar + - cd .. + + - mkdir build + - cd build + - cmake -GNinja -DCMAKE_BUILD_TYPE:String=Release -DCMAKE_PREFIX_PATH:STRING=%QTDIR% -DLMDB_ROOT_DIR:PATH=C:/projects/squawk/lmdb/mingw64 -DBOOST_ROOT:PATH=C:/projects/squawk/boost/mingw64 .. + + build_script: + - cmake --build . + - mkdir deploy + - cd deploy + - copy ..\squawk.exe .\ + - copy ..\external\qxmpp\src\libqxmpp.dll .\ + - windeployqt .\squawk.exe + - windeployqt .\libqxmpp.dll + - cd ..\.. + + artifacts: + - path: build/deploy/squawk.exe + name: Squawk executable (Qt 5.15.2) + + - path: build/deploy + name: Squawk deployment + +- + matrix: + only: + - image: macOS + + install: + - brew install lmdb imagemagick boost + - git submodule update --init --recursive + + before_build: + - mkdir build + - cd build + - cmake -DCMAKE_BUILD_TYPE:String=Release -DCMAKE_PREFIX_PATH:STRING=$HOME/Qt/5.15.2/clang_64 .. + + build_script: + - cmake --build . + + artifacts: + - path: build/squawk + name: Squawk executable (Qt 5.15.2) + - path: build/external/qxmpp/src/ + name: QXMPP + - path: build/squawk.app + name: Squawk Bundle (Qt 5.15.2) + +- + matrix: + only: + - image: "Previous Ubuntu1804" + + install: + - ls $HOME/Qt + - sudo apt update + - sudo apt install -y liblmdb-dev liblmdb0 imagemagick mesa-common-dev libglu1-mesa-dev libboost-all-dev + - git submodule update --init --recursive + + before_build: + - mkdir build + - cd build + - cmake -DCMAKE_BUILD_TYPE:String=Release -DCMAKE_PREFIX_PATH:STRING=$HOME/Qt/5.12.10/gcc_64 .. + + build_script: + - cmake --build . + + artifacts: + - path: build/squawk + name: Squawk executable (Qt 5.12) + - path: build/external/qxmpp/src/ + name: QXMPP From 4f6946a5fc0e68b45d2147c2dac00ada01018f25 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 01:28:08 +0800 Subject: [PATCH 11/17] add LMDB_INCLUDE_DIRS as include dir, fixing win32 ci --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96df523..1645ffc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ target_include_directories(squawk PRIVATE ${Qt5Gui_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt5Xml_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt5Network_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt5Core_INCLUDE_DIRS}) +target_include_directories(squawk PRIVATE ${LMDB_INCLUDE_DIRS}) ## QXmpp if (SYSTEM_QXMPP) From d84a33e144f5d0e93b5ccd15379ed45a67e3d3de Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 01:33:58 +0800 Subject: [PATCH 12/17] fix linux ci by finding and linking thread libraries --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1645ffc..5209974 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,12 @@ find_package(LMDB REQUIRED) target_link_libraries(squawk PRIVATE Qt5::Core Qt5::Widgets Qt5::DBus Qt5::Network Qt5::Gui Qt5::Xml) target_link_libraries(squawk PRIVATE lmdb) target_link_libraries(squawk PRIVATE simpleCrypt) +# Link thread libraries on Linux +if(UNIX AND NOT APPLE) + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries(squawk PRIVATE Threads::Threads) +endif() # Build type if (NOT CMAKE_BUILD_TYPE) From 1c0802c8ca6262f6815fd16119a1e5d412c4d534 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 01:51:01 +0800 Subject: [PATCH 13/17] fix win32 ci by place LMDB_INCLUDE_DIRS in core/ --- CMakeLists.txt | 1 - core/CMakeLists.txt | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5209974..1b2ca7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,6 @@ target_include_directories(squawk PRIVATE ${Qt5Gui_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt5Xml_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt5Network_INCLUDE_DIRS}) target_include_directories(squawk PRIVATE ${Qt5Core_INCLUDE_DIRS}) -target_include_directories(squawk PRIVATE ${LMDB_INCLUDE_DIRS}) ## QXmpp if (SYSTEM_QXMPP) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index e30cc7e..9369cb7 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -28,5 +28,7 @@ target_sources(squawk PRIVATE urlstorage.h ) +target_include_directories(squawk PRIVATE ${LMDB_INCLUDE_DIRS}) + add_subdirectory(handlers) add_subdirectory(passwordStorageEngines) From 8c6ac1a21d50cf38be1a796d395998dc79a22385 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 17:32:46 +0800 Subject: [PATCH 14/17] add icns to macos bundle; use macdeployqt post build --- CMakeLists.txt | 18 ++++++++---------- resources/CMakeLists.txt | 23 +++++++++++++++++++---- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b2ca7b..8632b38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,15 +25,6 @@ endif() add_executable(squawk ${WIN32_FLAG} ${MACOSX_BUNDLE_FLAG}) target_include_directories(squawk PRIVATE ${CMAKE_SOURCE_DIR}) -if (CMAKE_BUILD_TYPE STREQUAL "Release") - if (APPLE) - set_target_properties(squawk PROPERTIES - MACOSX_BUNDLE_EXECUTABLE_NAME "Squawk" - MACOSX_BUNDLE_ICON_FILE "${MACOSX_BUNDLE_ICON_FILE}" # TODO - MACOSX_BUNDLE_BUNDLE_NAME "Squawk" - MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in) - endif(APPLE) -endif() option(SYSTEM_QXMPP "Use system qxmpp lib" ON) option(WITH_KWALLET "Build KWallet support module" ON) @@ -142,4 +133,11 @@ add_subdirectory(ui) # Install the executable install(TARGETS squawk DESTINATION ${CMAKE_INSTALL_BINDIR}) -target_sources(squawk PRIVATE ${SQUAWK_WIN_RC} ${APP_ICON_MACOSX}) +if (CMAKE_BUILD_TYPE STREQUAL "Release") + if (APPLE) + add_custom_command(TARGET squawk POST_BUILD COMMENT "Running macdeployqt..." + COMMAND "${Qt5Widgets_DIR}/../../../bin/macdeployqt" "${CMAKE_CURRENT_BINARY_DIR}/squawk.app" + ) + endif(APPLE) +endif() + diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 42cb360..9288650 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -15,7 +15,9 @@ execute_process(COMMAND ${CONVERT_BIN} -background none -size 256x256 squawk.svg if (WIN32) execute_process(COMMAND ${CONVERT_BIN} squawk48.png squawk64.png squawk256.png squawk.ico WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc" PARENT_SCOPE) + set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc") + set(SQUAWK_WIN_RC "${SQUAWK_WIN_RC}" PARENT_SCOPE) + target_sources(squawk PRIVATE ${SQUAWK_WIN_RC}) endif(WIN32) if (APPLE) @@ -31,10 +33,22 @@ if (APPLE) execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_512x512.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !1024x1024 squawk.svg "icns.iconset/icon_512x512@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND iconutil -c icns "icns.iconset" -o "squawk.icns" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set(MACOSX_BUNDLE_ICON_FILE squawk.icns PARENT_SCOPE) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_BINARY_DIR}/squawk.icns PARENT_SCOPE) - set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES + set(MACOSX_BUNDLE_ICON_FILE squawk.icns) + set(MACOSX_BUNDLE_ICON_FILE ${MACOSX_BUNDLE_ICON_FILE} PARENT_SCOPE) + set(APP_ICON_MACOSX ${CMAKE_CURRENT_BINARY_DIR}/squawk.icns) + set(APP_ICON_MACOSX ${APP_ICON_MACOSX} PARENT_SCOPE) + target_sources(squawk PRIVATE ${APP_ICON_MACOSX}) + set_source_files_properties(${APP_ICON_MACOSX} TARGET_DIRECTORY squawk PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + if (CMAKE_BUILD_TYPE STREQUAL "Release") + if (APPLE) + set_target_properties(squawk PROPERTIES + MACOSX_BUNDLE_EXECUTABLE_NAME "Squawk" + MACOSX_BUNDLE_ICON_FILE "${MACOSX_BUNDLE_ICON_FILE}" # TODO + MACOSX_BUNDLE_BUNDLE_NAME "Squawk" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in) + endif(APPLE) + endif() endif (APPLE) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps) @@ -42,3 +56,4 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk48.png DESTINATION ${CMAKE_INSTA install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk64.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps RENAME squawk.png) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk128.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps RENAME squawk.png) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk256.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/256x256/apps RENAME squawk.png) + From 8b3752ef476cc79b8095701b172c9d8f6bea1ac9 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 18:12:26 +0800 Subject: [PATCH 15/17] fix ci for macos; adjust ci for linux executable with changed rpath --- appveyor.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 763a751..9b20f3b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ image: - Visual Studio 2019 - "Previous Ubuntu1804" - - macOS + - macOS-Mojave branches: except: @@ -60,7 +60,7 @@ for: name: Squawk executable (Qt 5.15.2) - path: build/deploy - name: Squawk deployment + name: Squawk deployment with Qt Framework - matrix: @@ -79,13 +79,16 @@ for: build_script: - cmake --build . + after_build: + - zip -r squawk.app.zip squawk.app + artifacts: - - path: build/squawk + - path: build/squawk.app/Contents/MacOS/squawk name: Squawk executable (Qt 5.15.2) - path: build/external/qxmpp/src/ name: QXMPP - - path: build/squawk.app - name: Squawk Bundle (Qt 5.15.2) + - path: build/squawk.app.zip + name: Squawk Bundle with Qt Framework (Qt 5.15.2) - matrix: @@ -101,13 +104,14 @@ for: before_build: - mkdir build - cd build - - cmake -DCMAKE_BUILD_TYPE:String=Release -DCMAKE_PREFIX_PATH:STRING=$HOME/Qt/5.12.10/gcc_64 .. + - cmake -DCMAKE_BUILD_TYPE:String=Release -DCMAKE_PREFIX_PATH:STRING=$HOME/Qt/5.12.10/gcc_64 -DCMAKE_BUILD_RPATH="\$ORIGIN" .. build_script: - cmake --build . + after_build: + - zip -r squawk.zip squawk -j external/qxmpp/src/libqxmpp* + artifacts: - - path: build/squawk - name: Squawk executable (Qt 5.12) - - path: build/external/qxmpp/src/ - name: QXMPP + - path: build/squawk.zip + name: Squawk executable and libraries (Qt 5.12) From d0bdb374a04f93644758439c9d8fad1e81415f13 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 18:47:59 +0800 Subject: [PATCH 16/17] add flag -fno-sized-deallocation, eliminating _ZdlPvm --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8632b38..da89682 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ target_compile_options(squawk PRIVATE "-Wall;-Wextra" "$<$:-g>" "$<$:-O3>" + "-fno-sized-deallocation" # for eliminating _ZdlPvm ) endif(CMAKE_COMPILER_IS_GNUCXX) From 67e5f9744ef1fc94e347bf3f3684312c56c98ea6 Mon Sep 17 00:00:00 2001 From: shunf4 Date: Wed, 6 Oct 2021 18:50:00 +0800 Subject: [PATCH 17/17] fix ci macos matrix item --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 9b20f3b..30a8125 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -65,7 +65,7 @@ for: - matrix: only: - - image: macOS + - image: macOS-Mojave install: - brew install lmdb imagemagick boost