[CMake] order of include dirs
Brad King
brad.king at kitware.com
Tue Mar 28 11:00:02 EST 2006
Alexander Neundorf wrote:
> in KDE we have the problem that e.g. when compiling kdebase the headers
> in the source dir should be preferred over the installed ones.
> Usually we would do
> include_directories( ${KDE4_INCLUDES} ) in the toplevel CMakeLists.txt.
> When adding more include dirs in CMakeLists.txt in deeper directories,
> these directories will be appended to the list of include dirs, except
> when used with the BEFORE keyword.
> But now we cannot realistically expect that every KDE developer will
> always remember the BEFORE keyword.
> So we had two ideas:
> make the behaviour configurable:
> # make prepend default:
> set(CMAKE_INCLUDE_DIRS_APPEND false)
> # to force appending:
> include_directories(AFTER dir1 dir2)
>
> Problem here: moving cmake files around to another project where this
> isn't set would change the behaviour.
>
> Second idea:
>
> include_directories(LAST dir1 dir2)
>
> which would have the effect that the listed directories would always be
> used after all other include dirs specified without the "LAST" keyword.
I think that will create two ordered lists of include directories
instead of one, which will just be confusing. I suggest creating a
kde4_add_indluce_directories macro that adds the BEFORE option:
macro(kde4_add_indluce_directories)
include_directories(BEFORE ${ARGN})
endmacro(kde4_add_indluce_directories)
-Brad
More information about the CMake
mailing list