[cmake-developers] (no subject)

Lectem lectem at gmail.com
Sat Dec 2 04:45:46 EST 2017


Hi,

I’m hurting an issue trying to hide dependencies from files that do not need those.
For example, I have a library that helps me decode some file, but I don’t want this library headers to be available for every .cpp in my library but one.

For example what one may do is the following :

#---------------------
add_library(mylib foo.cpp bar.cpp)
target_link_libraries(mylib PRIVATE libonlyusefulforfoo)
#---------------------

It works fine, but now bar.cpp can also include headers from libonlyusefulforfoo.
So what I tried was to use object libraries, but it has many disadvantages :
- I now have to duplicate dependencies for the object library and mylib if they have include directories requirements or compile flags in common
- An object library is a target… and I don’t want to add one target per file that has special include directories
- An object library shows in IDEs, while I’d like the .cpp files to stay in the same project. In visual the obj will be in my library but this is not practical.
I thought about source files properties, but unfortunately they do not support include directories, so here is my question :

TL ;DR
Would it be possible/difficult to have a PRIVATE_INCLUDE_DIRECTORIES property added for source files ? 
We already have COMPILE_FLAGS so why not include directories ?

I know we can set include directories per directory, but I don’t think that putting single .cpp files in seperate headers is good.

Thanks,
Lectem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20171202/3519f149/attachment.html>


More information about the cmake-developers mailing list