Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake include path

Tags:

c++

cmake

In a C++ project, I would to include the header files as as descendants of the project's source directory without use of UNIX directory shortcuts . or .. . Im not sure how to configure cmake to work with that.

I have the directory structure:

Root
|-include
| |- foo.h
|-src
| | foo.cpp
like image 475
user1377000 Avatar asked Mar 13 '13 17:03

user1377000


2 Answers

put into root\CMakeList.txt:

project(root)
include_directories(${root_SOURCE_DIR}/include)
...

you can use root_SOURCE_DIR everywhere in sub projects.

for more information consider to visit http://www.cmake.org/Wiki/CMake_Useful_Variables#Variables_not_listed_here

like image 115
AnatolyS Avatar answered Oct 23 '22 05:10

AnatolyS


Use include_directories( include ) for CMakeLists.txt in Root folder. Or include_directories( ${CMAKE_SOURCE_DIR}/include ) from any subfolder.

like image 25
yattering Avatar answered Oct 23 '22 03:10

yattering