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

Bill Hoffman bill.hoffman at kitware.com
Tue Nov 25 17:10:02 EST 2008


Sean Soria wrote:
> I had them switched originally and just double checked.  This also doesn't work:
> CMakeLists.txt:
> ADD_SUBDIRECTORY(foo)
> ADD_EXECUTABLE(hello main.c foo/main.c)
> 
> foo/CMakeLists.txt:
> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
> 

The problem is the add_subdirectory.  Although the docs are not clear on 
this include_directories is essentially a directory property.  It sets 
the include directories for all targets in that directory.  You could 
use include instead.

include(foo/includes.cmake)


-Bill



More information about the CMake mailing list