Mercurial > irccd
comparison cmake/IrccdSystem.cmake @ 207:6635b9187d71
Irccd: switch to 4 spaces indent, #518
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 21 Jun 2016 20:52:17 +0200 |
parents | c1acfacc46bd |
children | e9adab218027 |
comparison
equal
deleted
inserted
replaced
206:11808e98218f | 207:6635b9187d71 |
---|---|
30 # Recent versions of CMake has nice C++ feature detection for modern | 30 # Recent versions of CMake has nice C++ feature detection for modern |
31 # C++ but they are still a bit buggy so we use this | 31 # C++ but they are still a bit buggy so we use this |
32 # instead. | 32 # instead. |
33 # | 33 # |
34 if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") | 34 if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
35 # | 35 # |
36 # For GCC, we require at least GCC 5.1 | 36 # For GCC, we require at least GCC 5.1 |
37 # | 37 # |
38 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1") | 38 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.1") |
39 message(FATAL_ERROR "You need at least GCC 5.1") | 39 message(FATAL_ERROR "You need at least GCC 5.1") |
40 endif () | 40 endif () |
41 | 41 |
42 set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++14 ${CMAKE_CXX_FLAGS}") | 42 set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++14 ${CMAKE_CXX_FLAGS}") |
43 elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") | 43 elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
44 # | 44 # |
45 # LLVM/clang implemented C++14 starting from version 3.4 but the | 45 # LLVM/clang implemented C++14 starting from version 3.4 but the |
46 # switch -std=c++14 was not available. | 46 # switch -std=c++14 was not available. |
47 # | 47 # |
48 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.4") | 48 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.4") |
49 message(FATAL_ERROR "You need at least Clang 3.4") | 49 message(FATAL_ERROR "You need at least Clang 3.4") |
50 endif () | 50 endif () |
51 | 51 |
52 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5") | 52 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5") |
53 set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++1y ${CMAKE_CXX_FLAGS}") | 53 set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++1y ${CMAKE_CXX_FLAGS}") |
54 else () | 54 else () |
55 set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++14 ${CMAKE_CXX_FLAGS}") | 55 set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++14 ${CMAKE_CXX_FLAGS}") |
56 endif () | 56 endif () |
57 elseif (MSVC14) | 57 elseif (MSVC14) |
58 set(CMAKE_C_FLAGS "/DWIN32_LEAN_AND_MEAN /DNOMINMAX /wd4267 /wd4800 /D_CRT_SECURE_NO_WARNINGS ${CMAKE_C_FLAGS}") | 58 set(CMAKE_C_FLAGS "/DWIN32_LEAN_AND_MEAN /DNOMINMAX /wd4267 /wd4800 /D_CRT_SECURE_NO_WARNINGS ${CMAKE_C_FLAGS}") |
59 set(CMAKE_CXX_FLAGS "/DWIN32_LEAN_AND_MEAN /DNOMINMAX /wd4267 /wd4800 /D_CRT_SECURE_NO_WARNINGS /EHsc ${CMAKE_CXX_FLAGS}") | 59 set(CMAKE_CXX_FLAGS "/DWIN32_LEAN_AND_MEAN /DNOMINMAX /wd4267 /wd4800 /D_CRT_SECURE_NO_WARNINGS /EHsc ${CMAKE_CXX_FLAGS}") |
60 else () | 60 else () |
61 message(WARNING "Unsupported ${CMAKE_CXX_COMPILER_ID}, may not build correctly.") | 61 message(WARNING "Unsupported ${CMAKE_CXX_COMPILER_ID}, may not build correctly.") |
62 endif () | 62 endif () |
63 | 63 |
64 if (MINGW) | 64 if (MINGW) |
65 set(CMAKE_CXX_FLAGS "-D_WIN32_WINNT=0x0600 ${CMAKE_CXX_FLAGS}") | 65 set(CMAKE_CXX_FLAGS "-D_WIN32_WINNT=0x0600 ${CMAKE_CXX_FLAGS}") |
66 endif () | 66 endif () |
67 | 67 |
68 if (CMAKE_SIZEOF_VOID_P MATCHES "8") | 68 if (CMAKE_SIZEOF_VOID_P MATCHES "8") |
69 set(IRCCD_64BITS TRUE) | 69 set(IRCCD_64BITS TRUE) |
70 else () | 70 else () |
71 set(IRCCD_64BITS FALSE) | 71 set(IRCCD_64BITS FALSE) |
72 endif () | 72 endif () |
73 | 73 |
74 set(IRCCD_FAKEROOTDIR ${CMAKE_BINARY_DIR}/fakeroot) | 74 set(IRCCD_FAKEROOTDIR ${CMAKE_BINARY_DIR}/fakeroot) |
75 | 75 |
76 if (NOT EXISTS ${IRCCD_FAKEROOTDIR}) | 76 if (NOT EXISTS ${IRCCD_FAKEROOTDIR}) |
77 file(MAKE_DIRECTORY ${IRCCD_FAKEROOTDIR}) | 77 file(MAKE_DIRECTORY ${IRCCD_FAKEROOTDIR}) |
78 endif () | 78 endif () |
79 | 79 |
80 # --------------------------------------------------------- | 80 # --------------------------------------------------------- |
81 # System identification | 81 # System identification |
82 # --------------------------------------------------------- | 82 # --------------------------------------------------------- |
83 | 83 |
84 if (WIN32) | 84 if (WIN32) |
85 set(IRCCD_SYSTEM_WINDOWS TRUE) | 85 set(IRCCD_SYSTEM_WINDOWS TRUE) |
86 elseif (APPLE) | 86 elseif (APPLE) |
87 set(IRCCD_SYSTEM_MAC TRUE) | 87 set(IRCCD_SYSTEM_MAC TRUE) |
88 elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") | 88 elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") |
89 set(IRCCD_SYSTEM_FREEBSD TRUE) | 89 set(IRCCD_SYSTEM_FREEBSD TRUE) |
90 elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD") | 90 elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD") |
91 set(IRCCD_SYSTEM_NETBSD TRUE) | 91 set(IRCCD_SYSTEM_NETBSD TRUE) |
92 elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") | 92 elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD") |
93 set(IRCCD_SYSTEM_OPENBSD TRUE) | 93 set(IRCCD_SYSTEM_OPENBSD TRUE) |
94 elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") | 94 elseif (CMAKE_SYSTEM_NAME MATCHES "Linux") |
95 set(IRCCD_SYSTEM_LINUX TRUE) | 95 set(IRCCD_SYSTEM_LINUX TRUE) |
96 endif () | 96 endif () |
97 | 97 |
98 # --------------------------------------------------------- | 98 # --------------------------------------------------------- |
99 # Portability requirements | 99 # Portability requirements |
100 # --------------------------------------------------------- | 100 # --------------------------------------------------------- |
107 check_type_size(uint32_t HAVE_UINT32) | 107 check_type_size(uint32_t HAVE_UINT32) |
108 check_type_size(int64_t HAVE_INT64) | 108 check_type_size(int64_t HAVE_INT64) |
109 check_type_size(uint64_t HAVE_UINT64) | 109 check_type_size(uint64_t HAVE_UINT64) |
110 | 110 |
111 if (NOT HAVE_STDINT_H) | 111 if (NOT HAVE_STDINT_H) |
112 message("irccd requires stdint.h or cstdint header") | 112 message("irccd requires stdint.h or cstdint header") |
113 endif () | 113 endif () |
114 | 114 |
115 # | 115 # |
116 # Where any of these function / feature is required, include the <irccd/sysconfig.h> file. | 116 # Where any of these function / feature is required, include the <irccd/sysconfig.h> file. |
117 # | 117 # |
118 # The following variables are defined in irccd/sysconfig.h | 118 # The following variables are defined in irccd/sysconfig.h |
119 # | 119 # |
120 # HAVE_ACCESS - True if has access(2) function (and sys/types.h and sys/stat.h), | 120 # HAVE_ACCESS True if has access(2) function (and sys/types.h and sys/stat.h), |
121 # HAVE_DAEMON - True if daemon(3), | 121 # HAVE_DAEMON True if daemon(3), |
122 # HAVE_GETPID - True if has getpid(2) function (and sys/types.h and unistd.h and grp.h), | 122 # HAVE_GETPID True if has getpid(2) function (and sys/types.h and unistd.h and grp.h), |
123 # HAVE_POPEN - True if has popen(3) function (in stdio.h) | 123 # HAVE_POPEN True if has popen(3) function (in stdio.h) |
124 # HAVE_SETGID - True if has setgid(2) function and getgrnam(3) (and sys/types.h and unistd.h and pwd.h), | 124 # HAVE_SETGID True if has setgid(2) function and getgrnam(3) (and sys/types.h and unistd.h and pwd.h), |
125 # HAVE_SETPROGNAME - True if setprogname(3) is available from C library, | 125 # HAVE_SETPROGNAME True if setprogname(3) is available from C library, |
126 # HAVE_SETUID - True if has setuid(2) function and getpwnam(3) (and sys/types.h and unistd.h and pwd.h), | 126 # HAVE_SETUID True if has setuid(2) function and getpwnam(3) (and sys/types.h and unistd.h and pwd.h), |
127 # HAVE_STAT - True if has stat(2) function (and sys/types.h and sys/stat.h), | 127 # HAVE_STAT True if has stat(2) function (and sys/types.h and sys/stat.h), |
128 # HAVE_STAT_ST_DEV - The struct stat has st_dev field, | 128 # HAVE_STAT_ST_DEV The struct stat has st_dev field, |
129 # HAVE_STAT_ST_INO - The struct stat has st_ino field, | 129 # HAVE_STAT_ST_INO The struct stat has st_ino field, |
130 # HAVE_STAT_ST_NLINK - The struct stat has st_nlink field, | 130 # HAVE_STAT_ST_NLINK The struct stat has st_nlink field, |
131 # HAVE_STAT_ST_UID - The struct stat has st_uid field, | 131 # HAVE_STAT_ST_UID The struct stat has st_uid field, |
132 # HAVE_STAT_ST_GID - The struct stat has st_gid field, | 132 # HAVE_STAT_ST_GID The struct stat has st_gid field, |
133 # HAVE_STAT_ST_ATIME - The struct stat has st_atime field, | 133 # HAVE_STAT_ST_ATIME The struct stat has st_atime field, |
134 # HAVE_STAT_ST_MTIME - The struct stat has st_mtime field, | 134 # HAVE_STAT_ST_MTIME The struct stat has st_mtime field, |
135 # HAVE_STAT_ST_CTIME - The struct stat has st_ctime field, | 135 # HAVE_STAT_ST_CTIME The struct stat has st_ctime field, |
136 # HAVE_STAT_ST_SIZE - The struct stat has st_size field, | 136 # HAVE_STAT_ST_SIZE The struct stat has st_size field, |
137 # HAVE_STAT_ST_BLKSIZE - The struct stat has st_blksize field, | 137 # HAVE_STAT_ST_BLKSIZE The struct stat has st_blksize field, |
138 # HAVE_STAT_ST_BLOCKS - The struct stat has st_blocks field, | 138 # HAVE_STAT_ST_BLOCKS The struct stat has st_blocks field, |
139 # HAVE_SYSLOG - True if syslog functions are available (and syslog.h), | 139 # HAVE_SYSLOG True if syslog functions are available (and syslog.h), |
140 # | 140 # |
141 | 141 |
142 # Check for unistd.h | 142 # Check for unistd.h |
143 check_include_file(unistd.h HAVE_UNISTD_H) | 143 check_include_file(unistd.h HAVE_UNISTD_H) |
144 | 144 |
161 # | 161 # |
162 # #include <unistd.h> | 162 # #include <unistd.h> |
163 check_function_exists(access HAVE_ACCESS) | 163 check_function_exists(access HAVE_ACCESS) |
164 | 164 |
165 if (NOT HAVE_UNISTD_H) | 165 if (NOT HAVE_UNISTD_H) |
166 set(HAVE_ACCESS FALSE) | 166 set(HAVE_ACCESS FALSE) |
167 endif () | 167 endif () |
168 | 168 |
169 # getpid() function | 169 # getpid() function |
170 # | 170 # |
171 # If HAVE_GETPID is defined, include: | 171 # If HAVE_GETPID is defined, include: |
173 # #include <sys/types.h> | 173 # #include <sys/types.h> |
174 # #include <unistd.h> | 174 # #include <unistd.h> |
175 check_function_exists(getpid HAVE_GETPID) | 175 check_function_exists(getpid HAVE_GETPID) |
176 | 176 |
177 if (NOT HAVE_UNISTD_H OR NOT HAVE_SYS_TYPES_H) | 177 if (NOT HAVE_UNISTD_H OR NOT HAVE_SYS_TYPES_H) |
178 set(HAVE_GETPID FALSE) | 178 set(HAVE_GETPID FALSE) |
179 endif () | 179 endif () |
180 | 180 |
181 # setgid() function (and getgrnam) | 181 # setgid() function (and getgrnam) |
182 # | 182 # |
183 # If HAVE_SETGID is defined, include: | 183 # If HAVE_SETGID is defined, include: |
184 # | 184 # |
185 # #include <sys/types.h> | 185 # #include <sys/types.h> |
186 # #include <unistd.h> | 186 # #include <unistd.h> |
187 # #include <grp.h> // only for getgrnam | 187 # #include <grp.h> // only for getgrnam |
188 check_include_file(grp.h HAVE_GRP_H) | 188 check_include_file(grp.h HAVE_GRP_H) |
189 check_function_exists(getgrnam HAVE_GETGRNAM) | 189 check_function_exists(getgrnam HAVE_GETGRNAM) |
190 check_function_exists(setgid HAVE_SETGID) | 190 check_function_exists(setgid HAVE_SETGID) |
191 | 191 |
192 if (NOT HAVE_UNISTD_H OR NOT HAVE_SYS_TYPES_H OR NOT HAVE_GETGRNAM OR NOT HAVE_GRP_H) | 192 if (NOT HAVE_UNISTD_H OR NOT HAVE_SYS_TYPES_H OR NOT HAVE_GETGRNAM OR NOT HAVE_GRP_H) |
193 set(HAVE_SETGID FALSE) | 193 set(HAVE_SETGID FALSE) |
194 endif () | 194 endif () |
195 | 195 |
196 # popen() function | 196 # popen() function |
197 # | 197 # |
198 # If HAVE_POPEN is defined, include; | 198 # If HAVE_POPEN is defined, include; |
204 # | 204 # |
205 # If HAVE_SETUID is defined, include: | 205 # If HAVE_SETUID is defined, include: |
206 # | 206 # |
207 # #include <sys/types.h> | 207 # #include <sys/types.h> |
208 # #include <unistd.h> | 208 # #include <unistd.h> |
209 # #include <pwd.h> // only for getpwnam | 209 # #include <pwd.h> // only for getpwnam |
210 check_include_file(pwd.h HAVE_PWD_H) | 210 check_include_file(pwd.h HAVE_PWD_H) |
211 check_function_exists(getpwnam HAVE_GETPWNAM) | 211 check_function_exists(getpwnam HAVE_GETPWNAM) |
212 check_function_exists(setuid HAVE_SETUID) | 212 check_function_exists(setuid HAVE_SETUID) |
213 | 213 |
214 if (NOT HAVE_UNISTD_H OR NOT HAVE_SYS_TYPES_H OR NOT HAVE_GETPWNAM OR NOT HAVE_PWD_H) | 214 if (NOT HAVE_UNISTD_H OR NOT HAVE_SYS_TYPES_H OR NOT HAVE_GETPWNAM OR NOT HAVE_PWD_H) |
215 set(HAVE_SETUID FALSE) | 215 set(HAVE_SETUID FALSE) |
216 endif () | 216 endif () |
217 | 217 |
218 # stat(2) function | 218 # stat(2) function |
219 # | 219 # |
220 # If HAVE_STAT is defined, include: | 220 # If HAVE_STAT is defined, include: |
224 check_include_file(sys/stat.h HAVE_SYS_STAT_H) | 224 check_include_file(sys/stat.h HAVE_SYS_STAT_H) |
225 check_function_exists(stat HAVE_STAT) | 225 check_function_exists(stat HAVE_STAT) |
226 | 226 |
227 # If the sys/stat.h is not found, we disable stat(2) | 227 # If the sys/stat.h is not found, we disable stat(2) |
228 if (NOT HAVE_SYS_STAT_H OR NOT HAVE_SYS_TYPES_H) | 228 if (NOT HAVE_SYS_STAT_H OR NOT HAVE_SYS_TYPES_H) |
229 set(HAVE_STAT FALSE) | 229 set(HAVE_STAT FALSE) |
230 endif () | 230 endif () |
231 | 231 |
232 # syslog functions | 232 # syslog functions |
233 # | 233 # |
234 # If HAVE_SYSLOG is defined, include: | 234 # If HAVE_SYSLOG is defined, include: |
238 check_function_exists(openlog HAVE_OPENLOG) | 238 check_function_exists(openlog HAVE_OPENLOG) |
239 check_function_exists(syslog HAVE_SYSLOG) | 239 check_function_exists(syslog HAVE_SYSLOG) |
240 check_function_exists(closelog HAVE_CLOSELOG) | 240 check_function_exists(closelog HAVE_CLOSELOG) |
241 | 241 |
242 if (NOT HAVE_SYSLOG_H OR NOT HAVE_OPENLOG OR NOT HAVE_CLOSELOG) | 242 if (NOT HAVE_SYSLOG_H OR NOT HAVE_OPENLOG OR NOT HAVE_CLOSELOG) |
243 set(HAVE_SYSLOG FALSE) | 243 set(HAVE_SYSLOG FALSE) |
244 endif () | 244 endif () |
245 | 245 |
246 # Check for struct stat fields. | 246 # Check for struct stat fields. |
247 check_struct_has_member("struct stat" st_atime sys/stat.h HAVE_STAT_ST_ATIME) | 247 check_struct_has_member("struct stat" st_atime sys/stat.h HAVE_STAT_ST_ATIME) |
248 check_struct_has_member("struct stat" st_blksize sys/stat.h HAVE_STAT_ST_BLKSIZE) | 248 check_struct_has_member("struct stat" st_blksize sys/stat.h HAVE_STAT_ST_BLKSIZE) |
258 check_struct_has_member("struct stat" st_size sys/stat.h HAVE_STAT_ST_SIZE) | 258 check_struct_has_member("struct stat" st_size sys/stat.h HAVE_STAT_ST_SIZE) |
259 check_struct_has_member("struct stat" st_uid sys/stat.h HAVE_STAT_ST_UID) | 259 check_struct_has_member("struct stat" st_uid sys/stat.h HAVE_STAT_ST_UID) |
260 | 260 |
261 # Configuration file. | 261 # Configuration file. |
262 configure_file( | 262 configure_file( |
263 ${CMAKE_CURRENT_LIST_DIR}/internal/sysconfig.hpp.in | 263 ${CMAKE_CURRENT_LIST_DIR}/internal/sysconfig.hpp.in |
264 ${IRCCD_FAKEROOTDIR}/include/irccd/sysconfig.hpp | 264 ${IRCCD_FAKEROOTDIR}/include/irccd/sysconfig.hpp |
265 ) | 265 ) |