[cmake-developers] Setting the INCLUDE_DIRECTORIES property before and after a target after 9106b564
Brad King
brad.king at kitware.com
Tue May 1 08:16:07 EDT 2012
On 4/30/2012 8:37 PM, Raphael Kubo da Costa wrote:
> add_library(foo foo.c)
> set_directory_properties(
> PROPERTIES INCLUDE_DIRECTORIES "${SOME_DIRECTORY}")
[snip]
> Is this change of behaviour intentional?
CMake 2.8.8 introduced support for per-target include directories.
Prior to that the directory-level INCLUDE_DIRECTORIES property was
documented as read-only:
$ cmake --help-property INCLUDE_DIRECTORIES
cmake version 2.8.7
INCLUDE_DIRECTORIES
List of preprocessor include file search directories.
This read-only property specifies the list of directories given so far
to the include_directories command. It is intended for debugging
purposes.
It was meant to be set only by the include_directories() command.
The code in question was using previously undefined behavior and
worked only by accident.
CMake 2.8.8 does define behavior but not what the code above
expects. When a target is first created (e.g. add_library) the
value of the directory-level INCLUDE_DIRECTORIES property is used
to initialize a target-level property of the same name. After that
direct changes to the INCLUDE_DIRECTORIES property have no effect
on the target. However, the include_directories() command will
still append to both the directory-level property AND the target
properties for all targets already created in the current dir.
-Brad
More information about the cmake-developers
mailing list