Is it possible to specify an include directory when running cmake
. For example
cmake . -INCLUDE=/foo/bar
The header files are in a separate directory from the sources that I would like to compile, and I would like to remedy this without tinkering with the Makefile
generated by cmake
.
Update
The project does have a CMakeLists.txt
. Excerpt:
INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/ga)
INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/utils)
Can ${EO_SOURCE_DIR}
be set from the command line?
If the path to your headers is fixed in relation to your sources, then you should be able to avoid having to pass this info via the command line.
Say your project's directory structure is:
and in your CMakeLists.txt, you currently have something like:
then to add the
/my_includes
folder to the the list of include search paths, you only need to add the following:For further info about
include_directories
, runAnswer to update in question:
Yes, using the
-D
command line option just doThe variable
${EO_SOURCE_DIR}
gets cached as a result of this, so you only need this-D
argument once (unless the required path changes or you delete your CMakeCache file, etc.)Proper way to do this is to define a variable in CMakeLists.txt and ask user to set it:
Now you can set it from the command line:
cmake -D YOURLIB_INCLUDE_DIR=/path/to/yourlib/include .