作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 ExternalProject_Add 将外部项目作为库添加到我的项目中:
ExternalProject_Add(
xgboost
GIT_REPOSITORY https://github.com/dmlc/xgboost.git
GIT_TAG v0.60
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
INSTALL_COMMAND ""
)
set(XGBOOST_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}/src")
set(XGBOOST_BINARY_PATH "${XGBOOST_PREFIX_PATH}/xgboost-build")
set(XGBOOST_BINARY_INCLUDE "${XGBOOST_PREFIX_PATH}/xgboost/include;${XGBOOST_PREFIX_PATH}/xgboost/dmlc-core/include;${XGBOOST_PREFIX_PATH}/xgboost/rabit/include")
add_library(libxgboost IMPORTED STATIC GLOBAL)
add_dependencies(libxgboost xgboost)
set_target_properties(libxgboost PROPERTIES
"IMPORTED_LOCATION" "${XGBOOST_BINARY_PATH}/liblibxgboost.dylib"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
"INTERFACE_INCLUDE_DIRECTORIES" "${XGBOOST_BINARY_INCLUDE}"
)
add_library(somelib STATIC SomeLib.cpp)
target_include_directories(somelib PUBLIC libxgboost)
target_link_libraries(somelib libxgboost)
CMake Error in somelib/CMakeLists.txt:
Imported target "libxgboost" includes non-existent path
"build/xgboost/src/xgboost/include"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
最佳答案
我会发布最终的 CMakeLists.txt
将 xgboost 包含到您的项目中,它可能对某人有用,解决上述问题的方法是在 cmake
期间创建目录。配置阶段(注意:我使用 OSX 来构建它,所以你需要为 GNU/Linux 使用 liblibxgboost.so
而不是 liblibxgboost.dylib
):
include(ExternalProject)
ExternalProject_Add(
xgboost
GIT_REPOSITORY https://github.com/dmlc/xgboost.git
GIT_TAG v0.60
PREFIX ${CMAKE_CURRENT_BINARY_DIR}
INSTALL_COMMAND ""
)
set(XGBOOST_PREFIX_PATH "${CMAKE_CURRENT_BINARY_DIR}/src")
set(XGBOOST_BINARY_PATH "${XGBOOST_PREFIX_PATH}/xgboost-build")
set(XGBOOST_LIB_INCLUDE "${XGBOOST_PREFIX_PATH}/xgboost/include")
set(DMLC_LIB_INCLUDE "${XGBOOST_PREFIX_PATH}/xgboost/dmlc-core/include")
set(RABIT_LIB_INCLUDE "${XGBOOST_PREFIX_PATH}/xgboost/rabit/include")
set(XGBOOST_BINARY_INCLUDE "${XGBOOST_LIB_INCLUDE};${DMLC_LIB_INCLUDE};${RABIT_LIB_INCLUDE}")
# Hack to make it work, otherwise INTERFACE_INCLUDE_DIRECTORIES will not be propagated
file(MAKE_DIRECTORY ${XGBOOST_LIB_INCLUDE})
file(MAKE_DIRECTORY ${DMLC_LIB_INCLUDE})
file(MAKE_DIRECTORY ${RABIT_LIB_INCLUDE})
add_library(libxgboost IMPORTED STATIC GLOBAL)
add_dependencies(libxgboost xgboost)
set_target_properties(libxgboost PROPERTIES
"IMPORTED_LOCATION" "${XGBOOST_BINARY_PATH}/liblibxgboost.dylib"
"INTERFACE_INCLUDE_DIRECTORIES" "${XGBOOST_BINARY_INCLUDE}"
)
关于CMake:如何将 INTERFACE_INCLUDE_DIRECTORIES 与 ExternalProject 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45516209/
我正在创建一个希望公开两个接口(interface)包含目录的导入目标: list(APPEND LIB_INCLUDE_DIRS "dir1") list(APPEND LIB_INCLUDE_DI
我试图了解可以在 target_include_directories 中指定的范围之间的区别,特别是 PRIVATE和 INTERFACE .文档说(特定上下文是仅 header 库): The I
我正在尝试使用 ExternalProject_Add 将外部项目作为库添加到我的项目中: ExternalProject_Add( xgboost GIT_REPOS
我是一名优秀的程序员,十分优秀!