Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake system include search path

Tags:

cmake

I'm wondering how I would go about adding an include directory to the system search path for a CMake project. Particularly, I've some source that I'm trying to build a CMake project for.

The source is not mine, and so I don't really want to modify it.

The source has the following include directive:

#include <foo/bar.h>

So I need to add the directory containing foo to my search path. Is this something I can set within the CMakeLists.txt?

like image 501
bkinman Avatar asked Jul 18 '13 16:07

bkinman


1 Answers

you can use include_directories(..) to set directories that will be used for all targets, or add include directories only to a specific target with target_include_directories or set_property:

set(foo_INCLUDE_DIRS
    ${CMAKE_SOURCE_DIR}/foo
    ${CMAKE_SOURCE_DIR}/whatever)

set_property(TARGET YourTarget PROPERTY INCLUDE_DIRECTORIES ${foo_INCLUDE_DIRS})

target_include_directories(<target> [SYSTEM] [BEFORE <INTERFACE|PUBLIC|PRIVATE> [items1...]

#or
include_directories([AFTER|BEFORE] [SYSTEM] ${foo_INCLUDE_DIRS})
like image 88
user1283078 Avatar answered Oct 19 '22 14:10

user1283078