为什么cmake findBoost找不到系统提升路径?

时间:2017-06-22 13:30:43

标签: c++ boost cmake archlinux

我试图为我的项目制作cmake句柄依赖项, 然而,似乎cmake无法在我的系统上找到提升。

cmake_minimum_required(VERSION 3.8)
project(QuineMccluskeyExample)

set(CMAKE_CXX_STANDARD 14)

if(MSVC)
    set(CMAKE_CXX_FLAGS "/WX- /Wall /O2 /Ob2")
else()
    set(CMAKE_CXX_FLAGS "-pthread -Wall -O3")
endif()

# header only library
add_library(QuineMccluskey INTERFACE)
target_include_directories(QuineMccluskey INTERFACE include/)

# example project source directories
set(EXAMPLES ${PROJECT_SOURCE_DIR}/examples)

set(SOURCE_FILES
  ${EXAMPLES}/main.cpp) 


# Boost dependency
find_package(Boost 1.63.0 COMPONENTS REQUIRED
  dynamic_bitset
  config
  core
  move
  static_assert
  assert
  exception
  integer)

if(Boost_FOUND)
  message("found BOOST: " ${BOOST_ROOT})
  include_directories(${Boost_INCLUDE_DIR})
  add_executable(QuineMccluskeyExample ${SOURCE_FILES})
else()
  message("couldn't find boost")
endif()

这是我的CMakeLists.txt文件 以下是cmake输出日志

Boost version: 1.64.0

  Boost include path: /usr/include

  Could not find the following Boost libraries:

          boost_dynamic_bitset
          boost_config
          boost_core
          boost_move
          boost_static_assert
          boost_assert
          boost_integer

  No Boost libraries were found.  You may need to set BOOST_LIBRARYDIR to the
  directory containing Boost libraries or BOOST_ROOT to the location of
  Boost.

以上是让findBoost查找我的系统路径的结果。 我的系统路径是/ usr / include / boost cmake说它找到了正确的路径。 我检查了所有必需的依赖标题是否存在, 但由于某些原因,cmake无法找到它们。

手动提供-DBOOST_ROOT =“/ usr / include”会产生相同的结果。

下面是/ usr / include / boost

accumulators                  math
algorithm                     math_fwd.hpp
align                         mem_fn.hpp
aligned_storage.hpp           memory_order.hpp
align.hpp                     metaparse
any.hpp                       metaparse.hpp
archive                       move
array.hpp                     mpi
asio                          mpi.hpp
asio.hpp                      mpl
assert.hpp                    msm
assign                        multi_array
assign.hpp                    multi_array.hpp
atomic                        multi_index
atomic.hpp                    multi_index_container_fwd.hpp
bimap                         multi_index_container.hpp
bimap.hpp                     multiprecision
bind                          next_prior.hpp
bind.hpp                      noncopyable.hpp
blank_fwd.hpp                 nondet_random.hpp
blank.hpp                     none.hpp
call_traits.hpp               none_t.hpp
cast.hpp                      non_type.hpp
cerrno.hpp                    numeric
checked_delete.hpp            operators.hpp
chrono                        operators_v1.hpp
chrono.hpp                    optional
circular_buffer               optional.hpp
circular_buffer_fwd.hpp       parameter
circular_buffer.hpp           parameter.hpp
compatibility                 pending
compressed_pair.hpp           phoenix
compute                       phoenix.hpp
compute.hpp                   pointee.hpp
concept                       pointer_cast.hpp
concept_archetype.hpp         pointer_to_other.hpp
concept_check                 polygon
concept_check.hpp             polymorphic_cast.hpp
config                        polymorphic_pointer_cast.hpp
config.hpp                    pool
container                     predef
context                       predef.h
convert                       preprocessor
convert.hpp                   preprocessor.hpp
core                          process
coroutine                     process.hpp
coroutine2                    program_options
crc.hpp                       program_options.hpp
cregex.hpp                    progress.hpp
cstdfloat.hpp                 property_map
cstdint.hpp                   property_tree
cstdlib.hpp                   proto
current_function.hpp          ptr_container
cxx11_char_types.hpp          python
date_time                     python.hpp
date_time.hpp                 qvm
detail                        random
dll                           random.hpp
dll.hpp                       range
dynamic_bitset                range.hpp
dynamic_bitset_fwd.hpp        ratio
dynamic_bitset.hpp            ratio.hpp
enable_shared_from_this.hpp   rational.hpp
endian                        ref.hpp
exception                     regex
exception_ptr.hpp             regex_fwd.hpp
fiber                         regex.h
filesystem                    regex.hpp
filesystem.hpp                scoped_array.hpp
flyweight                     scoped_ptr.hpp
flyweight.hpp                 scope_exit.hpp
foreach_fwd.hpp               serialization
foreach.hpp                   shared_array.hpp
format                        shared_container_iterator.hpp
format.hpp                    shared_ptr.hpp
function                      signal.hpp
functional                    signals
functional.hpp                signals2
function_equal.hpp            signals2.hpp
function.hpp                  signals.hpp
function_output_iterator.hpp  smart_ptr
function_types                smart_ptr.hpp
fusion                        sort
generator_iterator.hpp        spirit
geometry                      spirit.hpp
geometry.hpp                  statechart
get_pointer.hpp               static_assert.hpp
gil                           swap.hpp
graph                         system
hana                          test
hana.hpp                      thread
heap                          thread.hpp
icl                           throw_exception.hpp
implicit_cast.hpp             timer
indirect_reference.hpp        timer.hpp
integer                       token_functions.hpp
integer_fwd.hpp               token_iterator.hpp
integer.hpp                   tokenizer.hpp
integer_traits.hpp            tr1
interprocess                  tti
intrusive                     tuple
intrusive_ptr.hpp             type_erasure
io                            type.hpp
io_fwd.hpp                    type_index
iostreams                     type_index.hpp
is_placeholder.hpp            typeof
iterator                      type_traits
iterator_adaptors.hpp         type_traits.hpp
iterator.hpp                  units
lambda                        unordered
last_value.hpp                unordered_map.hpp
lexical_cast                  unordered_set.hpp
lexical_cast.hpp              utility
limits.hpp                    utility.hpp
locale                        uuid
locale.hpp                    variant
local_function                variant.hpp
local_function.hpp            version.hpp
lockfree                      visit_each.hpp
log                           vmd
logic                         wave
make_default.hpp              wave.hpp
make_shared.hpp               weak_ptr.hpp
make_unique.hpp               xpressive

boost是archlinux repo上的最新发行版1.64_02

还有一个问题。 有没有一种干净的方法来在git CMake项目中包含boost依赖项? 喜欢使用子模块? 我试过但是想出一个简单干净的想法。

1 个答案:

答案 0 :(得分:1)

  

手动提供-DBOOST_ROOT =" / usr / include"

您提供的位置错误。相反,你应该做

-D BOOST_LIBRARYDIR=/usr/lib/boost

或Boost库所在的任何地方。