-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
162 lines (137 loc) · 4.86 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
161
162
# CMakeLists for the Limba Project
project(limba)
cmake_minimum_required(VERSION 2.8.6 FATAL_ERROR)
set(CMAKE_BUILD_TYPE "Debug")
# Detect Git revision (if present)
if(VERSION_SUFFIX MATCHES "-dev")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
find_package(Git)
if(GIT_EXECUTABLE)
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE project_revision RESULT_VARIABLE check_fail)
string(REGEX REPLACE "\n" "" project_revision ${project_revision})
if(check_fail)
message(STATUS "Could not fetch current Git revision: ${check_fail}")
else()
message(STATUS "Found Git revision: ${project_revision}")
set(VERSION_SUFFIX "${VERSION_SUFFIX}:${project_revision}")
endif(check_fail)
endif(GIT_EXECUTABLE)
endif()
endif()
set(LIMBA_VERSION_MAJOR "0")
set(LIMBA_VERSION_MINOR "6")
set(LIMBA_VERSION_PATCH "0")
set(LIMBA_VERSION "${LIMBA_VERSION_MAJOR}.${LIMBA_VERSION_MINOR}.${LIMBA_VERSION_PATCH}")
set(LIMBA_API_LEVEL "0")
# Forbid in-tree building
if(${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
message(STATUS "Please do an out-of-tree build:")
message(STATUS "rm -f CMakeCache.txt && mkdir build && cd build; cmake .. && make")
message(FATAL_ERROR "In-tree-build detected!")
endif(${CMAKE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
#
# Options
#
option(MAINTAINER "Enable maintainer mode" OFF)
option(LICOMPILE "Build and install the LiCompile facilities" OFF)
option(L10N "Enable localization" ON)
option(INSTALL_SUID "Install runapp with suid bit set" ON)
option(DOCUMENTATION "Build documentation" OFF)
#
# Default paths
#
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"/usr" CACHE PATH "Default install prefix" FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Special case for /etc and /var when prefix is /usr
if(${CMAKE_INSTALL_PREFIX} STREQUAL "/usr")
set(CMAKE_INSTALL_SYSCONFDIR "/etc" CACHE PATH "read-only single-machine data (etc)")
set(CMAKE_INSTALL_LOCALSTATEDIR "/var" CACHE PATH "modifiable single-machine data (var)")
endif(${CMAKE_INSTALL_PREFIX} STREQUAL "/usr")
include(GNUInstallDirs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/data/cmake/)
message(STATUS "Compiling Limba version ${LIMBA_VERSION}")
configure_file("${CMAKE_SOURCE_DIR}/data/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
)
#
# External dependencies
#
find_package(Gettext REQUIRED)
find_package(GLIB 2.44 REQUIRED COMPONENTS "gio" "gobject" "gio-unix")
pkg_check_modules(APPSTREAM REQUIRED appstream>=0.10)
pkg_check_modules(UUID REQUIRED uuid>=2.0)
pkg_check_modules (POLKIT REQUIRED polkit-gobject-1>=0.104)
pkg_check_modules(LIBCAP REQUIRED libcap>=2.24)
find_package(GI REQUIRED)
find_package(LibArchive REQUIRED)
find_package(GPGMe REQUIRED)
find_package(CURL REQUIRED)
find_library(M_LIB m)
# we want to use systemd, if possible
include(${CMAKE_SOURCE_DIR}/data/cmake/systemdservice.cmake)
# perform some basic checks on the kernel.
# very old kernels are a problem, so warn about it (but don't fail the build)
execute_process(
COMMAND uname -r
OUTPUT_VARIABLE KERNEL_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND uname -o
OUTPUT_VARIABLE OS_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (KERNEL_RELEASE VERSION_LESS 4.0)
message(WARNING "Kernel is too old. Limba might not work properly with it (needs at least OverlayFS from Linux 4.0).")
endif()
message(STATUS "Found ${OS_NAME} ${KERNEL_RELEASE}")
#
# Configure files
#
set (GETTEXT_PACKAGE "limba")
set (VERSION "${LIMBA_VERSION}")
set (BUILDDIR "${CMAKE_BINARY_DIR}")
set (SOFTWARE_ROOT_PREFIX "/app")
set (SOFTWARE_INSTALL_ROOT "/opt/software")
configure_file(config.h.in ${CMAKE_BINARY_DIR}/config.h)
#
# Enable testing
#
enable_testing()
#
# Custom C flags
#
set(MAINTAINER_CFLAGS "")
if(MAINTAINER)
set(MAINTAINER_CFLAGS "-Werror -Wall -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Winit-self")
if (CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9)
set(MAINTAINER_CFLAGS ${MAINTAINER_CFLAGS} "-fdiagnostics-color=auto")
endif()
endif()
endif(MAINTAINER)
add_definitions(${MAINTAINER_CFLAGS})
# enable C11 (Clang wants this)
set(CMAKE_C_STANDARD "11")
# Required if GPGme was compiled with _FILE_OFFSET_BITS=64
add_definitions("-D_FILE_OFFSET_BITS=64")
#
find_package(PkgConfig REQUIRED)
add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(data)
add_subdirectory(docs)
add_subdirectory(tests)
if (GETTEXT_FOUND AND L10N)
add_subdirectory(po)
endif (GETTEXT_FOUND AND L10N)
add_subdirectory(contrib)