Can anyone help me understand the following: I am writng a header-only library 'foo' with the following structure:
Project_Root
meson.build
include/foo.hpp
foo/meson.build
foo/bar.hpp
Here are the details:
[file: meson.build]
project('foobar', 'cpp',
version: '0.1.0',
default_options: ['cpp_std=c++20']
)
project_headers = []
subdir('include')
install_headers(project_headers, preserve_path: true)
[file: include/meson.build]
project_headers += files('foo.hpp')
subdir('foo')
[file: include/foo/meson.build]
project_headers += files('bar.hpp')
My question is why during installation, both foo.hpp and bar.hpp are installed in the same directory even though subdirectory-structure should remain preserved by using preserve_path: true
?
When using preserve_path
meson extracts the directory from the file name. Here's the code from install_headers()
:
...
if kwargs['preserve_path']:
for file in source_files:
dirname = os.path.dirname(file.fname)
dirs[dirname].append(file)
else:
dirs[''].extend(source_files)
...
In your case the fname
for bar.hpp
will be bar.hpp
so will have no path. The subdirectory is stored by files()
but is held in a different attribute. I cannot comment on why it is implemented in this way. I am not a Meson developer.
The example in the Meson release notes shows the path being included with the file names:
https://mesonbuild.com/Release-notes-for-0-63-0.html#added-preserve_path-arg-to-install_headers