Reputation: 4894
I'm using cmake and external project module via ExternalProject_Add
.
I'd like to specify custom header location for external project (just exactly as if I use include_directories
in that project, but I am not able to modify its CMakeLists.txt
and don't want to apply patch).
Is there any possibility to pass some include path to my external project?
I tried CMAKE_ARGS -DCMAKE_INCLUDE_PATH=<required path>
without success.
Upvotes: 9
Views: 7146
Reputation: 66061
You may execute additional CMake script for external project by assigning path to this script to variable CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE
(documentation).
Let external project uses CMake command
project(e_cool)
and you want to execute
include_directories(/path/to/additional/include)
at that moment.
For doing that, you need to prepare cmake script with corresponded content:
fix_e_cool.cmake:
include_directories(/path/to/additional/include)
And pass this script via CMAKE_ARGS option of ExternalProject_Add
in the main project:
CMakeLists.txt:
...
ExternalProject_Add(<name>
...
CMAKE_ARGS -DCMAKE_PROJECT_e_cool_INCLUDE=${CMAKE_SOURCE_DIR}/fix_e_cool.cmake
)
Upvotes: 10