Only use -Werror for our code

This commit is contained in:
Nicolas Werner 2020-01-25 00:58:22 +01:00
parent 96ad385331
commit d9aac3ee19

View file

@ -6,45 +6,43 @@ option(ASAN "Compile with address sanitizers" OFF)
option(QML_DEBUGGING "Enable qml debugging" OFF) option(QML_DEBUGGING "Enable qml debugging" OFF)
set( set(
CMAKE_TOOLCHAIN_FILE CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake"
"${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake" CACHE
CACHE FILEPATH "Default toolchain"
FILEPATH )
"Default toolchain"
)
option(HUNTER_ENABLED "Enable Hunter package manager" OFF) option(HUNTER_ENABLED "Enable Hunter package manager" OFF)
include("cmake/HunterGate.cmake") include("cmake/HunterGate.cmake")
HunterGate( HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.244.tar.gz" URL "https://github.com/cpp-pm/hunter/archive/v0.23.244.tar.gz"
SHA1 "2c0f491fd0b80f7b09e3d21adb97237161ef9835" SHA1 "2c0f491fd0b80f7b09e3d21adb97237161ef9835"
LOCAL LOCAL
) )
option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${HUNTER_ENABLED}) option(USE_BUNDLED_BOOST "Use the bundled version of Boost." ${HUNTER_ENABLED})
option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${HUNTER_ENABLED}) option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${HUNTER_ENABLED})
option(USE_BUNDLED_GTEST "Use the bundled version of Google Test." option(USE_BUNDLED_GTEST "Use the bundled version of Google Test."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_CMARK "Use the bundled version of cmark." option(USE_BUNDLED_CMARK "Use the bundled version of cmark."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_JSON "Use the bundled version of nlohmann json." option(USE_BUNDLED_JSON "Use the bundled version of nlohmann json."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_OPENSSL "Use the bundled version of OpenSSL." option(USE_BUNDLED_OPENSSL "Use the bundled version of OpenSSL."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_MTXCLIENT "Use the bundled version of the Matrix Client library." ${HUNTER_ENABLED}) option(USE_BUNDLED_MTXCLIENT "Use the bundled version of the Matrix Client library." ${HUNTER_ENABLED})
option(USE_BUNDLED_SODIUM "Use the bundled version of libsodium." option(USE_BUNDLED_SODIUM "Use the bundled version of libsodium."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_ZLIB "Use the bundled version of zlib." option(USE_BUNDLED_ZLIB "Use the bundled version of zlib."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_LMDB "Use the bundled version of lmdb." option(USE_BUNDLED_LMDB "Use the bundled version of lmdb."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++." option(USE_BUNDLED_LMDBXX "Use the bundled version of lmdb++."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
option(USE_BUNDLED_TWEENY "Use the bundled version of tweeny." option(USE_BUNDLED_TWEENY "Use the bundled version of tweeny."
${HUNTER_ENABLED}) ${HUNTER_ENABLED})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
@ -73,27 +71,27 @@ set(IDENTIFIER "com.github.mujx.nheko")
add_project_meta(META_FILES_TO_INCLUDE) add_project_meta(META_FILES_TO_INCLUDE)
if(NOT MSVC AND NOT APPLE) if(NOT MSVC AND NOT APPLE)
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
endif() endif()
if (BUILD_DOCS) if (BUILD_DOCS)
find_package(Doxygen) find_package(Doxygen)
if (DOXYGEN_FOUND) if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Doxyfile.in) set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT}) configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT})
add_custom_target(docs ALL add_custom_target(docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" COMMENT "Generating API documentation with Doxygen"
VERBATIM ) VERBATIM )
else (DOXYGEN_FOUND) else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation") message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND) endif (DOXYGEN_FOUND)
endif() endif()
@ -117,79 +115,76 @@ find_package(Qt5QuickCompiler)
find_package(Qt5DBus) find_package(Qt5DBus)
if (APPLE) if (APPLE)
find_package(Qt5MacExtras REQUIRED) find_package(Qt5MacExtras REQUIRED)
endif(APPLE) endif(APPLE)
if (Qt5Widgets_FOUND) if (Qt5Widgets_FOUND)
if (Qt5Widgets_VERSION VERSION_LESS 5.7.0) if (Qt5Widgets_VERSION VERSION_LESS 5.9.0)
message(STATUS "Qt version ${Qt5Widgets_VERSION}") message(STATUS "Qt version ${Qt5Widgets_VERSION}")
message(WARNING "Minimum supported Qt5 version is 5.7!") message(WARNING "Minimum supported Qt5 version is 5.9!")
endif() endif()
endif(Qt5Widgets_FOUND) endif(Qt5Widgets_FOUND)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(NOT MSVC) if(NOT MSVC)
set( set(
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} \ "${CMAKE_CXX_FLAGS} \
-Wall \ -Wall \
-Wextra \ -Wextra \
-pipe \ -pipe \
-pedantic \ -pedantic \
-fsized-deallocation \ -fsized-deallocation \
-fdiagnostics-color=always \ -fdiagnostics-color=always \
-Wunreachable-code \ -Wunreachable-code \
-std=c++17" -std=c++17"
) )
if (NOT CMAKE_COMPILER_IS_GNUCXX) if (NOT CMAKE_COMPILER_IS_GNUCXX)
# -Wshadow is buggy and broken in GCC, so do not enable it. # -Wshadow is buggy and broken in GCC, so do not enable it.
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
endif() endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR CI_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
endif() endif()
if (MSVC) if (MSVC)
set( set(
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} /bigobj" "${CMAKE_CXX_FLAGS} /bigobj"
) )
endif() endif()
if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES)) if(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING set(CMAKE_BUILD_TYPE "Debug" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE) FORCE)
message("Setting build type to '${CMAKE_BUILD_TYPE}'") message("Setting build type to '${CMAKE_BUILD_TYPE}'")
else(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES)) else(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
message("Build type set to '${CMAKE_BUILD_TYPE}'") message("Build type set to '${CMAKE_BUILD_TYPE}'")
endif(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES)) endif(NOT (CMAKE_BUILD_TYPE OR CMAKE_CONFIGURATION_TYPES))
set(SPDLOG_DEBUG_ON false) set(SPDLOG_DEBUG_ON false)
# Windows doesn't handle CMAKE_BUILD_TYPE. # Windows doesn't handle CMAKE_BUILD_TYPE.
if(NOT WIN32) if(NOT WIN32)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(SPDLOG_DEBUG_ON true) set(SPDLOG_DEBUG_ON true)
else() else()
set(SPDLOG_DEBUG_ON false) set(SPDLOG_DEBUG_ON false)
endif() endif()
endif() endif()
find_program(GIT git) find_program(GIT git)
if(GIT) if(GIT)
execute_process( execute_process(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT} rev-parse --short HEAD COMMAND ${GIT} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
) )
if(GIT_OUT) if(GIT_OUT)
set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${GIT_OUT}") set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}-${GIT_OUT}")
else() else()
set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}") set(CPACK_PACKAGE_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}")
endif() endif()
endif(GIT) endif(GIT)
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
@ -206,97 +201,97 @@ configure_file(cmake/nheko.h config/nheko.h)
# Declare source and header files. # Declare source and header files.
# #
set(SRC_FILES set(SRC_FILES
# Dialogs # Dialogs
src/dialogs/CreateRoom.cpp src/dialogs/CreateRoom.cpp
src/dialogs/ImageOverlay.cpp src/dialogs/ImageOverlay.cpp
src/dialogs/PreviewUploadOverlay.cpp src/dialogs/PreviewUploadOverlay.cpp
src/dialogs/InviteUsers.cpp src/dialogs/InviteUsers.cpp
src/dialogs/JoinRoom.cpp src/dialogs/JoinRoom.cpp
src/dialogs/MemberList.cpp src/dialogs/MemberList.cpp
src/dialogs/LeaveRoom.cpp src/dialogs/LeaveRoom.cpp
src/dialogs/Logout.cpp src/dialogs/Logout.cpp
src/dialogs/UserProfile.cpp src/dialogs/UserProfile.cpp
src/dialogs/ReadReceipts.cpp src/dialogs/ReadReceipts.cpp
src/dialogs/ReCaptcha.cpp src/dialogs/ReCaptcha.cpp
src/dialogs/RoomSettings.cpp src/dialogs/RoomSettings.cpp
# Emoji # Emoji
src/emoji/Category.cpp src/emoji/Category.cpp
src/emoji/ItemDelegate.cpp src/emoji/ItemDelegate.cpp
src/emoji/Panel.cpp src/emoji/Panel.cpp
src/emoji/PickButton.cpp src/emoji/PickButton.cpp
src/emoji/Provider.cpp src/emoji/Provider.cpp
# Timeline # Timeline
src/timeline/TimelineViewManager.cpp src/timeline/TimelineViewManager.cpp
src/timeline/TimelineModel.cpp src/timeline/TimelineModel.cpp
src/timeline/DelegateChooser.cpp src/timeline/DelegateChooser.cpp
# UI components # UI components
src/ui/Avatar.cpp src/ui/Avatar.cpp
src/ui/Badge.cpp src/ui/Badge.cpp
src/ui/LoadingIndicator.cpp src/ui/LoadingIndicator.cpp
src/ui/InfoMessage.cpp src/ui/InfoMessage.cpp
src/ui/FlatButton.cpp src/ui/FlatButton.cpp
src/ui/FloatingButton.cpp src/ui/FloatingButton.cpp
src/ui/Label.cpp src/ui/Label.cpp
src/ui/OverlayModal.cpp src/ui/OverlayModal.cpp
src/ui/SnackBar.cpp src/ui/SnackBar.cpp
src/ui/RaisedButton.cpp src/ui/RaisedButton.cpp
src/ui/Ripple.cpp src/ui/Ripple.cpp
src/ui/RippleOverlay.cpp src/ui/RippleOverlay.cpp
src/ui/OverlayWidget.cpp src/ui/OverlayWidget.cpp
src/ui/TextField.cpp src/ui/TextField.cpp
src/ui/TextLabel.cpp src/ui/TextLabel.cpp
src/ui/ToggleButton.cpp src/ui/ToggleButton.cpp
src/ui/Theme.cpp src/ui/Theme.cpp
src/ui/ThemeManager.cpp src/ui/ThemeManager.cpp
src/AvatarProvider.cpp src/AvatarProvider.cpp
src/Cache.cpp src/Cache.cpp
src/ChatPage.cpp src/ChatPage.cpp
src/CommunitiesListItem.cpp src/CommunitiesListItem.cpp
src/CommunitiesList.cpp src/CommunitiesList.cpp
src/EventAccessors.cpp src/EventAccessors.cpp
src/InviteeItem.cpp src/InviteeItem.cpp
src/LoginPage.cpp src/LoginPage.cpp
src/Logging.cpp src/Logging.cpp
src/MainWindow.cpp src/MainWindow.cpp
src/MatrixClient.cpp src/MatrixClient.cpp
src/MxcImageProvider.cpp src/MxcImageProvider.cpp
src/ColorImageProvider.cpp src/ColorImageProvider.cpp
src/QuickSwitcher.cpp src/QuickSwitcher.cpp
src/Olm.cpp src/Olm.cpp
src/RegisterPage.cpp src/RegisterPage.cpp
src/RoomInfoListItem.cpp src/RoomInfoListItem.cpp
src/RoomList.cpp src/RoomList.cpp
src/RunGuard.cpp src/RunGuard.cpp
src/SideBarActions.cpp src/SideBarActions.cpp
src/Splitter.cpp src/Splitter.cpp
src/popups/SuggestionsPopup.cpp src/popups/SuggestionsPopup.cpp
src/popups/PopupItem.cpp src/popups/PopupItem.cpp
src/popups/ReplyPopup.cpp src/popups/ReplyPopup.cpp
src/popups/UserMentions.cpp src/popups/UserMentions.cpp
src/TextInputWidget.cpp src/TextInputWidget.cpp
src/TopRoomBar.cpp src/TopRoomBar.cpp
src/TrayIcon.cpp src/TrayIcon.cpp
src/Utils.cpp src/Utils.cpp
src/UserInfoWidget.cpp src/UserInfoWidget.cpp
src/UserSettingsPage.cpp src/UserSettingsPage.cpp
src/WelcomePage.cpp src/WelcomePage.cpp
src/main.cpp src/main.cpp
) )
include(FeatureSummary) include(FeatureSummary)
if(USE_BUNDLED_BOOST) if(USE_BUNDLED_BOOST)
hunter_add_package(Boost COMPONENTS iostreams system thread) hunter_add_package(Boost COMPONENTS iostreams system thread)
endif() endif()
find_package(Boost 1.70 REQUIRED find_package(Boost 1.70 REQUIRED
COMPONENTS iostreams COMPONENTS iostreams
system system
thread) thread)
if(USE_BUNDLED_ZLIB) if(USE_BUNDLED_ZLIB)
hunter_add_package(ZLIB) hunter_add_package(ZLIB)
endif() endif()
@ -358,10 +353,10 @@ if(USE_BUNDLED_JSON)
endif() endif()
find_package(nlohmann_json 3.2.0) find_package(nlohmann_json 3.2.0)
set_package_properties(nlohmann_json PROPERTIES set_package_properties(nlohmann_json PROPERTIES
DESCRIPTION "JSON for Modern C++, a C++11 header-only JSON class" DESCRIPTION "JSON for Modern C++, a C++11 header-only JSON class"
URL "https://nlohmann.github.io/json/" URL "https://nlohmann.github.io/json/"
TYPE REQUIRED TYPE REQUIRED
) )
if(USE_BUNDLED_LMDBXX) if(USE_BUNDLED_LMDBXX)
hunter_add_package(lmdbxx) hunter_add_package(lmdbxx)
@ -396,80 +391,80 @@ endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
qt5_wrap_cpp(MOC_HEADERS qt5_wrap_cpp(MOC_HEADERS
# Dialogs # Dialogs
src/dialogs/CreateRoom.h src/dialogs/CreateRoom.h
src/dialogs/ImageOverlay.h src/dialogs/ImageOverlay.h
src/dialogs/PreviewUploadOverlay.h src/dialogs/PreviewUploadOverlay.h
src/dialogs/InviteUsers.h src/dialogs/InviteUsers.h
src/dialogs/JoinRoom.h src/dialogs/JoinRoom.h
src/dialogs/MemberList.h src/dialogs/MemberList.h
src/dialogs/LeaveRoom.h src/dialogs/LeaveRoom.h
src/dialogs/Logout.h src/dialogs/Logout.h
src/dialogs/UserProfile.h src/dialogs/UserProfile.h
src/dialogs/RawMessage.h src/dialogs/RawMessage.h
src/dialogs/ReadReceipts.h src/dialogs/ReadReceipts.h
src/dialogs/ReCaptcha.h src/dialogs/ReCaptcha.h
src/dialogs/RoomSettings.h src/dialogs/RoomSettings.h
# Emoji # Emoji
src/emoji/Category.h src/emoji/Category.h
src/emoji/ItemDelegate.h src/emoji/ItemDelegate.h
src/emoji/Panel.h src/emoji/Panel.h
src/emoji/PickButton.h src/emoji/PickButton.h
# Timeline # Timeline
src/timeline/TimelineViewManager.h src/timeline/TimelineViewManager.h
src/timeline/TimelineModel.h src/timeline/TimelineModel.h
src/timeline/DelegateChooser.h src/timeline/DelegateChooser.h
# UI components # UI components
src/ui/Avatar.h src/ui/Avatar.h
src/ui/Badge.h src/ui/Badge.h
src/ui/LoadingIndicator.h src/ui/LoadingIndicator.h
src/ui/InfoMessage.h src/ui/InfoMessage.h
src/ui/FlatButton.h src/ui/FlatButton.h
src/ui/Label.h src/ui/Label.h
src/ui/FloatingButton.h src/ui/FloatingButton.h
src/ui/Menu.h src/ui/Menu.h
src/ui/OverlayWidget.h src/ui/OverlayWidget.h
src/ui/SnackBar.h src/ui/SnackBar.h
src/ui/RaisedButton.h src/ui/RaisedButton.h
src/ui/Ripple.h src/ui/Ripple.h
src/ui/RippleOverlay.h src/ui/RippleOverlay.h
src/ui/TextField.h src/ui/TextField.h
src/ui/TextLabel.h src/ui/TextLabel.h
src/ui/ToggleButton.h src/ui/ToggleButton.h
src/ui/Theme.h src/ui/Theme.h
src/ui/ThemeManager.h src/ui/ThemeManager.h
src/notifications/Manager.h src/notifications/Manager.h
src/AvatarProvider.h src/AvatarProvider.h
src/Cache_p.h src/Cache_p.h
src/ChatPage.h src/ChatPage.h
src/CommunitiesListItem.h src/CommunitiesListItem.h
src/CommunitiesList.h src/CommunitiesList.h
src/LoginPage.h src/LoginPage.h
src/MainWindow.h src/MainWindow.h
src/MxcImageProvider.h src/MxcImageProvider.h
src/InviteeItem.h src/InviteeItem.h
src/QuickSwitcher.h src/QuickSwitcher.h
src/RegisterPage.h src/RegisterPage.h
src/RoomInfoListItem.h src/RoomInfoListItem.h
src/RoomList.h src/RoomList.h
src/SideBarActions.h src/SideBarActions.h
src/Splitter.h src/Splitter.h
src/popups/SuggestionsPopup.h src/popups/SuggestionsPopup.h
src/popups/ReplyPopup.h src/popups/ReplyPopup.h
src/popups/PopupItem.h src/popups/PopupItem.h
src/popups/UserMentions.h src/popups/UserMentions.h
src/TextInputWidget.h src/TextInputWidget.h
src/TopRoomBar.h src/TopRoomBar.h
src/TrayIcon.h src/TrayIcon.h
src/UserInfoWidget.h src/UserInfoWidget.h
src/UserSettingsPage.h src/UserSettingsPage.h
src/WelcomePage.h src/WelcomePage.h
) )
# #
# Bundle translations. # Bundle translations.
@ -477,97 +472,103 @@ qt5_wrap_cpp(MOC_HEADERS
include(Translations) include(Translations)
set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC}) set(TRANSLATION_DEPS ${LANG_QRC} ${QRC} ${QM_SRC})
set(COMMON_LIBS
MatrixClient::MatrixClient
Boost::iostreams
Boost::system
Boost::thread
cmark::cmark
spdlog::spdlog
Qt5::Widgets
Qt5::Svg
Qt5::Concurrent
Qt5::Multimedia
Qt5::Qml
Qt5::QuickControls2
Qt5::QuickWidgets
nlohmann_json::nlohmann_json
lmdbxx::lmdbxx
tweeny)
if(USE_BUNDLED_LMDB)
set(NHEKO_LIBS ${COMMON_LIBS} liblmdb::lmdb)
else()
set(NHEKO_LIBS ${COMMON_LIBS} PkgConfig::lmdb)
endif()
if (APPLE) if (APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa")
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm src/emoji/MacHelper.mm) set(SRC_FILES ${SRC_FILES} src/notifications/ManagerMac.mm src/emoji/MacHelper.mm)
elseif (WIN32) elseif (WIN32)
file(DOWNLOAD file(DOWNLOAD
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp" "https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp"
${PROJECT_SOURCE_DIR}/src/wintoastlib.cpp ${PROJECT_SOURCE_DIR}/src/wintoastlib.cpp
EXPECTED_HASH SHA256=1A1A7CE41C1052B12946798F4A6C67CE1FAD209C967F5ED4D720B173527E2073) EXPECTED_HASH SHA256=1A1A7CE41C1052B12946798F4A6C67CE1FAD209C967F5ED4D720B173527E2073)
file(DOWNLOAD file(DOWNLOAD
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.h" "https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.h"
${PROJECT_SOURCE_DIR}/src/wintoastlib.h ${PROJECT_SOURCE_DIR}/src/wintoastlib.h
EXPECTED_HASH SHA256=b4481023c5782733795838be22bf1a75f45d87458cd4d9a5a75f664a146eea11) EXPECTED_HASH SHA256=b4481023c5782733795838be22bf1a75f45d87458cd4d9a5a75f664a146eea11)
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerWin.cpp src/wintoastlib.cpp) set(SRC_FILES ${SRC_FILES} src/notifications/ManagerWin.cpp src/wintoastlib.cpp)
else () else ()
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerLinux.cpp) set(SRC_FILES ${SRC_FILES} src/notifications/ManagerLinux.cpp)
endif () endif ()
set(NHEKO_DEPS set(NHEKO_DEPS
${SRC_FILES} ${SRC_FILES}
${UI_HEADERS} ${UI_HEADERS}
${MOC_HEADERS} ${MOC_HEADERS}
${TRANSLATION_DEPS} ${TRANSLATION_DEPS}
${META_FILES_TO_INCLUDE}) ${META_FILES_TO_INCLUDE})
if(ASAN) if(ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined")
endif() endif()
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
if(APPLE) if(APPLE)
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS}) target_link_libraries (nheko PRIVATE Qt5::MacExtras)
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::MacExtras)
elseif(WIN32) elseif(WIN32)
add_executable (nheko ${OS_BUNDLE} ${ICON_FILE} ${NHEKO_DEPS}) target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN)
target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN) target_link_libraries (nheko PRIVATE ${NTDLIB} Qt5::WinMain)
target_link_libraries (nheko ${NTDLIB} ${NHEKO_LIBS} Qt5::WinMain)
else() else()
add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS}) target_link_libraries (nheko PRIVATE Qt5::DBus)
target_link_libraries (nheko ${NHEKO_LIBS} Qt5::DBus)
endif() endif()
target_include_directories(nheko PRIVATE src includes) target_include_directories(nheko PRIVATE src includes)
target_link_libraries(nheko PRIVATE
MatrixClient::MatrixClient
Boost::iostreams
Boost::system
Boost::thread
cmark::cmark
spdlog::spdlog
Qt5::Widgets
Qt5::Svg
Qt5::Concurrent
Qt5::Multimedia
Qt5::Qml
Qt5::QuickControls2
Qt5::QuickWidgets
nlohmann_json::nlohmann_json
lmdbxx::lmdbxx
tweeny)
if(USE_BUNDLED_LMDB)
target_link_libraries(nheko PRIVATE liblmdb::lmdb)
else()
target_link_libraries(nheko PRIVATE PkgConfig::lmdb)
endif()
if(QML_DEBUGGING) if(QML_DEBUGGING)
target_compile_definitions(nheko PRIVATE QML_DEBUGGING) target_compile_definitions(nheko PRIVATE QML_DEBUGGING)
endif() endif()
if(NOT MSVC)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR CI_BUILD)
target_compile_options(nheko PRIVATE "-Werror")
endif()
endif()
set_target_properties(nheko PROPERTIES SKIP_BUILD_RPATH TRUE) set_target_properties(nheko PROPERTIES SKIP_BUILD_RPATH TRUE)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
install (TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") install (TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install (FILES "resources/nheko-16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "nheko.png") install (FILES "resources/nheko-16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "nheko.png")
install (FILES "resources/nheko-32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "nheko.png") install (FILES "resources/nheko-32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "nheko.png")
install (FILES "resources/nheko-48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "nheko.png") install (FILES "resources/nheko-48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "nheko.png")
install (FILES "resources/nheko-64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "nheko.png") install (FILES "resources/nheko-64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "nheko.png")
install (FILES "resources/nheko-128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "nheko.png") install (FILES "resources/nheko-128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "nheko.png")
install (FILES "resources/nheko-256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "nheko.png") install (FILES "resources/nheko-256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "nheko.png")
install (FILES "resources/nheko-512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "nheko.png") install (FILES "resources/nheko-512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "nheko.png")
install (FILES "resources/nheko.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") install (FILES "resources/nheko.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install (FILES "resources/nheko.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo") install (FILES "resources/nheko.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
if(NOT TARGET uninstall) if(NOT TARGET uninstall)
configure_file( configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY) IMMEDIATE @ONLY)
add_custom_target(uninstall add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif() endif()
endif() endif()