-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
160 lines (143 loc) · 5.34 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Copyright © 2018 TermySequence LLC
#
# SPDX-License-Identifier: GPL-2.0-only
CMAKE_MINIMUM_REQUIRED(VERSION 3.9.0)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
CMAKE_POLICY(SET CMP0048 NEW)
PROJECT(termysequence VERSION 1.1.4)
OPTION(BUILD_SERVER "Build the server and monitor" ON)
OPTION(BUILD_QTGUI "Build the Qt client" ON)
OPTION(BUILD_TESTS "Build tests" OFF)
OPTION(MAINTAINER_MODE "Build maintainer utilities" OFF)
OPTION(USE_SYSTEMD "Enable systemd socket activation and sd-bus monitor" ON)
OPTION(USE_LIBGIT2 "Enable git file monitoring feature" ON)
OPTION(USE_FUSE3 "Enable remote file mounting feature via libfuse3" ON)
OPTION(USE_FUSE2 "Enable remote file mounting feature via libfuse2" OFF)
OPTION(NATIVE_DIALOGS "Use native dialog boxes" ON)
OPTION(SU_NEEDS_PTY "Use a pty by default when running su" OFF)
SET(V8_ARCH "x64" CACHE STRING "Architecture parameter for V8 build")
SET(V8_ARMFP "" CACHE STRING "ARM floating-point ABI parameter for V8 build")
SET(V8_JOBS "2" CACHE STRING "Number of V8 build commands to run in parallel")
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
SET(FRIENDLY_NAME "DebugSequence")
SET(DEBUG_SUFFIX "d")
ELSE()
SET(FRIENDLY_NAME "TermySequence")
SET(NDEBUG 1)
ENDIF()
SET(ORG_NAME "TermySequence LLC")
SET(ORG_DOMAIN "termysequence.com")
SET(PRODUCT_DOMAIN "termysequence.io")
SET(PRODUCT_RDOMAIN "io.termysequence.")
SET(ENV_NAME "TERMYSEQUENCE")
SET(ABBREV_NAME termy)
SET(SERVER_NAME ${ABBREV_NAME}-server${DEBUG_SUFFIX})
SET(FORWARDER_NAME ${ABBREV_NAME}-forwrd${DEBUG_SUFFIX}) # Same length as SERVER_NAME
SET(MONITOR_NAME ${ABBREV_NAME}-monitor${DEBUG_SUFFIX})
SET(CONNECT_NAME ${ABBREV_NAME}-connect${DEBUG_SUFFIX})
SET(QUERY_NAME ${ABBREV_NAME}-query${DEBUG_SUFFIX})
SET(SETUP_NAME ${ABBREV_NAME}-setup${DEBUG_SUFFIX})
SET(APP_NAME qtermy${DEBUG_SUFFIX})
SET(PIPE_NAME qtermy${DEBUG_SUFFIX}-pipe)
SET(SYSTEMD_SETUP_NAME ${ABBREV_NAME}-systemd-setup${DEBUG_SUFFIX})
SET(ICONTOOL_NAME "IconBlaster")
# Server runtime directories
SET(SERVER_XDG_DIR "%t/${SERVER_NAME}")
SET(SERVER_RUN_DIR "/run/user/%U/${SERVER_NAME}")
SET(SERVER_TMP_DIR "/tmp/${SERVER_NAME}%U")
# App runtime directories
SET(APP_XDG_DIR "%t/${APP_NAME}")
SET(APP_RUN_DIR "/run/user/%U/${APP_NAME}")
SET(APP_TMP_DIR "/tmp/${APP_NAME}%U")
# Name of socket file (used both server and app)
SET(SOCKET_FILE /sock)
# Name of pid file: must be shorter than SOCKET_FILE
SET(PID_FILE /pid)
# Documentation root URL
SET(DOCUMENTATION_ROOT "https://${PRODUCT_DOMAIN}/doc"
CACHE STRING "Documentation root URL")
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wimplicit-fallthrough -Wno-sign-compare")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wimplicit-fallthrough -Wno-sign-compare")
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -rdynamic")
INCLUDE(GNUInstallDirs)
MESSAGE(STATUS "Building for ${CMAKE_SYSTEM_NAME} in ${CMAKE_BUILD_TYPE} mode")
MESSAGE(STATUS "PREFIX is ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS "DATADIR is ${CMAKE_INSTALL_FULL_DATADIR}")
MESSAGE(STATUS "SYSCONFDIR is ${CMAKE_INSTALL_FULL_SYSCONFDIR}")
FIND_PACKAGE(PkgConfig REQUIRED)
IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF (USE_SYSTEMD)
FIND_PACKAGE(Systemd 235 REQUIRED)
ENDIF()
IF (USE_FUSE3)
SET(FUSE_VERSION 3.1)
SET(USE_FUSE2 0)
ELSEIF (USE_FUSE2)
SET(FUSE_VERSION 2.9)
ENDIF()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(USE_SYSTEMD 0)
SET(USE_FUSE3 0)
SET(USE_FUSE2 0)
ELSE()
MESSAGE(FATAL_ERROR "Unsupported OS: ${CMAKE_SYSTEM_NAME}")
ENDIF()
SET(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(Uuid 2.30.1 REQUIRED)
FIND_PACKAGE(Utf8cpp REQUIRED)
CONFIGURE_FILE(common.h.in common.h)
INCLUDE_DIRECTORIES(BEFORE . ${PROJECT_BINARY_DIR})
FIND_PROGRAM(GITEXE git DOC "Git VCS")
FIND_FILE(GITDIR NAMES .git PATHS ${CMAKE_SOURCE_DIR} NO_DEFAULT_PATH)
SET(GITINFO ${PROJECT_BINARY_DIR}/gitinfo.h)
IF (GITEXE AND GITDIR)
ADD_CUSTOM_COMMAND(OUTPUT ${GITINFO}
DEPENDS gitinfo.h.in ${CMAKE_SOURCE_DIR}/gitinfo.sh ${GITDIR}/logs/HEAD
COMMAND ${CMAKE_SOURCE_DIR}/gitinfo.sh --head ${GITINFO}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM)
ELSE()
ADD_CUSTOM_COMMAND(OUTPUT ${GITINFO}
DEPENDS gitinfo.h.in ${CMAKE_SOURCE_DIR}/gitinfo.sh
COMMAND ${CMAKE_SOURCE_DIR}/gitinfo.sh --none ${GITINFO}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
VERBATIM)
ENDIF()
ADD_CUSTOM_TARGET(gitinfo DEPENDS ${GITINFO})
# GCC link-time optimization
FUNCTION(LTO_LIBRARY target)
IF (NDEBUG AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
TARGET_COMPILE_OPTIONS(${target} PRIVATE -flto -ffat-lto-objects)
ENDIF()
ENDFUNCTION()
FUNCTION(LTO_EXECUTABLE target)
IF (NDEBUG AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
TARGET_COMPILE_OPTIONS(${target} PRIVATE -flto -fno-fat-lto-objects)
SET_TARGET_PROPERTIES(${target} PROPERTIES LINK_FLAGS "-flto -fuse-linker-plugin")
ENDIF()
ENDFUNCTION()
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_AR "gcc-ar")
SET(CMAKE_RANLIB "gcc-ranlib")
ENDIF()
ADD_SUBDIRECTORY(vendor)
ADD_SUBDIRECTORY(lib)
ADD_SUBDIRECTORY(os)
IF (BUILD_SERVER)
ADD_SUBDIRECTORY(mon)
ADD_SUBDIRECTORY(mux)
ENDIF()
IF (BUILD_QTGUI)
ADD_SUBDIRECTORY(src)
ENDIF()
ADD_SUBDIRECTORY(doc)
IF (MAINTAINER_MODE)
ADD_SUBDIRECTORY(util)
ENDIF()
IF (BUILD_TESTS)
ENABLE_TESTING()
ADD_SUBDIRECTORY(test)
ENDIF()