[CMake] CPATH vs CMAKE_INCLUDE_PATH

Daniel Stonier d.stonier at gmail.com
Sun Mar 25 03:35:48 EDT 2012


What is the preferred way of passing include directories globally to your
cmake project from the command line?

I was looking at CMAKE_INCLUDE_PATH but noticed that it just helps it find
files, it doesn't actually add the directories to the build. You have to do
that via include_directories(). e.g. something like this might let you pass
additional directories into your cmake project if you had this excerpt in
your project's CMakeLists.txt:

foreach(path ${CMAKE_INCLUDE_PATH})
  include_directories(${path})
endforeach()

But this feels like I'm bending it's original purpose to my iron will. Is
there a reason why CMAKE_INCLUDE_PATH only does half the job?

If it's not the preferred way of passing include directories to a cmake
project - is setting a CPATH environment variable the correct way? And
isn't that awkward having to worry about both non-cmake and cmake variables
to build your project?

I also wished to ask similarly re LIBRARY_DIRS vs CMAKE_LIBRARY_PATH as it
is similar.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120325/1287c036/attachment.htm>


More information about the CMake mailing list