[CMake] General questions

Alexander Neundorf a.neundorf-work at gmx.net
Mon Feb 25 13:54:02 EST 2008


On Sunday 24 February 2008, Yang Zhang wrote:
...
>    $ CPATH=inc make
>    [100%] Built target a
>
>    $ touch inc/a.h
>
>    $ CPATH=inc make
>    [100%] Built target a
>
> It appears that cmake doesn't know where the header files are actually
> located, and hence is unable to add a proper dependency. I'm hoping to
> avoid specifying the same include_directories(...) for all projects that
> I'm working on. I've recently been surviving on an an ad-hoc build
> system that uses gcc -M, which specifies full paths, but that's tied to
> the compiler, of course.

By using CPATH you are working around it.
Additionally by relying on external environment variables it is not obvious 
from the build files what will actually be built (for readers of these 
files).
Just use include_directories() to add the include dirs you need. If you have a 
lot of them, you can create a macro which sets them all and just call that 
macro once from your toplevel cmake file.
If you care mainly about the current directory, you can do:
set(CMAKE_INCLUDE_CURRENT_DIR ON)

Alex


More information about the CMake mailing list