2016-01-03 87 views
2

cmake的headerfile boost.hpp我喜欢用的cmake包括与cmake的

添加boost/operators.hpp从CMake的的FindBoost文档:

find_package(Boost 1.36.0) 
if(Boost_FOUND) 
    include_directories(${Boost_INCLUDE_DIRS}) 
    add_executable(foo foo.cc) 
endif() 

所以我添加

从消息
find_package(Boost 1.60.0) 
if (Boost_FOUND) 
    include_directories(${Boost_INCLUDE_DIRS}) 

    add_library(core ${core_SRCS}) 
    add_executable(app main.cpp) 
    target_link_libraries(app core) 

endif() 

输出:

-- Boost version: 1.60.0 
-- BOOST_ROOT=~/Projects/ClionProjects/.repo/boost_1_60_0 
-- Boost_DIR=Boost_DIR-NOTFOUND 
-- Boost_INCLUDE_DIR=/home/dornathal/Projects/ClionProjects/.repo/boost_1_60_0 

然而,它构建(我可以运行程序和测试),但只要我尝试包含#include<boost/operators.hpp>它不会在测试项目中找到它。

我实际上是由boost::operators<T>扩展一个类,并奇怪我的IDE(克利翁)让我跳到那个的资源文件。

+0

'operations.hpp'与'operators.hpp'不一样。 – juanchopanza

+0

好了解决了我的发帖当然包括 – Dornathal

+2

时我使用了operators.hpp当然没有关于它的“当然”。我们无法阅读您的真实代码。 – juanchopanza

回答

0

include_directories CMake命令添加包含当前目录及其子目录的目录。由于你的错误的测试项目,并在主要项目中使用include_directories,我想这个问题是,你必须对这些单独的目录,例如:

src/ 
    CMakeLists.txt - include_directories used here 
test/ 
    test.cc - no effect on this file 

如果是这样,你可以移动include_directories的情况下直到他们的共同父目录或使用target_include_directories可以传播公众INCLUDE_DIRECTORIES财产。

你也可以通过添加VERBOSE=1你make命令看到传递给你的编译器的命令:

make VERBOSE=1 

这显示了包括目录都可以通过除其他外-I...选项传递到编译器。