Reputation: 9263
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.
Upvotes: 15
Views: 18245
Reputation: 667
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.
Upvotes: 10
Reputation: 13051
There is also ${CMAKE_CURRENT_BINARY_DIR}
which resolves the the subdirectory in the build directory that is currently active.
If your sources are in a subdirectory such as src/
and you want to include files that are being generated from src/CMakeLists.txt
then using ${CMAKE_CURRENT_BINARY_DIR}
might be what you are looking for.
Upvotes: 1
Reputation: 9263
I was looking for
include_directories (${CMAKE_BINARY_DIR})
To add the build directory in case of out-of-source build.
Upvotes: 18