8

I am trying to specify the Crypto++ library in my CMakeLists file but I always get an error.

Here is my CMakeLists file:

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})

And here is the errors I get:

 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!

Thank you for your help!

jww
  • 97,681
  • 90
  • 411
  • 885
Omar Lahlou
  • 1,000
  • 9
  • 33
  • 1
    If you get something put together to make this easier on folks in the future, then please share it at [Crypto++ Users](https://groups.google.com/forum/#!forum/cryptopp-users). Once its vetted, I can make sure it gets a page at [Crypto++ Patches](http://www.cryptopp.com/wiki/Category:Patch). – jww Apr 16 '15 at 17:13

1 Answers1

5

CMake doesn't have a module for the Crypto++ library in the package so you have to provide your own. You can try the following(I've used it once) or google for the "Find CryptoPP cmake".

When you are done with the file, place it somewhere and point CMake to search for the file in that location. Suppose you have placed it under your sources directory in contrib/cmake subfolder, then CMake code will be:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/contrib/cmake")

So you set the path for the modules search now you need to use find_package, note, however, that you should provide the package name in the same fashion your .cmake file is named. For example, if you have CryptoPP.cmake, then you should put the following:

find_package ( CryptoPP REQUIRED )
ixSci
  • 13,100
  • 5
  • 45
  • 79
  • Is `set(CMAKE_MODULE_PATH ...)` and `find_package (CryptoPP REQUIRED)` all that's needed here? I feel like there should be a file list and `CXXFLAGS` to accompany them. But I don't know Cmake, so I might be wrong. – jww Apr 20 '15 at 08:37
  • @jww, It's all that is required for the Crypto++ CMake search setup. Later, when a package is found one has to use some variables(depends on the `cmake` file used to find it) to let the target build system know about it(where to search for the headers, what lib to link etc.). – ixSci Apr 20 '15 at 09:15
  • 2
    @jww, if you used the cmake file referenced in my answer you'd have to include the directory for the headers like this: `include_directories(${CRYPTOPP_INCLUDE_DIRS})` and provide the library for the linking likes this: `target_link_libraries( ${CRYPTOPP_LIBRARIES})` – ixSci Apr 20 '15 at 09:19
  • 1
    *"if you used the cmake file referenced in my answer..."* - no, I did not follow it. If its important, then you should include it in your answer. I rarely follow the offsite links that showup on Stack Overflow. Its too risky, especially if a 0-day is in the wild (and Webkit has plenty of them...). – jww Apr 20 '15 at 09:23
  • @jww, it's just an example of a cmake file. It is not important per se since there is no "standard" cmake file for the task. And since one might choose a different file the variable names might be different. The steps would be the same, tnough. – ixSci Apr 20 '15 at 09:26
  • @jww, btw, the link is to bitbucket. There is nothing to be afraid of ;) – ixSci Apr 20 '15 at 09:27
  • Sorry to revisit this... We are updating Crypto++ at the moment. If you can provide a `CmakeList.txt` to build the library, it would be appreciated. You can contact me at noloader, gmail address. – jww Jun 08 '15 at 10:57
  • @jww, you need help with providing CMake file for building Crypto++ or for creating file which users later will use for searching of Crypto++ on their machines? I can help with the former but not with the latter. – ixSci Jun 08 '15 at 11:14