cmake: pass include directories to external project


I'm using <strong>cmake</strong> and <a href="https://cmake.org/cmake/help/v3.2/module/ExternalProject.html" rel="nofollow">external project</a> 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.


You may execute additional CMake script for external project by assigning path to this script to variable CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE (<a href="https://cmake.org/cmake/help/v3.0/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.html" rel="nofollow">documentation</a>).

Let <em>external project</em> uses CMake command


and you want to execute


at that moment.

For doing that, you need to prepare cmake script with corresponded content:



And pass this script via CMAKE_ARGS option of ExternalProject_Add in the main project:


... ExternalProject_Add(<name> ... CMAKE_ARGS -DCMAKE_PROJECT_e_cool_INCLUDE=${CMAKE_SOURCE_DIR}/fix_e_cool.cmake )


Using <a href="https://cmake.org/cmake/help/v3.0/command/option.html" rel="nofollow">option</a> will allow you to pass data from the the command line, for example:

cmake -DHEADER_PATH="/usr/my/path/file.h" ..


  • iOS PUSH notification type options? Alert vs Banner?
  • Is it possible to write a gherkin step on multiple lines?
  • Partial search on Encrypted field
  • using copy in postgresql?
  • Detecting iOS app with app lock MDM profile
  • How to fix google cloud ssl issue
  • How do you run a string as code? [duplicate]
  • WebDriver: ChromeDriver attempting to reach http://localhost/session on initialization and failing
  • How to force process isolation for an out of process COM server?
  • How to add an Auth Token in every request using AFIncrementalStore?
  • No session share and avoid navigation buttons in browser while opening application window
  • QTreeView with fixed column widths
  • In Java, how can I take a variable obtained from a user input from one method and use the output in
  • Visual Studio Code PHP Debug does not stop on breakpoints for Docker project
  • Number formatting in Oracle using TO_CHAR
  • Footer appears next to section instead of below
  • Configure MySQL db for a Spring-MVC project
  • Matplotlib: subplot
  • kafka-topics.sh ---delete --topic ''testTopic'' is not working for kafka V 0.10.
  • Prepopulated Core Data SQL store with new Write-Ahead Log (WAL) journaling
  • Erlang needs to connect to https server?
  • Reveal Icon Button - Bootstrap 3
  • How to detect beginning of line, or: “The name 'getCharPositionInLine' does not exist in t
  • ODBC connection to an .accdb file
  • Django non-rel createsuperuser fails due to non-ascii characters
  • Semi-local Levenshtein distance
  • Spring annotation @Order
  • How to create mirrored image effect with CSS single element
  • Creating http response as a return value for mockito
  • Using loops in Jasmine (with injected service)
  • Find all parks for a given zipcode with google maps
  • Javascript inside HTML import not affecting imported HTML
  • C# code can't “see” the methods in my C++ dll
  • Copy and paste data from multiple workbooks to a worksheet in another Workbook
  • Getting the type of a “Type” in C# reflection
  • Create an average of multiple excel chart without the data source
  • Error handeling in antlr 3.0
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • Update cell query for Excel ADO from Delphi