adjust CMakeLists.txt, to prepare for win32 and macos builds

This commit is contained in:
shunf4 2021-10-05 12:49:06 +08:00
parent ef1a9846bf
commit 5fbb96618f
6 changed files with 132 additions and 9 deletions

View File

@ -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)

View File

@ -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)

42
signalcatcher_win32.cpp Normal file
View File

@ -0,0 +1,42 @@
/*
* Squawk messenger.
* Copyright (C) 2021 Shunf4 <shun1048576@gmail.com>
*
* 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/>.
*/
#include "signalcatcher.h"
#include <unistd.h>
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;
}

1
squawk.rc Normal file
View File

@ -0,0 +1 @@
IDI_ICON1 ICON "squawk.ico"

View File

@ -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})

View File

@ -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})