1 # Module for locating the Crypto++ encryption library.
3 # Customizable variables:
5 # This variable points to the CryptoPP root directory. On Windows the
6 # library location typically will have to be provided explicitly using the
7 # -D command-line option. The directory should include the include/cryptopp,
8 # lib and/or bin sub-directories.
10 # Read-only variables:
12 # Indicates whether the library has been found.
14 # CRYPTOPP_INCLUDE_DIRS
15 # Points to the CryptoPP include directory.
18 # Points to the CryptoPP libraries that should be passed to
19 # target_link_libararies.
22 # Copyright (c) 2012 Sergiu Dotenco
24 # Permission is hereby granted, free of charge, to any person obtaining a copy
25 # of this software and associated documentation files (the "Software"), to deal
26 # in the Software without restriction, including without limitation the rights
27 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28 # copies of the Software, and to permit persons to whom the Software is
29 # furnished to do so, subject to the following conditions:
31 # The above copyright notice and this permission notice shall be included in all
32 # copies or substantial portions of the Software.
34 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42 INCLUDE (FindPackageHandleStandardArgs)
44 FIND_PATH (CRYPTOPP_ROOT_DIR
45 NAMES cryptopp/cryptlib.h include/cryptopp/cryptlib.h
46 PATHS ENV CRYPTOPPROOT
47 DOC "CryptoPP root directory")
49 # Re-use the previous path:
50 FIND_PATH (CRYPTOPP_INCLUDE_DIR
51 NAMES cryptopp/cryptlib.h
52 HINTS ${CRYPTOPP_ROOT_DIR}
54 DOC "CryptoPP include directory")
56 FIND_LIBRARY (CRYPTOPP_LIBRARY_DEBUG
57 NAMES cryptlibd cryptoppd
58 HINTS ${CRYPTOPP_ROOT_DIR}
60 DOC "CryptoPP debug library")
62 FIND_LIBRARY (CRYPTOPP_LIBRARY_RELEASE
63 NAMES cryptlib cryptopp
64 HINTS ${CRYPTOPP_ROOT_DIR}
66 DOC "CryptoPP release library")
68 IF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
70 optimized ${CRYPTOPP_LIBRARY_RELEASE}
71 debug ${CRYPTOPP_LIBRARY_DEBUG} CACHE DOC "CryptoPP library")
72 ELSEIF (CRYPTOPP_LIBRARY_RELEASE)
73 SET (CRYPTOPP_LIBRARY ${CRYPTOPP_LIBRARY_RELEASE} CACHE DOC
75 ENDIF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
77 IF (CRYPTOPP_INCLUDE_DIR)
78 SET (_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_INCLUDE_DIR}/cryptopp/config.h)
80 IF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
81 FILE (STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION_TMP REGEX
82 "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
85 "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION_TMP
86 ${_CRYPTOPP_VERSION_TMP})
88 STRING (REGEX REPLACE "([0-9]+)[0-9][0-9]" "\\1" CRYPTOPP_VERSION_MAJOR
89 ${_CRYPTOPP_VERSION_TMP})
90 STRING (REGEX REPLACE "[0-9]([0-9])[0-9]" "\\1" CRYPTOPP_VERSION_MINOR
91 ${_CRYPTOPP_VERSION_TMP})
92 STRING (REGEX REPLACE "[0-9][0-9]([0-9])" "\\1" CRYPTOPP_VERSION_PATCH
93 ${_CRYPTOPP_VERSION_TMP})
95 SET (CRYPTOPP_VERSION_COUNT 3)
97 ${CRYPTOPP_VERSION_MAJOR}.${CRYPTOPP_VERSION_MINOR}.${CRYPTOPP_VERSION_PATCH})
98 ENDIF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
99 ENDIF (CRYPTOPP_INCLUDE_DIR)
101 SET (CRYPTOPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIR})
102 SET (CRYPTOPP_LIBRARIES ${CRYPTOPP_LIBRARY})
104 MARK_AS_ADVANCED (CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY CRYPTOPP_LIBRARY_DEBUG
105 CRYPTOPP_LIBRARY_RELEASE)
107 FIND_PACKAGE_HANDLE_STANDARD_ARGS (cryptopp REQUIRED_VARS CRYPTOPP_ROOT_DIR
108 CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY VERSION_VAR CRYPTOPP_VERSION)