annotate CMakeLists.txt @ 1109:251976043986

cmake: add systemd service
author David Demelier <markand@malikania.fr>
date Wed, 20 Oct 2021 15:54:07 +0200
parents 02c1b78b9b58
children 8c53096eef1e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 # CMakeLists.txt -- CMake build system for irccd
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 # Copyright (c) 2013-2021 David Demelier <markand@malikania.fr>
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 # Permission to use, copy, modify, and/or distribute this software for any
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 # purpose with or without fee is hereby granted, provided that the above
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 # copyright notice and this permission notice appear in all copies.
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
1107
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
19 #
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
20 # Overview of projects targets
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
21 # ============================
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
22 #
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
23 # Irccd is a host program that loads C native plugins, to do so it exports the
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
24 # public API by its own and plugins must not link to the library code itself.
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
25 # But for unit testing the project we don't want to compile over and over the
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
26 # same files that *must* link against the library code so we split:
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
27 #
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
28 # - libirccd (lib/, static library): contains the public API for C plugins.
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
29 # - irccd-static (irccd/, object code): contains all irccd(1) code *without*
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
30 # the main entry point. This code isn't publicly exposed to the plugins.
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
31 # - irccd (irccd/, executable): contains main and config parser code.
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
32 # - irccdctl (irccdctl, executable): contain irccdctl(1) utility.
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
33 #
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
34
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 cmake_minimum_required(VERSION 2.20)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 cmake_policy(SET CMP0048 NEW)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 project(irccd
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
38 LANGUAGES C
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 DESCRIPTION "IRC Client Daemon"
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 HOMEPAGE_URL "http://projects.malikania.fr/irccd"
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 VERSION 4.0.0
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
43
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 set_property(GLOBAL PROPERTY USE_FOLDERS On)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
45
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
46 set(CMAKE_C_STANDARD 11)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
47 set(CMAKE_C_STANDARD_REQUIRED On)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 set(CMAKE_C_EXTENSIONS Off)
1102
5b9c21b3907a cmake: fix build on UNIX likes
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
49 set(CMAKE_POSITION_INDEPENDENT_CODE On)
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
50
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic ${CMAKE_C_FLAGS}")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
54
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
55 option(IRCCD_WITH_EXAMPLES "Enable example files" On)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 option(IRCCD_WITH_JS "Enable Javascript" On)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 option(IRCCD_WITH_MAN "Enable manual pages" On)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
58 option(IRCCD_WITH_SSL "Enable SSL (requires OpenSSL)" On)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 option(IRCCD_WITH_TESTS "Enable unit tests" On)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
60
1109
251976043986 cmake: add systemd service
David Demelier <markand@malikania.fr>
parents: 1107
diff changeset
61 set(IRCCD_WITH_UID "irccd" CACHE STRING "Default uid to run irccd as")
251976043986 cmake: add systemd service
David Demelier <markand@malikania.fr>
parents: 1107
diff changeset
62 set(IRCCD_WITH_GID "irccd" CACHE STRING "Default gid to run irccd as")
251976043986 cmake: add systemd service
David Demelier <markand@malikania.fr>
parents: 1107
diff changeset
63
1107
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
64 # Check presence of POSIX m library
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
65 find_library(M_LIBRARY m libm)
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
66
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 include(GNUInstallDirs)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
68
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 include(cmake/IrccdDefinePlugin.cmake)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
70
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
71 if (IRCCD_WITH_SSL)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 find_package(OpenSSL REQUIRED)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
74
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
75 if (IRCCD_WITH_JS)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 add_subdirectory(extern/libduktape)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
78
1103
c94ae6941ce0 cmake: fix libm build
David Demelier <markand@malikania.fr>
parents: 1102
diff changeset
79
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
80 add_subdirectory(extern/libutlist)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
81 add_subdirectory(extern/libketopt)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
82
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
83 add_subdirectory(lib)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
84 add_subdirectory(irccd)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
85 add_subdirectory(irccdctl)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
86 add_subdirectory(plugins)
1109
251976043986 cmake: add systemd service
David Demelier <markand@malikania.fr>
parents: 1107
diff changeset
87 add_subdirectory(systemd)
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
88
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
89 if (IRCCD_WITH_EXAMPLES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
90 add_subdirectory(examples)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
91 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
92 if (IRCCD_WITH_MAN)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
93 add_subdirectory(man)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
94 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
95
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
96 if (IRCCD_WITH_TESTS)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
97 enable_testing()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
98 add_subdirectory(extern/libgreatest)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
99 add_subdirectory(tests)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
100 endif ()