[CMake] adding include directories to main target

Łukasz Tasz lukasz at tasz.eu
Wed Oct 26 15:33:39 EDT 2011


Hi,

in C,CMakelists.txt set variable which store include_dir but add
PARENT_SCOPE, and then use this variable in A,CMakeLists.txt to set
includes:
CCMakeLists.txt:

set(includesFromC "dir_name" PARENT_SCOPE)


ACMakeLists.txt:

add_subdirectory(C)
include_directories(${includesFromC})


Another option is that if includeDir from C is Cproject relative, in
CCMakeLists.txt you can specify command project(projectC)
and then refer to ${projectC_SOURCE_DIR} while setting includes in
ACMakeLists.txt

Hope it helps
Lukasz

2011/10/26 j <j at dynamica.org>:
> Hi there,
>
> I'm trying to set the include directories that a library in my project uses
> into my main target. the hierarchy is as follows:
>
> CMakeLists.txt (A)
> +application
>  CMakeLists.txt (B)
> +library
>  CMakeLists.txt (C)
>
> B is called by A through add_subdirectory and B does a LINK_LIBRARIES for
> 'library'.
> A calls C as well through add_subdirectory and that adds a target for
> 'library' to the project.
> there are, however many compiler flags and include paths set in C that are
> needed in the
> 'main' target of the project to compile 'application'
>
> How do I make the include paths set by C appear in the target for
> 'application' ?
>
> Thanks,
>
> Jonathan
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Lukasz Tasz


More information about the CMake mailing list