Merge pull request #1565 from Nheko-Reborn/cmake_formatting

Format CMakeLists.txt
This commit is contained in:
DeepBlueV7.X 2023-10-01 12:51:02 +00:00 committed by GitHub
commit c7940277b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,7 @@ set(
CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake"
CACHE
FILEPATH "Default toolchain"
)
)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ standard")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard to be supported")
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default")
@ -68,12 +68,12 @@ option(USE_BUNDLED_BLURHASH "Use the bundled version of blurhash." ON)
include(CMakeDependentOption)
set(VOIP_DEFAULT ON)
if (APPLE OR WIN32)
if(APPLE OR WIN32)
set(VOIP_DEFAULT OFF)
endif()
option(VOIP "Whether to enable voip support. Disable this, if you don't have gstreamer." ${VOIP_DEFAULT})
set(X11_DEFAULT)
if (WIN32 OR APPLE OR HAIKU)
if(WIN32 OR APPLE OR HAIKU)
set(X11_DEFAULT OFF)
endif()
option(X11 "Whether to enable X11 specific features (screenshare, window roles)." ${X11_DEFAULT})
@ -85,7 +85,6 @@ if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
message("Adding FetchContent_MakeAvailable")
# from cmakes sources
macro(FetchContent_MakeAvailable)
foreach(contentName IN ITEMS ${ARGV})
string(TOLOWER ${contentName} contentNameLower)
FetchContent_GetProperties(${contentName})
@ -103,7 +102,6 @@ if(${CMAKE_VERSION} VERSION_LESS "3.14.0")
endif()
endif()
endforeach()
endmacro()
endif()
@ -137,10 +135,10 @@ if(NOT MSVC AND NOT APPLE)
find_package(Threads REQUIRED)
endif()
if (BUILD_DOCS)
if(BUILD_DOCS)
find_package(Doxygen)
if (DOXYGEN_FOUND)
if(DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
@ -151,31 +149,30 @@ if (BUILD_DOCS)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
else(DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif(DOXYGEN_FOUND)
endif()
#
## coeurl
#
## Need to repeat all libevent deps?!?
if (USE_BUNDLED_LIBEVENT)
if(USE_BUNDLED_LIBEVENT)
hunter_add_package_safe(Libevent)
find_package(Libevent CONFIG REQUIRED)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(libevent_core REQUIRED IMPORTED_TARGET libevent_core)
if (WIN32)
if(WIN32)
pkg_check_modules(libevent_windows REQUIRED IMPORTED_TARGET libevent_windows)
else()
pkg_check_modules(libevent_pthreads REQUIRED IMPORTED_TARGET
libevent_pthreads)
pkg_check_modules(libevent_pthreads REQUIRED IMPORTED_TARGET libevent_pthreads)
endif()
endif()
# curl
if (USE_BUNDLED_LIBCURL)
if(USE_BUNDLED_LIBCURL)
hunter_add_package_safe(CURL)
find_package(CURL CONFIG REQUIRED)
else()
@ -201,19 +198,19 @@ if(USE_BUNDLED_COEURL)
else()
find_package(PkgConfig)
pkg_check_modules(coeurl IMPORTED_TARGET coeurl>=0.3.0)
if (TARGET PkgConfig::coeurl)
if(TARGET PkgConfig::coeurl)
set(COEURL_TARGET_NAME PkgConfig::coeurl)
endif()
endif()
if(NOT TARGET PkgConfig::coeurl)
find_package(coeurl 0.2.1 CONFIG)
if (TARGET coeurl::coeurl)
if(TARGET coeurl::coeurl)
set(COEURL_TARGET_NAME coeurl::coeurl)
endif()
endif()
if (NOT COEURL_TARGET_NAME)
if(NOT COEURL_TARGET_NAME)
message(ERROR "Couldn't find coeurl")
endif()
@ -225,7 +222,6 @@ else()
pkg_check_modules(re2 REQUIRED IMPORTED_TARGET re2)
endif()
#
# LMDB
#
@ -247,7 +243,7 @@ find_package(Qt6 6.5 COMPONENTS Core Widgets Gui LinguistTools Svg Multimedia Qm
#find_package(Qt6QuickCompiler)
find_package(Qt6DBus)
if (USE_BUNDLED_QTKEYCHAIN)
if(USE_BUNDLED_QTKEYCHAIN)
include(FetchContent)
set(BUILD_WITH_QT6 ON)
FetchContent_Declare(
@ -255,7 +251,7 @@ if (USE_BUNDLED_QTKEYCHAIN)
GIT_REPOSITORY https://github.com/frankosterfeld/qtkeychain.git
GIT_TAG v0.14.0
)
if (BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS)
set(QTKEYCHAIN_STATIC OFF CACHE INTERNAL "")
else()
set(QTKEYCHAIN_STATIC ON CACHE INTERNAL "")
@ -266,8 +262,8 @@ else()
find_package(Qt6Keychain REQUIRED)
endif()
if (Qt6Widgets_FOUND)
if (Qt6Widgets_VERSION VERSION_LESS 6.5.0)
if(Qt6Widgets_FOUND)
if(Qt6Widgets_VERSION VERSION_LESS 6.5.0)
message(STATUS "Qt version ${Qt6Widgets_VERSION}")
message(WARNING "Minimum supported Qt6 version is 6.5!")
endif()
@ -286,14 +282,14 @@ if(NOT MSVC)
-Wunreachable-code \
-Wno-attributes"
)
if (NOT CMAKE_COMPILER_IS_GNUCXX)
if(NOT CMAKE_COMPILER_IS_GNUCXX)
# -Wshadow is buggy and broken in GCC, so do not enable it.
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
endif()
endif()
if (MSVC)
if(MSVC)
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} /bigobj"
@ -507,11 +503,10 @@ set(SRC_FILES
includes/jdenticoninterface.h
src/main.cpp
)
)
include(FeatureSummary)
if(USE_BUNDLED_OPENSSL)
hunter_add_package_safe(OpenSSL)
endif()
@ -547,7 +542,7 @@ if(USE_BUNDLED_CMARK)
CMAKE_ARGS "CMARK_STATIC=ON CMARK_SHARED=OFF CMARK_TESTS=OFF CMARK_TESTS=OFF"
)
FetchContent_MakeAvailable(cmark)
if (MSVC)
if(MSVC)
add_library(cmark::cmark ALIAS cmark)
else()
add_library(cmark::cmark ALIAS cmark_static)
@ -564,7 +559,7 @@ set_package_properties(nlohmann_json PROPERTIES
DESCRIPTION "JSON for Modern C++, a C++11 header-only JSON class"
URL "https://nlohmann.github.io/json/"
TYPE REQUIRED
)
)
if(USE_BUNDLED_LMDBXX)
include(FetchContent)
@ -587,7 +582,6 @@ else()
/usr/local/include
$ENV{LIB_DIR}/include
$ENV{LIB_DIR}/include/lmdbxx)
endif()
add_library(lmdbxx INTERFACE)
target_include_directories(lmdbxx INTERFACE ${LMDBXX_INCLUDE_DIR})
@ -608,12 +602,12 @@ else()
find_package(MatrixClient 0.9.0 REQUIRED)
endif()
if (VOIP)
if(VOIP)
include(FindPkgConfig)
pkg_check_modules(GSTREAMER REQUIRED IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18)
endif()
if (X11 AND NOT WIN32 AND NOT APPLE AND NOT HAIKU)
if(X11 AND NOT WIN32 AND NOT APPLE AND NOT HAIKU)
pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb xcb-ewmh)
endif()
@ -624,7 +618,7 @@ add_subdirectory(third_party/SingleApplication-3.3.2/)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
# this must be defined here to make the moc work properly
if (NOT APPLE AND NOT WIN32)
if(NOT APPLE AND NOT WIN32)
add_compile_definitions(NHEKO_DBUS_SYS)
endif()
@ -637,13 +631,13 @@ else()
qt_add_resources(QRC resources/res.qrc)
endif()
if (APPLE)
if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Foundation -framework Cocoa -framework UserNotifications")
set(SRC_FILES ${SRC_FILES} src/notifications/NotificationManagerProxy.h src/notifications/MacNotificationDelegate.h src/notifications/MacNotificationDelegate.mm src/notifications/ManagerMac.mm src/notifications/ManagerMac.cpp src/emoji/MacHelper.mm src/emoji/MacHelper.h)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
set_source_files_properties( src/notifications/NotificationManagerProxy.h src/notifications/MacNotificationDelegate.h src/notifications/MacNotificationDelegate.mm src/notifications/ManagerMac.mm src/emoji/MacHelper.mm src/emoji/MacHelper.h PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
endif()
elseif (WIN32)
elseif(WIN32)
file(DOWNLOAD
"https://raw.githubusercontent.com/mohabouje/WinToast/41ed1c58d5dce0ee9c01dbdeac05be45358d4f57/src/wintoastlib.cpp"
${PROJECT_SOURCE_DIR}/src/wintoastlib.cpp
@ -655,7 +649,7 @@ elseif (WIN32)
EXPECTED_HASH SHA256=b4481023c5782733795838be22bf1a75f45d87458cd4d9a5a75f664a146eea11)
set(SRC_FILES ${SRC_FILES} src/notifications/ManagerWin.cpp src/wintoastlib.cpp src/wintoastlib.h)
else ()
else()
set(SRC_FILES ${SRC_FILES}
src/dbus/NhekoDBusApi.h
src/dbus/NhekoDBusBackend.h
@ -663,7 +657,7 @@ else ()
src/dbus/NhekoDBusBackend.cpp
src/notifications/ManagerLinux.cpp
)
endif ()
endif()
set(NHEKO_DEPS
${SRC_FILES}
@ -675,12 +669,12 @@ if(ASAN)
endif()
if(WIN32)
qt_add_executable (nheko WIN32 ${OS_BUNDLE} ${NHEKO_DEPS})
qt_add_executable(nheko WIN32 ${OS_BUNDLE} ${NHEKO_DEPS})
target_compile_definitions(nheko PRIVATE _WIN32_WINNT=0x0601 NOMINMAX WIN32_LEAN_AND_MEAN STRICT)
else()
qt_add_executable (nheko ${OS_BUNDLE} ${NHEKO_DEPS})
qt_add_executable(nheko ${OS_BUNDLE} ${NHEKO_DEPS})
if (HAVE_BACKTRACE_SYMBOLS_FD AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
if(HAVE_BACKTRACE_SYMBOLS_FD AND NOT CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(nheko PROPERTIES ENABLE_EXPORTS ON)
endif()
endif()
@ -811,12 +805,11 @@ qt_add_qml_module(nheko
SOURCES
src/UserDirectoryModel.cpp
src/UserDirectoryModel.h
)
)
#qt_target_qml_sources(nheko
# #PREFIX "/"
#)
#
# Bundle translations
#
@ -824,22 +817,21 @@ file(GLOB LANG_TS_SRC "${CMAKE_CURRENT_SOURCE_DIR}/resources/langs/*.ts")
qt_add_translations(nheko RESOURCE_PREFIX "/translations" TS_FILES
${LANG_TS_SRC} SOURCES ${QML_SOURCES} ${SRC_FILES})
if(WIN32)
target_compile_definitions(nheko PRIVATE WIN32_LEAN_AND_MEAN)
if(MSVC)
target_compile_options(nheko PUBLIC "/Zc:__cplusplus")
endif()
else()
target_link_libraries (nheko PRIVATE Qt6::DBus)
if (FLATPAK)
target_link_libraries(nheko PRIVATE Qt6::DBus)
if(FLATPAK)
target_compile_definitions(nheko PRIVATE NHEKO_FLATPAK)
endif()
endif()
target_include_directories(nheko PRIVATE src includes src/timeline/ src/ui/ src/encryption/ src/voip/)
if (USE_BUNDLED_CPPHTTPLIB)
if(USE_BUNDLED_CPPHTTPLIB)
target_include_directories(nheko PRIVATE third_party/cpp-httplib-0.5.12)
target_sources(nheko PRIVATE third_party/cpp-httplib-0.5.12/httplib.h)
else()
@ -847,7 +839,7 @@ else()
target_link_libraries(nheko PRIVATE httplib::httplib)
endif()
if (USE_BUNDLED_BLURHASH)
if(USE_BUNDLED_BLURHASH)
target_include_directories(nheko PRIVATE third_party/blurhash)
set(BLURHASH_SRC_FILES
third_party/blurhash/blurhash.cpp
@ -861,11 +853,11 @@ else()
endif()
# Fixup bundled keychain include dirs
if (USE_BUNDLED_QTKEYCHAIN)
if(USE_BUNDLED_QTKEYCHAIN)
target_include_directories(nheko PRIVATE ${qt6keychain_SOURCE_DIR} ${qt6keychain_BINARY_DIR})
endif()
if (NOT JSON_ImplicitConversions)
if(NOT JSON_ImplicitConversions)
set_target_properties(nlohmann_json::nlohmann_json PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "JSON_USE_IMPLICIT_CONVERSIONS=\$<BOOL:OFF>;JSON_DIAGNOSTICS=\$<BOOL:OFF>"
)
@ -897,11 +889,11 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
)
endif()
if (TARGET PkgConfig::GSTREAMER)
if(TARGET PkgConfig::GSTREAMER)
target_link_libraries(nheko PRIVATE PkgConfig::GSTREAMER)
target_compile_definitions(nheko PRIVATE GSTREAMER_AVAILABLE)
endif()
if (TARGET PkgConfig::XCB)
if(TARGET PkgConfig::XCB)
target_link_libraries(nheko PRIVATE PkgConfig::XCB)
target_compile_definitions(nheko PRIVATE XCB_AVAILABLE)
endif()
@ -910,12 +902,10 @@ if(MSVC)
target_link_libraries(nheko PRIVATE ntdll)
endif()
if(QML_DEBUGGING)
target_compile_definitions(nheko PRIVATE QML_DEBUGGING)
endif()
if(NOT MSVC AND NOT HAIKU)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR CI_BUILD)
target_compile_options(nheko PRIVATE "-Werror")
@ -951,21 +941,21 @@ if(UNIX AND NOT APPLE)
set(APPID "nheko")
endif()
install (TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install (FILES "resources/nheko-16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "${APPID}.png")
install (FILES "resources/nheko-32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "${APPID}.png")
install (FILES "resources/nheko-48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "${APPID}.png")
install (FILES "resources/nheko-64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "${APPID}.png")
install (FILES "resources/nheko-128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "${APPID}.png")
install (FILES "resources/nheko-256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "${APPID}.png")
install (FILES "resources/nheko-512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "${APPID}.png")
install (FILES "resources/nheko.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" RENAME "${APPID}.svg")
install (FILES "resources/_nheko" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions")
install(TARGETS nheko RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES "resources/nheko-16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "${APPID}.png")
install(FILES "resources/nheko-32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "${APPID}.png")
install(FILES "resources/nheko-48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "${APPID}.png")
install(FILES "resources/nheko-64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/64x64/apps" RENAME "${APPID}.png")
install(FILES "resources/nheko-128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "${APPID}.png")
install(FILES "resources/nheko-256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "${APPID}.png")
install(FILES "resources/nheko-512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "${APPID}.png")
install(FILES "resources/nheko.svg" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" RENAME "${APPID}.svg")
install(FILES "resources/_nheko" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/zsh/site-functions")
configure_file("resources/nheko.desktop.in" "resources/nheko.desktop" @ONLY)
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/nheko.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" RENAME "${APPID}.desktop")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/nheko.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" RENAME "${APPID}.desktop")
configure_file("resources/nheko.appdata.xml.in" "resources/nheko.appdata.xml" @ONLY)
install (FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/nheko.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo" RENAME "${APPID}.appdata.xml")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/resources/nheko.appdata.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo" RENAME "${APPID}.appdata.xml")
if(NOT TARGET uninstall)
configure_file(