包含基于Cmake中条件的目录

时间:2014-05-27 23:08:14

标签: c++ c makefile cmake

我们的项目中有一个树形目录结构,如:

project_dir/public_include
public_include has dir1, dir2 and dir3

现在,我想根据选项

包含目录
if(option A)
 include_directories(project_dir/public_include/dir1)
else
 include_directories(project_dir/public_include/dir3
                     project_dir/public_include/dir2)
endif()

头文件是独立的。

它无法正常工作!我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

options怎么样?尝试使用option(option_A "include dir 1" ON)顶部的CMakeLists.txt。默认设置为option_A=ON,您的if语句应该有效。