我正在使用cmake v3.13,我想将我ExternalProject_Add()
的SEAL库更改为:
include(FetchContent)
# Get the seal library
set(SEAL "seal")
FetchContent_Declare(
${SEAL}
GIT_REPOSITORY https://github.com/microsoft/SEAL
GIT_TAG v3.5.2
)
FetchContent_GetProperties(${SEAL})
if(NOT ${SEAL}_POPULATED)
FetchContent_Populate(${SEAL})
add_subdirectory(${${SEAL}_SOURCE_DIR} ${${SEAL}_BINARY_DIR})
endif()
当我使用时,ExternalProject_Add()
我已经使用过CMAKE_ARGS -DBUILD_SHARED_LIBS=ON
,这不适FetchContent_Declare()
用于仅下载库。
SEAL v3.5.2 CMakeLists.txt使用它来检查是否需要构建共享库:
# Should we build also the shared library?
set(BUILD_SHARED_LIBS_STR "Build shared library")
option(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_STR} OFF)
if(MSVC AND BUILD_SHARED_LIBS)
message(WARNING "This build system only supports a static build; disabling `BUILD_SHARED_LIBS`")
set(BUILD_SHARED_LIBS OFF CACHE BOOL ${BUILD_SHARED_LIBS_STR} FORCE)
endif()
# Conditionally build the shared library
if(BUILD_SHARED_LIBS)
add_library(seal_shared SHARED $<TARGET_OBJECTS:seal_obj>)
set_target_properties(seal_shared PROPERTIES OUTPUT_NAME seal)
seal_set_version(seal_shared)
seal_set_soversion(seal_shared)
seal_set_language(seal_shared)
seal_set_include_directories(seal_shared)
seal_link_threads(seal_shared)
# Conditionally add MSGSL include directory to build interface
if(SEAL_USE_MSGSL AND NOT MSVC)
target_include_directories(seal_shared PUBLIC $<BUILD_INTERFACE:${MSGSL_INCLUDE_DIR}>)
endif()
if(SEAL_USE_ZLIB AND NOT MSVC)
# In the shared build we link zlibstatic into the shared library
target_link_libraries(seal_shared PRIVATE zlibstatic)
endif()
seal_install_target(seal_shared SEALTargets)
endif()
有没有办法下载SEAL库FetchContent_Declare()
,然后在构建它时使用一些CMakeLists设置将CMAKE_ARGS -DBUILD_SHARED_LIBS=ON
参数传递给下载的库?