在CMakeLists文件中指定Crypto ++库

Oma*_*lou 6 c++ makefile cmake crypto++

我试图在我的CMakeLists文件中指定Crypto ++库,但我总是收到错误.

这是我的CMakeLists档案:

cmake_minimum_required(VERSION 2.8)
project( Recognition )
find_package( OpenCV REQUIRED )
find_package ( CURL REQUIRED )
find_package ( CRYPTOPP REQUIRED )
add_executable( Recognition Recognition.cpp )
target_link_libraries( Recognition ${OpenCV_LIBS} ${CURL_LIBRARY} ${CRYPTOPP_LIBRARY})
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

 By not providing "FindCRYPTOPP.cmake" in CMAKE_MODULE_PATH this project has
 asked CMake to find a package configuration file provided by "CRYPTOPP",
 but CMake did not find one.

 Could not find a package configuration file provided by "CRYPTOPP" with any
 of the following names:

 CRYPTOPPConfig.cmake
 cryptopp-config.cmake

 Add the installation prefix of "CRYPTOPP" to CMAKE_PREFIX_PATH or set
 "CRYPTOPP_DIR" to a directory containing one of the above files.  If
 "CRYPTOPP" provides a separate development package or SDK, be sure it has
 been installed.

 -- Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!

ixS*_*Sci 5

CMake在包中没有Crypto ++库的模块,因此您必须提供自己的模块.您可以尝试以下(我已经使用过一次)或谷歌搜索"查找CryptoPP cmake".

完成文件后,将其放在某处并指向CMake以搜索该位置的文件.假设您已将其放在contrib/cmake子文件夹中的sources目录下,那么CMake代码将为:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/contrib/cmake")
Run Code Online (Sandbox Code Playgroud)

因此,您现在需要设置模块搜索的路径find_package,但请注意,您应该以与.cmake文件命名相同的方式提供软件包名称.例如,如果你有CryptoPP.cmake,那么你应该把以下内容:

find_package ( CryptoPP REQUIRED )
Run Code Online (Sandbox Code Playgroud)

  • @jww,如果您使用我的答案中引用的cmake文件,您必须包含这样的标题目录:`include_directories($ {CRYPTOPP_INCLUDE_DIRS})`并提供链接库,如下所示:`target_link_libraries(< target> <other libs> $ {CRYPTOPP_LIBRARIES})` (2认同)