Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake : Add build directory to include path

Tags:

c

cmake

I'm looking for the good way to add the build directory (which is different from my source directory, a git repository) to the include path for gcc, in order to have the classic "config.h" file for portability seen during the compilation.

like image 926
claf Avatar asked Feb 19 '09 19:02

claf


2 Answers

I was looking for

include_directories (${CMAKE_BINARY_DIR})

To add the build directory in case of out-of-source build.

like image 72
claf Avatar answered Oct 05 '22 06:10

claf


A more modern approach than the selected answer would be to use

set(CMAKE_INCLUDE_CURRENT_DIR ON)

CMAKE_INCLUDE_CURRENT_DIR - Automatically add the current source and build directories to the include path.

like image 45
vuko_zrno Avatar answered Oct 05 '22 06:10

vuko_zrno