1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
|
# sigc++
# Input: sigcxx_build_dep, sigcxx_pcname, sigcxx_libversion, sigcxx_api_version,
# install_includedir, project_source_root, sigc_res
# Output: source_h_files, built_h_files, sigcxx_dep, built_files_root,
# built_h_file_targets
source_cc_files = [
'connection.cc',
'signal_base.cc',
'trackable.cc',
'functors' / 'slot_base.cc',
]
sigc_h_files = [
'bind.h',
'bind_return.h',
'connection.h',
'reference_wrapper.h',
'retype_return.h',
'signal_base.h',
'slot.h',
'trackable.h',
'type_traits.h',
'visit_each.h',
]
adaptors_h_files = [
'adaptors' / 'adaptors.h',
'adaptors' / 'bound_argument.h',
]
functors_h_files = [
'functors' / 'functors.h',
'functors' / 'slot_base.h',
]
# .m4 files to build .h and .cc files from.
adaptors_lambda_cc_m4_files = [
'lambda.cc',
]
sigc_h_m4_files = [
'limit_reference.h',
'signal.h',
]
adaptors_h_m4_files = [
'adaptor_trait.h',
'bind.h',
'bind_return.h',
'compose.h',
'deduce_result_type.h',
'exception_catch.h',
'hide.h',
'retype.h',
'retype_return.h',
'track_obj.h',
]
adaptors_lambda_h_m4_files = [
'base.h',
'select.h',
]
functors_h_m4_files = [
'functor_trait.h',
'mem_fun.h',
'ptr_fun.h',
'slot.h',
]
source_h_files = sigc_h_files + adaptors_h_files + functors_h_files
built_h_files = sigc_h_m4_files
foreach file : adaptors_h_m4_files
built_h_files += 'adaptors' / file
endforeach
foreach file : adaptors_lambda_h_m4_files
built_h_files += 'adaptors' / 'lambda' / file
endforeach
foreach file : functors_h_m4_files
built_h_files += 'functors' / file
endforeach
built_cc_files = []
foreach file : adaptors_lambda_cc_m4_files
built_cc_files += 'adaptors' / 'lambda' / file
endforeach
install_headers('sigc++.h', subdir: sigcxx_pcname / 'sigc++')
install_headers(sigc_h_files, subdir: sigcxx_pcname / 'sigc++')
install_headers(adaptors_h_files, subdir: sigcxx_pcname / 'sigc++' / 'adaptors')
install_headers(functors_h_files, subdir: sigcxx_pcname / 'sigc++' / 'functors')
untracked_sigcxx = 'untracked' / 'sigc++'
src_untracked_sigcxx = project_source_root / untracked_sigcxx
extra_sigc_cppflags = []
extra_sigc_objects = []
# Make sure we are exporting the symbols from the DLL
if is_msvc
extra_sigc_cppflags += ['-DSIGC_BUILD', '-D_WINDLL']
endif
# Build the .rc file for Windows builds and link to it
if host_machine.system() == 'windows'
windows = import('windows')
sigc_res = windows.compile_resources(sigc_rc)
extra_sigc_objects += sigc_res
endif
if maintainer_mode
# Maintainer mode. Generate .h and .cc files from .m4 files in macros/ directories.
# docs/reference/meson.build needs this.
built_files_root = project_build_root
m4_and_built_files = []
foreach file : adaptors_lambda_cc_m4_files + adaptors_lambda_h_m4_files
m4_and_built_files += [['adaptors' / 'lambda' / 'macros' / file + '.m4',
'adaptors' / 'lambda' / file]]
endforeach
foreach file : sigc_h_m4_files
m4_and_built_files += [['macros' / file + '.m4', file]]
endforeach
foreach file : adaptors_h_m4_files
m4_and_built_files += [['adaptors' / 'macros' / file + '.m4', 'adaptors' / file]]
endforeach
foreach file : functors_h_m4_files
m4_and_built_files += [['functors' / 'macros' / file + '.m4', 'functors' / file]]
endforeach
# Force meson+ninja to generate source files before anything is compiled.
# Compilation must depend on these targets.
built_cc_file_targets = []
built_h_file_targets = []
foreach m4_and_built_file : m4_and_built_files
input_file = m4_and_built_file[0]
output_file = m4_and_built_file[1]
if output_file.endswith('.cc')
stamp_file = output_file.underscorify() + '.cc'
else
stamp_file = output_file.underscorify() + '.stamp'
endif
built_file_target = custom_target(output_file.underscorify(),
input: input_file,
output: stamp_file,
command: [
python3, handle_built_files, 'build_from_m4',
meson.current_source_dir() / 'macros',
'@INPUT@',
meson.current_build_dir() / output_file,
'@OUTPUT@',
],
depend_files: 'macros' / 'template.macros.m4',
build_by_default: maintainer_mode,
install: false,
)
if output_file.endswith('.cc')
built_cc_file_targets += built_file_target
else
built_h_file_targets += built_file_target
endif
endforeach
extra_include_dirs = ['..']
sigcxx_library = library('sigc-' + sigcxx_api_version,
source_cc_files, built_cc_file_targets, built_h_file_targets,
extra_sigc_objects,
version: sigcxx_libversion,
cpp_args: extra_sigc_cppflags,
include_directories: extra_include_dirs,
dependencies: sigcxx_build_dep,
install: true,
)
built_h_cc_dir = meson.current_build_dir()
else # not maintainer_mode
# Not maintainer mode. Compile built source code files in
# project_source_root/untracked/sigc++.
# docs/reference/meson.build needs these.
built_h_file_targets = []
built_files_root = project_source_root / 'untracked'
# Two cases:
# 1. The source code comes from a tarball, where the built files
# are stored in project_source_root/untracked.
# There are no built files in the build tree.
# 2. Files have been built in the build tree. Then maintainer_mode has
# been changed from true to false. Files that are missing or not up to date
# in project_source_root/untracked are copied from the build tree.
# Try to copy built source code files to the source tree.
run_command(
python3, handle_built_files, 'copy_built_files',
meson.current_build_dir(),
src_untracked_sigcxx,
built_h_files + built_cc_files,
)
untracked_built_cc_files = []
foreach file : built_cc_files
untracked_built_cc_files += '..' / 'untracked' / 'sigc++' / file
endforeach
extra_include_dirs = [ '..', '..' / 'untracked' ]
sigcxx_library = library('sigc-' + sigcxx_api_version,
source_cc_files, untracked_built_cc_files,
extra_sigc_objects,
version: sigcxx_libversion,
cpp_args: extra_sigc_cppflags,
include_directories: extra_include_dirs,
dependencies: sigcxx_build_dep,
install: true,
)
built_h_cc_dir = src_untracked_sigcxx
endif
# Install built .h files.
meson.add_install_script(
python3.path(), handle_built_files, 'install_built_h_files',
built_h_cc_dir,
install_includedir / sigcxx_pcname / 'sigc++', # subdir below {prefix}
built_h_files,
)
if not meson.is_subproject()
# Distribute built files.
# (add_dist_script() is not allowed in a subproject)
meson.add_dist_script(
python3.path(), handle_built_files, 'dist_built_files',
built_h_cc_dir,
untracked_sigcxx,
built_h_files + built_cc_files,
)
endif
# This is useful in the main project when libsigc++ is used as a subproject.
# It's also used when building example programs and test programs.
sigcxx_dep = declare_dependency(
sources: built_h_file_targets,
link_with: sigcxx_library,
include_directories: extra_include_dirs,
dependencies: sigcxx_build_dep
)
|