Reputation: 1694
Regards:
I have two different C++ projects, each one with its own CMakeList.txt file that generates a .so library file. E.g. both projects are under the paths trunk/A, and trunk/B, and they contain the files:
that respectively generate files A.so and B.so. For practical reasons, I want to keep both projects A and B separated, but I would also like to have a CMakeList.txt file (e.g. trunk/CMakeList.txt) that would compile both binaries simultaneously.
I expected to replicate something similar to what can be achieved with qmake, by including a .pri file in a .pro file. Hence, I tried by including both CMakeList files with the following code for trunk/CMakeList.txt:
PROJECT(TEST)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
include(A/CMakeLists.txt)
include(B/CMakeLists.txt)
But CMake does not work that way. The contents in the included CMakeList files are evaluated from the trunk directory. E.g, by reading the following line in trunk/A/CMakeList.txt:
FILE(GLOB HEADERS *.h)
CMake will only look for *.h files in /trunk, not in /trunk/A
Is there a proper way to do this in CMake? Something similar to what QMake does with .pri include files?
Hundred thanks in advance!.
Upvotes: 0
Views: 154
Reputation: 4626
You need to use ADD_SUBDIRECTORY
:
PROJECT(TEST)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
ADD_SUBDIRECTORY( A )
ADD_SUBDIRECTORY( B )
Upvotes: 2