Working around target needing many include directories

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Working around target needing many include directories

Israel Israeli
We are using a library that adds all of it's subdirectories to the include search path (hundreds of directories and thousands of files). This is done because they change their folder structure constantly (but we don't care as we are upgrading every once in a while and can adjust).
We don't want this for our usage as the file names are very generic and can cause name clashes (`Queue.h` for example) with other third party libs.

We want to rewrite their build system (which is not cmake originally, but that is a different story) so that this addition of include directories is private.

Namely simple write:

target_include_directories(Lib PRIVATE ${LIB_SUBDIRECTORIES})

Here is the problem and question:
When building the lib like this, everything works great, but when our project that depends on the library is built, there are preprocessor errors - we include files from the library which in turn include other lib files with non relative includes - and in our target build step the compiler does not have the include directories needed to resolve the non relative include.
Example:

Lib
    dirA
      file_a.h
    dirB
     file_b.h

//file_a.h
#include "file_b.h"

//main.cpp
#include "Lib\dirA\file_a.h"

App
    main.cpp

//CMake builds `Lib` okay.
//CMake fails to build `App` due to non-relative include in `file_a.h`


Is there a way to have it both ways? Build the library with all include paths, and in target depending on it - not add all of them?
Can precompiled headers do this?
Is there a pure cmake solution?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake