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.
1, include_directories() is accessible for all the files in the source-tree 2, target_include_directories() is-only accessible for a specific target when compile.
cmake is searched first in CMAKE_MODULE_PATH , then in the CMake module directory. There is one exception to this: if the file which calls include() is located itself in the CMake builtin module directory, then first the CMake builtin module directory is searched and CMAKE_MODULE_PATH afterwards.
CMakeLists. txt is placed at the root of the source tree of any application, library it will work for. If there are multiple modules, and each module can be compiled and built separately, CMakeLists. txt can be inserted into the sub folder.
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
)
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