Pietro
Pietro

Reputation: 13220

Meson project: can I have part of the source located elsewhere?

In a Meson project, how can I compile files (i.e. not just headers) located in an directory which is not in my project tree?

E.g.:

MyProj/
   src/
      meson.build
ExternalCode/
   src/
      file1.h
      file1.cpp

include_directories is just for headers...

If I use ".." in the files path, I get this error:

meson.build:10:0: ERROR: Subdir contains ..

Upvotes: 2

Views: 1892

Answers (2)

Mariano
Mariano

Reputation: 270

yes but the external file must be picked up in the following way: e.g.

source =  files(file1.cpp)

put in meson.build inside

ExternalCode/src 

folder

Upvotes: 1

pmod
pmod

Reputation: 11007

If you want to build ExternalCode as a part of your project, then I recommend fetch somehow this directory inside your project, e.g. using symbolic link and place meson.build file alongside. So, your project layout will look as:

MyProj/
   meson.build
   src/
      meson.build
   external/
      ExternalCode -> link to ...
      meson.build

Then, make aware meson of all sub-directories in the project placing this in top level meson.build file:

subdir('src')
subdir('external')

Upvotes: 2

Related Questions