]> git.tdb.fi Git - ext/sigc++-2.0.git/blob - sigc++/meson.build
Import libsigc++ 2.10.8 sources
[ext/sigc++-2.0.git] / sigc++ / meson.build
1 # sigc++
2
3 # Input: sigcxx_build_dep, sigcxx_pcname, sigcxx_libversion, sigcxx_api_version,
4 #        install_includedir, project_source_root, sigc_res, python3,
5 #        handle_built_files, maintainer_mode, can_add_dist_script
6 # Output: source_h_files, built_h_files, sigcxx_own_dep, built_files_root,
7 #         built_h_file_targets
8
9 source_cc_files = [
10   'connection.cc',
11   'signal_base.cc',
12   'trackable.cc',
13   'functors' / 'slot_base.cc',
14 ]
15
16 sigc_h_files = [
17   'bind.h',
18   'bind_return.h',
19   'connection.h',
20   'reference_wrapper.h',
21   'retype_return.h',
22   'signal_base.h',
23   'slot.h',
24   'trackable.h',
25   'type_traits.h',
26   'visit_each.h',
27 ]
28 adaptors_h_files = [
29   'adaptors' / 'adaptors.h',
30   'adaptors' / 'bound_argument.h',
31 ]
32 functors_h_files = [
33   'functors' / 'functors.h',
34   'functors' / 'slot_base.h',
35 ]
36
37 # .m4 files to build .h files from.
38 sigc_h_m4_files = [
39   'limit_reference.h',
40   'signal.h',
41 ]
42
43 m4_template = files('macros' / 'template.macros.m4')
44 m4_include_dir = meson.current_source_dir() / 'macros'
45
46 source_h_files = sigc_h_files + adaptors_h_files + functors_h_files
47
48 built_h_files = sigc_h_m4_files
49 built_cc_files = []
50
51 # Force meson+ninja to generate source files before anything is compiled.
52 # Compilation must depend on these targets.
53 built_cc_file_targets = []
54 built_h_file_targets = []
55
56 subdir('adaptors')
57 subdir('adaptors/lambda')
58 subdir('functors')
59
60 install_headers('sigc++.h', subdir: sigcxx_pcname / 'sigc++')
61 install_headers(sigc_h_files, subdir: sigcxx_pcname / 'sigc++')
62 install_headers(adaptors_h_files, subdir: sigcxx_pcname / 'sigc++' / 'adaptors')
63 install_headers(functors_h_files, subdir: sigcxx_pcname / 'sigc++' / 'functors')
64
65 untracked_sigcxx = 'untracked' / 'sigc++'
66 src_untracked_sigcxx = project_source_root / untracked_sigcxx
67
68 extra_sigc_cppflags = []
69 extra_sigc_objects = []
70
71 # Make sure we are exporting the symbols from the DLL
72 if is_msvc
73   extra_sigc_cppflags += ['-DSIGC_BUILD', '-D_WINDLL']
74 endif
75
76 # Build the .rc file for Windows builds and link to it
77 if host_machine.system() == 'windows'
78   windows = import('windows')
79   sigc_res = windows.compile_resources(sigc_rc)
80   extra_sigc_objects += sigc_res
81 endif
82
83 if maintainer_mode
84
85   # Maintainer mode. Generate .h and .cc files from .m4 files in macros/ directory.
86   # .h and .cc files are also generated in subdirectories.
87
88   # docs/reference/meson.build needs this.
89   built_files_root = project_build_root
90
91   foreach file : sigc_h_m4_files
92     built_h_file_targets += custom_target(file,
93       input: 'macros' / file + '.m4',
94       output: file,
95       command: [
96         python3, handle_built_files, 'build_from_m4',
97         m4_include_dir,
98         '@INPUT@',
99         '@OUTPUT@',
100       ],
101       depend_files: m4_template,
102       build_by_default: maintainer_mode,
103       install: false,
104     )
105   endforeach
106
107   extra_include_dirs = ['..']
108   sigcxx_library = library('sigc-' + sigcxx_api_version,
109     source_cc_files, built_cc_file_targets, built_h_file_targets,
110     extra_sigc_objects,
111     version: sigcxx_libversion,
112     darwin_versions: darwin_versions,
113     cpp_args: extra_sigc_cppflags,
114     implicit_include_directories: false,
115     include_directories: extra_include_dirs,
116     dependencies: sigcxx_build_dep,
117     install: true,
118   )
119
120   built_h_cc_dir = meson.current_build_dir()
121
122 else # not maintainer_mode
123
124   # Not maintainer mode. Compile built source code files in
125   # project_source_root/untracked/sigc++.
126
127   # docs/reference/meson.build needs this.
128   built_files_root = project_source_root / 'untracked'
129
130   # Two cases:
131   # 1. The source code comes from a tarball, where the built files
132   #    are stored in project_source_root/untracked.
133   #    There are no built files in the build tree.
134   # 2. Files have been built in the build tree. Then maintainer_mode has
135   #    been changed from true to false. Files that are missing or not up to date
136   #    in project_source_root/untracked are copied from the build tree.
137
138   # Try to copy built source code files to the source tree.
139   run_command(
140     python3, handle_built_files, 'copy_built_files',
141     meson.current_build_dir(),
142     src_untracked_sigcxx,
143     built_h_files + built_cc_files,
144     check: true,
145   )
146
147   untracked_built_cc_files = []
148   foreach file : built_cc_files
149     untracked_built_cc_files += '..' / 'untracked' / 'sigc++' / file
150   endforeach
151
152   extra_include_dirs = [ '..', '..' / 'untracked' ]
153   sigcxx_library = library('sigc-' + sigcxx_api_version,
154     source_cc_files, untracked_built_cc_files,
155     extra_sigc_objects,
156     version: sigcxx_libversion,
157     darwin_versions: darwin_versions,
158     cpp_args: extra_sigc_cppflags,
159     implicit_include_directories: false,
160     include_directories: extra_include_dirs,
161     dependencies: sigcxx_build_dep,
162     install: true,
163   )
164
165   built_h_cc_dir = src_untracked_sigcxx
166
167 endif
168
169 # Install built .h files.
170 meson.add_install_script(
171   python3, handle_built_files, 'install_built_h_files',
172   built_h_cc_dir,
173   install_includedir / sigcxx_pcname / 'sigc++', # subdir below {prefix}
174   built_h_files,
175 )
176
177 if can_add_dist_script
178   # Distribute built files.
179   meson.add_dist_script(
180     python3, handle_built_files, 'dist_built_files',
181     built_h_cc_dir,
182     untracked_sigcxx,
183     built_h_files + built_cc_files,
184   )
185 endif
186
187 # This is used when building example programs and test programs.
188 # It's also a part of sigcxx_dep, when libsigc++ is a subproject.
189 sigcxx_own_dep = declare_dependency(
190   sources: built_h_file_targets,
191   link_with: sigcxx_library,
192   include_directories: extra_include_dirs,
193   dependencies: sigcxx_build_dep
194 )