[CMake] dependency on header

Eric Noulard eric.noulard at gmail.com
Sat Feb 25 18:22:22 EST 2012


2012/2/25 Krzysztof <kj at limes.com.pl>:
> Does CMake know that if I include a header file in a source it should
> consider the source as dependent on the header? I mean, will CMake recompile
> the source when only the header changes or do I need explicitly tell CMake
> this in CMakeLists.txt?

CMake has a builtin dependency checker for supported language (C, C++,
Fortran, ...)
so yes it should work.

Did you try ? Do you have a counter-example?

That said specifying all files (including headers) in your CMakeLists.txt
may be a good habit too.

Have a look at:

PUBLIC_HEADER, PRIVATE_HEADER, HEADER_FILE_ONLY CMake properties.
cmake --help-property PUBLIC_HEADER

and the PUBLIC_HEADER option of the INSTALL(TARGETS) command.

you'll see that explicitely specifying headers in CMakeLists.txt may be useful.
-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list