如何在cmake中为每个项目设置包含目录

How to set include directory per project in cmake

我有一个 cmake 可以为 visual studio 生成多个项目。我在 cmake 中有一行设置包含目录如下:

include_directories(
    ${Boost_INCLUDE_DIRS}
    ${OpenCV_INCLUDE_DIRS}
    ${LIBLAS_INCLUDE_DIRS}
    ${LIBE57_INCLUDE_DIRS}
    ${CERES_INCLUDE_DIRS}
    ${NANOFLANN_INCLUDE_DIRS}
     )

它为所有项目设置了它,我是否为每个项目设置了它?所以项目 A 只能访问 Boost include dir 而项目 B 只能访问 Opencv include dir 例如?

我发现这个 post 说它将在 2011 年晚些时候实施:

http://www.cmake.org/pipermail/cmake/2009-April/028682.html

你想要target_include_directories

http://www.cmake.org/cmake/help/v3.0/command/target_include_directories.html

http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html