Reputation:
I've installed C++ library "Crypto++" using sudo apt install libcrypto++-dev
I find lib using this command: find_package(CryptoPP REQUIRED)
But CMake cant find it for some reason, and print this error:
CMake Error at CMakeLists.txt:40 (find_package):
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.
I also tried all names like CryptoPP, and etc. It didnt work.
Upvotes: 1
Views: 2120
Reputation: 30807
Three seconds of googling shows that the CryptoPP folks decided to stop supporting CMake themselves.
The community-supported CMake build stuff is now here. As the build instructions go, fetch it and then you can link your target(s) to cryptopp
.
Alternatively, you can try your luck with the pkgconfig file that seems to ship with that package:
find_package(PkgConfig REQUIRED)
pkg_check_modules(Cryptopp REQUIRED IMPORTED_TARGET libcrypto++)
target_link_libraries(your_application PUBLIC PkgConfig::Cryptopp)
If you use macOS' homebrew package manager, the package is named libcryptopp
instead, so the pkg_check_modules
line needs to change accordingly.
Upvotes: 4
Reputation: 307
For those who are having trouble using the first answer. A possible solution for CMake, which works both on Linux (sudo apt-get install libcrypto++-dev libcrypto++-doc libcrypto++-utils
), and on MacOS (brew install cryptopp
):
find_path(CRYPTOPP_INCLUDE cryptopp/cryptlib.h /usr/include /usr/local/include /opt/homebrew/include)
find_library(CRYPTOPP_LIB cryptopp /usr/lib /usr/local/lib /opt/homebrew/lib)
if(NOT CRYPTOPP_INCLUDE OR NOT CRYPTOPP_LIB)
message(FATAL_ERROR "Crypto++ library is not found!")
endif()
add_executable(Target ...)
target_link_libraries(Target PRIVATE ${CRYPTOPP_LIB})
target_include_directories(Target PRIVATE ${CRYPTOPP_INCLUDE})
Upvotes: 0