0

My project structure is currently this:

-project
|--apps
   |--app1
   |--test
|--libs
   |--lib1_subdir
      |--lib1_lib
      |--lib1_test
         |--test1
         |--test2
      |--lib1_examples
...

It works fine and dependencies are easily managed with simples

libs.pro

libs2.depends = lib1

libs1.pro

tests.depends = lib

is there a way to structure the project as follow keeping a clean dependencies structure?

-project
|--app
   |--app1
|--lib
   |--lib1
   |--lib2
|--tests
   |--test_lib1
   |--test_lib2
   |--test_lib3
|--examples
   |--ex_lib1
   |--ex_app1
...

subdir project can specify dependencies only for the same directory, cmake is not an option.

Moia
  • 2,216
  • 1
  • 12
  • 34

1 Answers1

0

subdir project can specify dependencies only for the same directory

Of course, no. Simply use another level of indirection:

SUBDIRS = lib1 lib2 lib1_tests
lib1_tests.depends = lib1
lib1_tests.subdir = ../tests/test_lib1
# and so on
Matt
  • 13,674
  • 1
  • 18
  • 27
  • Well, in this way you do are including lib1_tests in that subdir, this means lib1_tests appears 2 times in the project hierarchy. This should means too if I'm going to compile from the top level hierarchy the project will be tried to be compiled 2 times, am I wrong? – Moia Aug 05 '19 at 08:44
  • @Moia SUBDIRS implements that dreaded "recursive make" pattern. Hence, it knows nothing about inter-project dependencies. This is something you have to provide as an extra step. And an additional no-op "make -C xxx" usually is not too expensive. But, of course, you can "optimize" some stuff. That's your choice. – Matt Aug 05 '19 at 12:02