0

Hi I have a similar question partially discussed in How to include library and header files from another one of my projects?

my project has the following structures

mainProj/
         meson.build
         src/ 
               lib1/
                   include/
                   src/
                   meson.build
               lib2/
                   include/
                   src/
                   meson.build
               lib3/
                   include/
                   src/
                   meson.build
               libNomeson1/
                   include/
                   src/
               progMain
                   include/
                   src/
                      ...
                      main.c
                   meson.build
               build/

the proj structures can't be changed and the lib# projects belongs to different teams,

now progMain proj needs to pickup headers from the lib#, and also can happen that lib1 needs to pick up header from lib3....

in the meson.build of progMain proj I have declared headers included:

public_headers = include_directories('../',
                                    'inc',
                                     )

when I go to configure I got the warning

|progMain| WARNING: include_directories sandbox violation!
The project is trying to access the directory ../ which belongs to a different
subproject. This is a problem as it hardcodes the relative paths of these two projeccts.
This makes it impossible to compile the project in any other directory layout and also
prevents the subproject from changing its own directory layout.

Instead of poking directly at the internals the subproject should be executed and
it should set a variable that the caller can then use. Something like:

# In subproject
some_dep = declare_depencency(include_directories: include_directories('include'))

# In parent project
some_dep = depencency('some')
executable(..., dependencies: [some_dep])

This warning will become a hard error in a future Meson release.

but the suggestion does not fit my project layout

Mariano
  • 240
  • 3
  • 15
  • Why are you using subproject here? Subproject is meant to handle cases of vendoring one project inside another, like if you need zlib, you can vendor that in $root/subprojects. I would expect in your case that you would use `subdir()`, which does not have a sandbox, because the various libs are all part of the same project. – dcbaker Dec 07 '21 at 05:29
  • Hi , I use sunproject because most of the lib used are itself standalone project handled by other teams that can be used also by other "mainProj"s – Mariano Dec 10 '21 at 08:31
  • More over in addition to the lib# handled with meson I can have other libNomeson# from witch I need to pickup include files. – Mariano Dec 10 '21 at 08:36
  • If you're using subprojects, you need to grab either a `declare_dependency` object or an `include_directories` using `subproject.get_variable()` – dcbaker Dec 11 '21 at 06:12
  • Hi @dcbaker if I well understood yous suggestion: e.g. in meson.build of lib1 i add lib1_dep = dependency(include_directories: include_directories('include')) in proMain meson.build lib1_inc dep_dep = lib1.get_variable('lib1_inc_dep') and so on for the other lib with a meson.build file isn't it? but woe to solve the problem for the non meson lib as libNomeson1? – Mariano Feb 09 '22 at 08:20

0 Answers0