[CMake] INCLUDE_DIRECTORIES in sub-directories doesn't work?

Sean Soria sean.soria at gmail.com
Tue Nov 25 06:38:07 EST 2008


CMakeLists.txt:
INCLUDE_DIRECTORIES(.)
ADD_SUBDIRECTORY(foo)
ADD_EXECUTABLE(hello main.c foo/main.c)

foo/CMakeLists.txt:
INCLUDE_DIRECTORIES(.)

I would expect foo/main.c to be compiled with:
/usr/bin/gcc   -I/code/xbmc/XBMC/build.test/.
-I/code/xbmc/XBMC/build.test/foo/.   -o
CMakeFiles/hello.dir/foo/main.o   -c
/code/xbmc/XBMC/build.test/foo/main.c

I even see the include path defined in
foo/CMakeFiles/CMakeDirectoryInformation.cmake:
SET(CMAKE_C_INCLUDE_PATH
  "."
  "foo/."
  )

Unfortunately cmake seems to ignore these and I get this instead:
/usr/bin/gcc   -I/code/xbmc/XBMC/build.test/.   -o
CMakeFiles/hello.dir/foo/main.o   -c
/code/xbmc/XBMC/build.test/foo/main.c

Am I missing something or is INCLUDE_DIRECTORIES broken?  I've even
tried set_property on the directory.


More information about the CMake mailing list