annotate CMakeLists.txt @ 1150:4c9d2d5d126f

irccd: add CTCP support in Irccd.Server, closes #2532
author David Demelier <markand@malikania.fr>
date Sun, 06 Feb 2022 15:03:59 +0100
parents 323d6d34ec1b
children b6a0d9515c82
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 #
1136
f06e9761cc90 misc: update copyright years
David Demelier <markand@malikania.fr>
parents: 1127
diff changeset
4 # Copyright (c) 2013-2022 David Demelier <markand@malikania.fr>
1098
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)
1127
e932bb946f73 cmake: set extensions
David Demelier <markand@malikania.fr>
parents: 1125
diff changeset
48 set(CMAKE_C_EXTENSIONS On)
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")
1120
2053790d5e9b cmake: remove all feature macros
David Demelier <markand@malikania.fr>
parents: 1116
diff changeset
52 set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic ${CMAKE_C_FLAGS}")
1098
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
1125
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
55 include(CMakePackageConfigHelpers)
1110
8c53096eef1e cmake: add pkg-config file support
David Demelier <markand@malikania.fr>
parents: 1109
diff changeset
56 include(GNUInstallDirs)
8c53096eef1e cmake: add pkg-config file support
David Demelier <markand@malikania.fr>
parents: 1109
diff changeset
57
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
58 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
59 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
60 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
61 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
62 option(IRCCD_WITH_TESTS "Enable unit tests" On)
1110
8c53096eef1e cmake: add pkg-config file support
David Demelier <markand@malikania.fr>
parents: 1109
diff changeset
63 option(IRCCD_WITH_PKGCONFIG "Enable installation of pkg-config file" On)
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
64
1139
2e09e46de490 man: improvements
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
65 set(IRCCD_MAN_DATE "February 3, 2022")
1109
251976043986 cmake: add systemd service
David Demelier <markand@malikania.fr>
parents: 1107
diff changeset
66 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
67 set(IRCCD_WITH_GID "irccd" CACHE STRING "Default gid to run irccd as")
1110
8c53096eef1e cmake: add pkg-config file support
David Demelier <markand@malikania.fr>
parents: 1109
diff changeset
68 set(IRCCD_WITH_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
8c53096eef1e cmake: add pkg-config file support
David Demelier <markand@malikania.fr>
parents: 1109
diff changeset
69 CACHE STRING "Directory for pkg-config files")
1109
251976043986 cmake: add systemd service
David Demelier <markand@malikania.fr>
parents: 1107
diff changeset
70
1107
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
71 # Check presence of POSIX m library
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
72 find_library(M_LIBRARY m libm)
02c1b78b9b58 cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents: 1103
diff changeset
73
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 include(cmake/IrccdDefinePlugin.cmake)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
75
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 if (IRCCD_WITH_SSL)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 find_package(OpenSSL REQUIRED)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
79
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
80 if (IRCCD_WITH_JS)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
81 add_subdirectory(extern/libduktape)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
82 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
83
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
84 add_subdirectory(extern/libutlist)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
85
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
86 add_subdirectory(lib)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
87 add_subdirectory(irccd)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
88 add_subdirectory(irccdctl)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
89 add_subdirectory(plugins)
1109
251976043986 cmake: add systemd service
David Demelier <markand@malikania.fr>
parents: 1107
diff changeset
90 add_subdirectory(systemd)
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
91
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
92 if (IRCCD_WITH_EXAMPLES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
93 add_subdirectory(examples)
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 if (IRCCD_WITH_MAN)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
96 add_subdirectory(man)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
97 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
98
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
99 if (IRCCD_WITH_TESTS)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
100 enable_testing()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
101 add_subdirectory(extern/libgreatest)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
102 add_subdirectory(tests)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
103 endif ()
1125
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
104
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
105 # CMake packages.
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
106 write_basic_package_version_file(
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
107 ${PROJECT_BINARY_DIR}/irccd-config-version.cmake
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
108 VERSION ${PROJECT_VERSION}
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
109 COMPATIBILITY SameMajorVersion
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
110 )
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
111
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
112 configure_file(
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
113 ${PROJECT_SOURCE_DIR}/cmake/irccd-config.cmake.in
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
114 ${PROJECT_BINARY_DIR}/irccd-config.cmake
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
115 @ONLY
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
116 )
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
117
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
118 install(
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
119 FILES
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
120 ${PROJECT_BINARY_DIR}/irccd-config.cmake
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
121 ${PROJECT_BINARY_DIR}/irccd-config-version.cmake
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
122 ${PROJECT_SOURCE_DIR}/cmake/IrccdDefinePlugin.cmake
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
123 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/irccd
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1120
diff changeset
124 )