gpt4 book ai didi

cmake - 使用CMake构建外部项目时如何不进行安装步骤

转载 作者:行者123 更新时间:2023-12-03 14:50:11 26 4
gpt4 key购买 nike

我正在使用cmake ExternalProject_Add命令构建依赖项项目:

include(ExternalProject)
...
set(COMMON_BASE_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../CommonBase)

ExternalProject_Add(CommonBaseProject
SOURCE_DIR ${COMMON_BASE_PROJECT_DIR}
BINARY_DIR ${COMMON_BASE_PROJECT_DIR}/build
INSTALL_COMMMAND ""
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${COMMON_BASE_PROJECT_DIR}/include)

add_library(
${LIBRARY_NAME}
SHARED
${SRC_FILES}
${INCLUDE_FILES}
)

target_link_libraries (Bios ${COMMON_BASE_PROJECT_DIR}/build/libCommonBase.dll)
add_dependencies(Bios CommonBaseProject)

但我得到错误:
[100%] Linking CXX shared library libCommonBase.dll
[100%] Built target CommonBase
[ 50%] Performing install step for 'CommonBaseProject'
make[3]: *** No rule to make target 'install'. Stop.

我不需要执行安装步骤,所以我的问题是:如何禁用它?

最佳答案

您可以使用STEP_TARGETS build为构建步骤生成目标,并添加对此特定目标的依赖性。步骤目标被命名为<external-project-name>-<step-name>,因此在这种情况下,代表构建步骤的目标将被命名为CommonBaseProject-build

您可能还想通过EXCLUDE_FROM_ALL TRUE从“所有”目标中排除CommonBaseProject。

ExternalProject_Add(CommonBaseProject
SOURCE_DIR ${COMMON_BASE_PROJECT_DIR}
BINARY_DIR ${COMMON_BASE_PROJECT_DIR}/build
STEP_TARGETS build
EXCLUDE_FROM_ALL TRUE
)

add_dependencies(Bios CommonBaseProject-build)

关于cmake - 使用CMake构建外部项目时如何不进行安装步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37838786/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com