强制编译器的cmake使构建失败
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了强制编译器的cmake使构建失败相关的知识,希望对你有一定的参考价值。
我认为为cmake指定-DCMAKE_CXX_COMPILER_FORCED=1 -DCMAKE_C_COMPILER_FORCED=1
会使我的构建更快,因为它会跳过编译器检查。相反,它使我的构建失败:
#16 470.8 -- Found Git: /usr/bin/git (found version "2.17.1")
#16 470.8 -- Content of the error:
#16 470.8 -- Version of this git repo: v0.0.1-2-g93b2a22
#16 470.9 -- The C compiler identification is GNU 5.5.0
#16 470.9 -- The CXX compiler identification is GNU 5.5.0
#16 470.9 -- GCC detected - Adding flags
#16 471.0 -- Looking for pthread.h
#16 471.0 -- Looking for pthread.h - found
#16 471.0 -- Looking for pthread_create
#16 471.1 -- Looking for pthread_create - not found
#16 471.1 -- Looking for pthread_create in pthreads
#16 471.1 -- Looking for pthread_create in pthreads - not found
#16 471.1 -- Looking for pthread_create in pthread
#16 471.2 -- Looking for pthread_create in pthread - found
#16 471.2 -- Found Threads: TRUE
#16 471.2 -- Found Protobuf: /usr/local/lib/libprotobuf.so;-lpthread (found version "3.5.0")
#16 471.2 CMake Error at /opt/cmake/share/cmake-3.12/Modules/FindBoost.cmake:2048 (message):
#16 471.2 Unable to find the requested Boost libraries.
#16 471.2
#16 471.2 Boost version: 1.65.1
#16 471.2
#16 471.2 Boost include path: /usr/include
#16 471.2
#16 471.2 Could not find the following Boost libraries:
#16 471.2
#16 471.2 boost_graph
#16 471.2
#16 471.2 No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
#16 471.2 directory containing Boost libraries or BOOST_ROOT to the location of
#16 471.2 Boost.
#16 471.2 Call Stack (most recent call first):
#16 471.2 CMakeLists.txt:24 (find_package)
#16 471.2
#16 471.2
#16 471.3 -- Configuring incomplete, errors occurred!
安装了libboost-graph-dev,所以不清楚这里发生了什么 - 如果删除选项,那么构建工作正常。
这里发生了什么?
答案
来自文档:
Boost Graph Library是一个仅限标头的库,无需构建即可使用。
不需要在find_package(Boost ...)
调用中指定仅头文件库。删除它,然后链接到Boost::boost
调用中的目标target_link_libraries
或将include_directories(${Boost_INCLUDE_DIRS})
添加到您的CMakeLists.txt文件。
以上是关于强制编译器的cmake使构建失败的主要内容,如果未能解决你的问题,请参考以下文章
使用特定链接器进行CMake交叉编译不会将参数传递给armlink
添加不存在的目标时强制 CMake target_link_libraries 失败