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.
I was looking for
include_directories (${CMAKE_BINARY_DIR})
To add the build directory in case of out-of-source build.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With