Gittyup/CMakeLists.txt

174 lines
4.9 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.12)
2021-10-19 16:05:47 +03:00
project(Gittyup)
2018-12-13 02:22:04 +03:00
# Set name and version.
2021-10-19 16:05:47 +03:00
set(GITTYUP_NAME "Gittyup")
2023-02-23 12:29:14 +03:00
set(GITTYUP_EXECUTABLE_NAME "gittyup")
set(GITTYUP_IDENTIFIER "com.github.Murmele.Gittyup")
2021-11-18 18:38:28 +03:00
set(GITTYUP_VERSION_MAJOR 1)
set(GITTYUP_VERSION_MINOR 3)
set(GITTYUP_VERSION_PATCH 0)
2021-10-19 16:05:47 +03:00
set(GITTYUP_VERSION
2022-05-01 10:51:34 +03:00
"${GITTYUP_VERSION_MAJOR}.${GITTYUP_VERSION_MINOR}.${GITTYUP_VERSION_PATCH}"
2018-12-13 02:22:04 +03:00
)
string(TIMESTAMP CURR_YEAR "%Y")
add_compile_definitions(CURR_YEAR=${CURR_YEAR})
configure_file(${CMAKE_SOURCE_DIR}/LICENSE.md.in ${CMAKE_SOURCE_DIR}/LICENSE.md
2023-04-12 19:07:21 +03:00
@ONLY NEWLINE_STYLE UNIX)
2022-05-01 10:51:34 +03:00
# Write version to file so it can be used also from external, for example in the
# github manifest
2022-04-21 19:09:58 +03:00
file(WRITE "${CMAKE_BINARY_DIR}/Version.txt" ${GITTYUP_VERSION})
2022-05-01 10:51:34 +03:00
set(DEV_BUILD
""
CACHE STRING
"Mark this build as a development build with the given description")
2022-05-01 10:51:34 +03:00
if(DEV_BUILD)
set(BUILD_DESCRIPTION " (development build: ${DEV_BUILD})")
else()
set(BUILD_DESCRIPTION "")
endif()
2018-12-13 02:22:04 +03:00
# Generate build date.
2021-10-19 16:05:47 +03:00
string(TIMESTAMP GITTYUP_BUILD_DATE)
2018-12-13 02:22:04 +03:00
# Lookup git revision.
find_package(Git)
if(GIT_FOUND)
execute_process(
2022-05-01 10:51:34 +03:00
COMMAND ${GIT_EXECUTABLE} --git-dir=${CMAKE_SOURCE_DIR}/.git show -s
--format=%h HEAD
2021-10-19 16:05:47 +03:00
OUTPUT_VARIABLE GITTYUP_BUILD_REVISION
2022-05-01 10:51:34 +03:00
OUTPUT_STRIP_TRAILING_WHITESPACE)
2018-12-13 02:22:04 +03:00
else()
2021-10-19 16:05:47 +03:00
set(GITTYUP_BUILD_REVISION "unknown")
2018-12-13 02:22:04 +03:00
endif()
# Explicitly disable shared libraries.
set(BUILD_SHARED_LIBS OFF)
option(FLATPAK "Building for flatpak" OFF)
2022-09-19 02:24:59 +03:00
option(DEBUG_FLATPAK "Building but using flatpak urls for testing" OFF)
2023-01-25 11:48:27 +03:00
option(ENABLE_UPDATE_OVER_GUI "Enable updating from the Gittyup gui" ON)
option(USE_SYSTEM_OPENSSL "Use the system-wide OpenSSL installation" OFF)
option(
USE_SYSTEM_LIBGIT2
"Use the system-wide libgit2 installation (Gittyup requires the current development branch)"
OFF)
option(USE_SYSTEM_LIBSSH2 "Use the system-wide libssh2 installation" OFF)
option(USE_SYSTEM_GIT "Use the system-wide GIT installation" OFF)
option(USE_SYSTEM_QT "Don't copy QT files into the installation directory" OFF)
option(USE_SYSTEM_LUA "Use the system-wide Lua installation" OFF)
option(USE_SYSTEM_HUNSPELL "Use the system-wide hunspell installation" OFF)
option(USE_SYSTEM_CMARK "Use the system-wide cmark installation" OFF)
option(ENABLE_TESTS "Enable Gittyup Unittests" ON)
set(LUA_MODULES_PATH
CACHE
PATH
"Path to the directory with native Lua modules (only relevant if system-wide Lua installation is used)"
)
2020-11-14 19:46:11 +03:00
# Require C++17.
set(CMAKE_CXX_STANDARD 17)
2018-12-13 02:22:04 +03:00
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(HAIKU)
# qsort_r in libgit2 requires this
set(CMAKE_EXE_LINKER_FLAGS -lgnu)
elseif(UNIX AND NOT APPLE)
2018-12-13 02:22:04 +03:00
set(CMAKE_EXE_LINKER_FLAGS -ldl)
endif()
# Find Qt modules.
set(QT_MODULES
2022-05-01 10:51:34 +03:00
Concurrent
Core
Gui
Network
PrintSupport
Widgets
Test)
2018-12-13 02:22:04 +03:00
if(UNIX)
set(QT_MODULES ${QT_MODULES} DBus)
endif()
option(DEBUG_OUTPUT
"Print debug output (Only available if debug menu is enabled!)" ON)
option(DEBUG_OUTPUT_GENERAL "Enable general debug messages" ON)
option(DEBUG_OUTPUT_REFRESH "Enable debug messages to debug the refresh flow"
OFF)
if(NOT DEBUG_OUTPUT)
add_compile_definitions(QT_NO_DEBUG_OUTPUT)
else()
if(DEBUG_OUTPUT_GENERAL)
add_compile_definitions(DEBUG_OUTPUT_GENERAL)
endif()
if(DEBUG_OUTPUT_REFRESH)
add_compile_definitions(DEBUG_OUTPUT_REFRESH)
endif()
endif()
2022-05-01 10:51:34 +03:00
find_package(
Qt5 5.12
COMPONENTS ${QT_MODULES} LinguistTools
REQUIRED)
if(FLATPAK)
find_package(
Qt5 5.15
COMPONENTS XcbQpa
REQUIRED)
add_compile_definitions(FLATPAK)
endif()
2018-12-13 02:22:04 +03:00
2023-01-25 11:48:27 +03:00
if(ENABLE_UPDATE_OVER_GUI)
add_compile_definitions(ENABLE_UPDATE_OVER_GUI)
endif()
2022-09-19 02:24:59 +03:00
if(DEBUG_FLATPAK)
add_compile_definitions(DEBUG_FLATPAK)
endif()
2022-06-10 15:28:28 +03:00
include(GNUInstallDirs) # Defines some variables as BINDIR, LIBDIR, ...
2019-12-07 06:13:33 +03:00
set(QT_TRANSLATIONS_DIR "${Qt5_DIR}/../../../translations")
2021-07-31 19:28:36 +03:00
set(QT_TRANSLATIONS_DIR "/usr/share/qt/translations")
2019-12-07 06:13:33 +03:00
2019-10-18 23:13:55 +03:00
if(APPLE)
foreach(QT_MODULE ${QT_MODULES})
2022-05-01 10:51:34 +03:00
# FIXME: Force debug build to link against release libraries inside of
# frameworks on macOS. The Qt debug libraries are broken because their link
# dependencies are to the release libraries (e.g. QtGui_debug depends on
# QtCore). This causes multiple symbol definition errors at application load
# time.
2019-10-18 23:13:55 +03:00
get_target_property(LOCATION Qt5::${QT_MODULE} LOCATION)
2022-05-01 10:51:34 +03:00
set_target_properties(Qt5::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG
${LOCATION})
2019-10-18 23:13:55 +03:00
endforeach()
endif()
2023-01-23 21:43:05 +03:00
if(APPLE)
2023-02-23 13:45:19 +03:00
set(CONTENTS_DIR ${GITTYUP_EXECUTABLE_NAME}.app/Contents)
2023-01-27 19:04:28 +03:00
set(RESOURCES_DIR ${CONTENTS_DIR}/Resources)
2023-02-22 11:27:10 +03:00
set(L10N_INSTALL_DIR ${RESOURCES_DIR}/l10n)
2023-01-23 21:43:05 +03:00
elseif(UNIX)
2023-01-23 22:00:06 +03:00
set(L10N_INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${GITTYUP_NAME})
set(RESOURCES_DIR ${CMAKE_INSTALL_DATADIR}/${GITTYUP_NAME})
2023-01-23 21:43:05 +03:00
else()
2023-01-27 19:04:28 +03:00
set(L10N_INSTALL_DIR Resources/l10n)
set(RESOURCES_DIR Resources)
2023-01-23 21:43:05 +03:00
endif()
2018-12-13 02:22:04 +03:00
add_subdirectory(dep)
add_subdirectory(src)
add_subdirectory(l10n)
2018-12-13 02:22:04 +03:00
add_subdirectory(pack)
if(ENABLE_TESTS)
add_subdirectory(test)
endif()