【发布时间】:2020-12-21 16:34:53
【问题描述】:
我正在使用 Clion 并且我正尝试在我的 CMakeLists.txt 文件中使用 cryptopp-cmake 作为 cryptopp,因为 Cryptopp 在其默认项目存储库中没有 CMakeLists.txt 文件。我的 CMakeLists.txt 有这个 Cryptopp 相关内容:
# Include usage of external projects
include(FetchContent)
# Get the cryptopp CMakeLists.txt file for cryptopp package
set(CRYPTOPP_CMAKE "cryptopp-cmake")
FetchContent_Declare(
${CRYPTOPP_CMAKE}
GIT_REPOSITORY https://github.com/noloader/cryptopp-cmake
GIT_TAG CRYPTOPP_8_2_0
)
FetchContent_GetProperties(${CRYPTOPP_CMAKE})
if(NOT ${CRYPTOPP_CMAKE}_POPULATED)
FetchContent_Populate(${CRYPTOPP_CMAKE})
endif()
# Get the cryptopp package
set(CRYPTOPP "cryptopp")
FetchContent_Declare(
${CRYPTOPP}
GIT_REPOSITORY https://github.com/weidai11/cryptopp
GIT_TAG CRYPTOPP_8_2_0
)
FetchContent_GetProperties(${CRYPTOPP})
if(NOT ${CRYPTOPP}_POPULATED)
FetchContent_Populate(${CRYPTOPP})
endif()
# !!! IMORTANT !!! before using add_subdirectory(), include_directories() and set(CRYPTOPP_LIB....) commands.
file(COPY ${${CRYPTOPP_CMAKE}_SOURCE_DIR}/CMakeLists.txt DESTINATION ${${CRYPTOPP}_SOURCE_DIR})
add_subdirectory(${${CRYPTOPP}_SOURCE_DIR} ${${CRYPTOPP}_BINARY_DIR})
include_directories(${${CRYPTOPP}_SOURCE_DIR})
set(CRYPTOPP_LIB ${${CRYPTOPP}_BINARY_DIR}/libcryptopp.so)
# Link the project libraries to the executable
target_link_libraries(hmmenc-client PRIVATE
${CRYPTOPP_LIB}
)
当我让它在 CLion 中运行时,CMakeLists.txt 会按原样复制,但我收到错误 *** No rule to make target '_deps/cryptopp-build/libcryptopp.so', needed by '../hmmenc_client/bin/hmmenc-client'. Stop.。
尽管成功复制了 CMakeLists.txt,但在第一次运行时没有生成 libcryptopp.so 文件,不幸的是,我需要使用“重建项目” CLion 中的选项,用于生成 libcryptopp.so 并填充 ${CRYPTOPP_LIB} 变量。
是否有一种方法可以使 Cryptopp's CMakeLists.txt 文件在第一次运行时影响我的构建并生成 libcryptopp.so 文件?
【问题讨论】:
-
您可以考虑在 GitHub 上填写问题,以便作者(活跃的社区 contributor)可以提供见解和/或修复。