通过CMake在Windows上编译项目时,可以说Boost库是依赖项,您可以执行以下操作:
ACTUAL_BOOST_ROOT
指定为CACHE PATH
设置,
然后会将其设置为BOOST_ROOT
,以便FIND_PACKAGE(Boost)
可以找到。{1}}
提升图书馆。我想对我自己的图书馆Straph做同样的事情,但出于某种原因,在我自己的FindStraph.cmake
中,我无法拿起STRAPH_ROOT
变量:
# Find Straph library
#
# Once done this will define:
# STRAPH_FOUND - System has Straph
# STRAPH_INCLUDE_DIRS - The Straph include directories
# STRAPH_LIBRARIES - The libraries needed to use Straph
find_path(STRAPH_INCLUDE_DIR straph/straph.h
HINTS
${STRAPH_ROOT}/include
${STRAPH_ROOT}
)
find_library(STRAPH_LIBRARY NAMES straph libstraph
HINTS
${STRAPH_ROOT}/lib
${STRAPH_ROOT}
)
set(STRAPH_LIBRARIES ${STRAPH_LIBRARY})
set(STRAPH_INCLUDE_DIRS ${STRAPH_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Straph DEFAULT_MSG STRAPH_LIBRARY STRAPH_INCLUDE_DIR)
mark_as_advanced(STRAPH_INCLUDE_DIR STRAPH_LIBRARY)
至少在我看来是这样的:在CMakeLists.txt
我做了类似的事情:
SET(ACTUAL_STRAPH_ROOT CACHE PATH "Location of Straph library")
IF(EXISTS ${ACTUAL_STRAPH_ROOT})
SET(STRAPH_ROOT ${ACTUAL_STRAPH_ROOT})
ENDIF()
FIND_PACKAGE(Straph REQUIRED)
INCLUDE_DIRECTORIES(${STRAPH_INCLUDE_DIRS})
但是,即使在我设置ACTUAL_STRAPH_ROOT
之后,也会发现它无法找到库。