|
| 1 | +# SPDX-FileCopyrightText: Corentin Noël <[email protected]> |
| 2 | +# SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 |
| 3 | +project( |
| 4 | + 'libical', |
| 5 | + 'c', |
| 6 | + version: '3.99.99', |
| 7 | + license: 'MPL-2.0 OR LGPL-2.1-only', |
| 8 | + license_files: 'LICENSE.txt', |
| 9 | + meson_version: '>=1.1', |
| 10 | +) |
| 11 | + |
| 12 | +lib_major_soversion = '4' |
| 13 | +lib_soversion_string = '@[email protected]'.format(lib_major_soversion) |
| 14 | +project_version = '4.0' |
| 15 | +project_url = 'https://libical.github.io/libical/' |
| 16 | + |
| 17 | +languages = ['c'] |
| 18 | +cxx_bindings_enabled = add_languages('cpp', native: false, required: get_option('cxx_bindings')) |
| 19 | +if cxx_bindings_enabled |
| 20 | + languages += 'cpp' |
| 21 | +endif |
| 22 | + |
| 23 | +pkg = import('pkgconfig') |
| 24 | +cc = meson.get_compiler('c') |
| 25 | + |
| 26 | +icu_uc_dep = dependency('icu-uc', required: false) |
| 27 | +icu_i18n_dep = dependency('icu-i18n', required: false) |
| 28 | +if (icu_uc_dep.found()) |
| 29 | + icu_binary_dir = icu_uc_dep.get_variable('exec_prefix', default_value: get_option('prefix')) / 'sbin' |
| 30 | +endif |
| 31 | + |
| 32 | + |
| 33 | +# Config checks |
| 34 | +config_data = configuration_data() |
| 35 | +config_data.set('CMAKE_PROJECT_HOMEPAGE_URL', project_url) |
| 36 | +config_data.set('CMAKE_PROJECT_NAME', meson.project_name()) |
| 37 | +config_data.set('PROJECT_VERSION', project_version) |
| 38 | +config_data.set('CMAKE_PROJECT_VERSION_MAJOR', meson.project_version().split('.')[0]) |
| 39 | +config_data.set('CMAKE_PROJECT_VERSION_MINOR', meson.project_version().split('.')[1]) |
| 40 | +config_data.set('CMAKE_PROJECT_VERSION_PATCH', meson.project_version().split('.')[2]) |
| 41 | + |
| 42 | +config_data.set10('HAVE_BYTESWAP_H', cc.has_header('byteswap.h')) |
| 43 | +config_data.set10('HAVE_DIRENT_H', cc.has_header('dirent.h')) |
| 44 | +config_data.set10('HAVE_ENDIAN_H', cc.has_header('endian.h')) |
| 45 | +config_data.set10('HAVE_INTTYPES_H', cc.has_header('inttypes.h')) |
| 46 | +config_data.set10('HAVE_PTHREAD_H', cc.has_header('pthread.h')) |
| 47 | +config_data.set10('HAVE_SYS_ENDIAN_H', cc.has_header('sys/endian.h')) |
| 48 | +config_data.set10('HAVE_SYS_PARAM_H', cc.has_header('sys/param.h')) |
| 49 | +config_data.set10('HAVE_SYS_UTSNAME_H', cc.has_header('sys/utsname.h')) |
| 50 | +config_data.set10('HAVE_FCNTL_H', cc.has_header('fcntl.h')) |
| 51 | +config_data.set10('HAVE_UNISTD_H', cc.has_header('unistd.h')) |
| 52 | +config_data.set10('HAVE_WCTYPE_H', cc.has_header('wctype.h')) |
| 53 | +config_data.set10('HAVE_STDBOOL_H', cc.has_header('stdbool.h')) |
| 54 | + |
| 55 | +if target_machine.system() == 'windows' and cc.get_id() == 'msvc' |
| 56 | + config_data.set10('HAVE__ACCESS', cc.has_function('_access', prefix: '#include <io.h>')) |
| 57 | + config_data.set10('HAVE__GETPID', cc.has_function('_getpid', prefix: '#include <process.h>')) |
| 58 | + config_data.set10('HAVE__MKDIR', cc.has_function('_mkdir', prefix: '#include <direct.h>')) |
| 59 | + config_data.set10('HAVE__OPEN', cc.has_function('_open', prefix: '#include <io.h>')) |
| 60 | + config_data.set10('HAVE__SNPRINTF', cc.has_function('_snprintf', prefix: '#include <stdio.h>')) |
| 61 | + config_data.set10('HAVE__STAT', cc.has_function('_stat', prefix: '#include <sys/types.h>\n#include <sys/stat.h>')) |
| 62 | + config_data.set10( |
| 63 | + 'HAVE__FSTAT64', |
| 64 | + cc.has_function('_fstat64', prefix: '#include <sys/types.h>\n#include <sys/stat.h>'), |
| 65 | + ) |
| 66 | + config_data.set10('HAVE__STRDUP', cc.has_function('_strdup', prefix: '#include <string.h>')) |
| 67 | + config_data.set10('HAVE__STRICMP', cc.has_function('_stricmp', prefix: '#include <string.h>')) |
| 68 | + config_data.set10('HAVE__STRNICMP', cc.has_function('_strnicmp', prefix: '#include <string.h>')) |
| 69 | + config_data.set10('HAVE__READ', cc.has_function('_read', prefix: '#include <io.h>')) |
| 70 | + config_data.set10('HAVE__WRITE', cc.has_function('_write', prefix: '#include <io.h>')) |
| 71 | +else |
| 72 | + config_data.set10('HAVE_ACCESS', cc.has_function('access', prefix: '#include <unistd.h>')) |
| 73 | + config_data.set10('HAVE_FORK', cc.has_function('fork', prefix: '#include <unistd.h>')) |
| 74 | + config_data.set10('HAVE_GETOPT', cc.has_function('getopt', prefix: '#include <unistd.h>')) |
| 75 | + config_data.set10('HAVE_GETPID', cc.has_function('getpid', prefix: '#include <unistd.h>')) |
| 76 | + config_data.set10('HAVE_GETPWENT', cc.has_function('getpwent', prefix: '#include <sys/types.h>\n#include <pwd.h>')) |
| 77 | + config_data.set10('HAVE_GMTIME_R', cc.has_function('gmtime_r', prefix: '#include <time.h>')) |
| 78 | + config_data.set10('HAVE_LOCALTIME_R', cc.has_function('localtime_r', prefix: '#include <time.h>')) |
| 79 | + config_data.set10('HAVE_MKDIR', cc.has_function('mkdir', prefix: '#include <sys/stat.h>\n#include <sys/types.h>')) |
| 80 | + config_data.set10( |
| 81 | + 'HAVE_OPEN', |
| 82 | + cc.has_function('open', prefix: '#include <sys/stat.h>\n#include <sys/types.h>\n#include <fcntl.h>'), |
| 83 | + ) |
| 84 | + config_data.set10('HAVE_NANOSLEEP', cc.has_function('nanosleep', prefix: '#include <time.h>')) |
| 85 | + config_data.set10('HAVE_SIGNAL', cc.has_function('signal', prefix: '#include <signal.h>')) |
| 86 | + config_data.set10( |
| 87 | + 'HAVE_STAT', |
| 88 | + cc.has_function('stat', prefix: '#include <sys/stat.h>\n#include <sys/types.h>\n#include <unistd.h>'), |
| 89 | + ) |
| 90 | + config_data.set10( |
| 91 | + 'HAVE_FSTAT', |
| 92 | + cc.has_function('fstat', prefix: '#include <sys/stat.h>\n#include <sys/types.h>\n#include <unistd.h>'), |
| 93 | + ) |
| 94 | + config_data.set10('HAVE_STRDUP', cc.has_function('strdup', prefix: '#include <string.h>')) |
| 95 | + config_data.set10('HAVE_STRCASECMP', cc.has_function('strcasecmp', prefix: '#include <strings.h>')) |
| 96 | + config_data.set10('HAVE_STRNCASECMP', cc.has_function('strncasecmp', prefix: '#include <strings.h>')) |
| 97 | + config_data.set10('HAVE_READ', cc.has_function('read', prefix: '#include <unistd.h>')) |
| 98 | + config_data.set10('HAVE_UNLINK', cc.has_function('unlink', prefix: '#include <unistd.h>')) |
| 99 | + config_data.set10('HAVE_USLEEP', cc.has_function('usleep', prefix: '#include <unistd.h>')) |
| 100 | + config_data.set10('HAVE_WAITPID', cc.has_function('waitpid', prefix: '#include <sys/types.h>\n#include <sys/wait.h>')) |
| 101 | + config_data.set10('HAVE_WRITE', cc.has_function('write', prefix: '#include <unistd.h>')) |
| 102 | + config_data.set10('HAVE_ALARM', cc.has_function('alarm', prefix: '#include <unistd.h>')) |
| 103 | +endif |
| 104 | + |
| 105 | +config_data.set10('HAVE_BACKTRACE', cc.has_function('backtrace', prefix: '#include <execinfo.h>')) |
| 106 | +config_data.set10('HAVE_ISWSPACE', cc.has_function('iswspace', prefix: '#include <wctype.h>')) |
| 107 | +config_data.set10('HAVE_SETENV', cc.has_function('setenv', prefix: '#include <stdlib.h>')) |
| 108 | +config_data.set10('HAVE_UNSETENV', cc.has_function('unsetenv', prefix: '#include <stdlib.h>')) |
| 109 | +config_data.set10('HAVE_SNPRINTF', cc.has_function('snprintf', prefix: '#include <stdio.h>')) |
| 110 | + |
| 111 | +types = { |
| 112 | + 'intptr_t': '#include <stdint.h>', |
| 113 | + 'pid_t': '#include <sys/types.h>', |
| 114 | + 'size_t': '#include <stddef.h>', |
| 115 | + 'ssize_t': '#include <sys/types.h>', |
| 116 | + 'time_t': '#include <time.h>', |
| 117 | + '__time64_t': '#include <time.h>', |
| 118 | + 'wint_t': '#include <wctype.h>', |
| 119 | +} |
| 120 | + |
| 121 | +foreach type, prefix : types |
| 122 | + type_size = cc.sizeof(type, prefix: prefix) |
| 123 | + if type_size > 0 |
| 124 | + upper_type = type.to_upper() |
| 125 | + config_data.set10('HAVE_SIZEOF_@0@'.format(upper_type), true) |
| 126 | + config_data.set('SIZEOF_@0@'.format(upper_type), type_size) |
| 127 | + endif |
| 128 | +endforeach |
| 129 | + |
| 130 | +if get_option('64bit_icaltime_t') |
| 131 | + if config_data.has('HAS_SIZEOF___TIME64_T') |
| 132 | + config_data.set('ICAL_ICALTIME_T_TYPE', '__time64_t') |
| 133 | + else |
| 134 | + error( |
| 135 | + 'Option LIBICAL_ENABLE_64BIT_ICALTIME_T is not supported for this compiler or architecture since the __time64_t type is not available.', |
| 136 | + ) |
| 137 | + endif |
| 138 | +else |
| 139 | + if config_data.get('SIZEOF_TIME_T') == 4 |
| 140 | + warning( |
| 141 | + 'The 32-bit time_t type has been detected. Consider reconfiguring with -D64bit_icaltime_t=true to enable 64-bit time_t types.', |
| 142 | + ) |
| 143 | + endif |
| 144 | + config_data.set('ICAL_ICALTIME_T_TYPE', 'time_t') |
| 145 | +endif |
| 146 | + |
| 147 | +thread_dep = dependency('threads') |
| 148 | +config_data.set10( |
| 149 | + 'HAVE_PTHREAD_ATTR_GET_NP', |
| 150 | + cc.has_function('pthread_attr_get_np', dependencies: thread_dep, prefix: '#define _GNU_SOURCE\n#include <pthread.h>'), |
| 151 | +) |
| 152 | +config_data.set10( |
| 153 | + 'HAVE_PTHREAD_GETATTR_NP', |
| 154 | + cc.has_function('pthread_getattr_np', dependencies: thread_dep, prefix: '#define _GNU_SOURCE\n#include <pthread.h>'), |
| 155 | +) |
| 156 | +config_data.set10( |
| 157 | + 'HAVE_PTHREAD_CREATE', |
| 158 | + cc.has_function('pthread_create', dependencies: thread_dep, prefix: '#include <pthread.h>'), |
| 159 | +) |
| 160 | +config_data.set10('HAVE_PTHREAD_H', cc.has_header('pthread_np.h', dependencies: thread_dep)) |
| 161 | + |
| 162 | +config_data.set10('ICAL_ALLOW_EMPTY_PROPERTIES', get_option('allow_empty_properties')) |
| 163 | +config_data.set10('ICAL_ERRORS_ARE_FATAL', get_option('errors_are_fatal')) |
| 164 | + |
| 165 | +config_h = configure_file(input: 'config.h.cmake', output: 'config.h', format: 'cmake', configuration: config_data) |
| 166 | + |
| 167 | +config_dep = declare_dependency( |
| 168 | + include_directories: include_directories('.'), |
| 169 | + compile_args: '-DHAVE_CONFIG_H=1', |
| 170 | + sources: config_h, |
| 171 | +) |
| 172 | + |
| 173 | +perl_bin = find_program('perl', native: true) |
| 174 | + |
| 175 | +add_project_arguments( |
| 176 | + '-DICAL_ALLOW_EMPTY_PROPERTIES=@0@'.format(get_option('errors_are_fatal').to_int()), |
| 177 | + language: languages, |
| 178 | +) |
| 179 | +add_project_arguments('-DICAL_ERRORS_ARE_FATAL=@0@'.format(get_option('errors_are_fatal').to_int()), language: languages) |
| 180 | + |
| 181 | +package_data_dir = get_option('prefix') / get_option('datadir') / 'libical' |
| 182 | +add_project_arguments('-DPACKAGE_DATA_DIR="@0@"'.format(package_data_dir), language: languages) |
| 183 | + |
| 184 | +subdir('design-data') |
| 185 | +subdir('scripts') |
| 186 | +subdir('src') |
0 commit comments