Mercurial > irccd
annotate CMakeLists.txt @ 1127:e932bb946f73
cmake: set extensions
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 05 Dec 2021 12:14:41 +0100 |
parents | 75e228008e07 |
children | f06e9761cc90 |
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) |
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 | 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 |
1109
251976043986
cmake: add systemd service
David Demelier <markand@malikania.fr>
parents:
1107
diff
changeset
|
65 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
|
66 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
|
67 set(IRCCD_WITH_PKGCONFIGDIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" |
8c53096eef1e
cmake: add pkg-config file support
David Demelier <markand@malikania.fr>
parents:
1109
diff
changeset
|
68 CACHE STRING "Directory for pkg-config files") |
1109
251976043986
cmake: add systemd service
David Demelier <markand@malikania.fr>
parents:
1107
diff
changeset
|
69 |
1107
02c1b78b9b58
cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents:
1103
diff
changeset
|
70 # Check presence of POSIX m library |
02c1b78b9b58
cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents:
1103
diff
changeset
|
71 find_library(M_LIBRARY m libm) |
02c1b78b9b58
cmake: rename some targets and explain
David Demelier <markand@malikania.fr>
parents:
1103
diff
changeset
|
72 |
1098
6c15d37b7518
cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
73 include(cmake/IrccdDefinePlugin.cmake) |
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_SSL) |
6c15d37b7518
cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
76 find_package(OpenSSL REQUIRED) |
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 |
6c15d37b7518
cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
79 if (IRCCD_WITH_JS) |
6c15d37b7518
cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
80 add_subdirectory(extern/libduktape) |
6c15d37b7518
cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
81 endif () |
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(extern/libutlist) |
6c15d37b7518
cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff
changeset
|
84 add_subdirectory(extern/libketopt) |
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 | 104 |
105 # CMake packages. | |
106 write_basic_package_version_file( | |
107 ${PROJECT_BINARY_DIR}/irccd-config-version.cmake | |
108 VERSION ${PROJECT_VERSION} | |
109 COMPATIBILITY SameMajorVersion | |
110 ) | |
111 | |
112 configure_file( | |
113 ${PROJECT_SOURCE_DIR}/cmake/irccd-config.cmake.in | |
114 ${PROJECT_BINARY_DIR}/irccd-config.cmake | |
115 @ONLY | |
116 ) | |
117 | |
118 install( | |
119 FILES | |
120 ${PROJECT_BINARY_DIR}/irccd-config.cmake | |
121 ${PROJECT_BINARY_DIR}/irccd-config-version.cmake | |
122 ${PROJECT_SOURCE_DIR}/cmake/IrccdDefinePlugin.cmake | |
123 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/irccd | |
124 ) |