1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-25 00:53:43 +00:00
dindexer/cmake/Modules/FindCryptoPP.cmake

137 lines
4 KiB
CMake
Raw Normal View History

# Module for locating the Crypto++ encryption library.
#
# Customizable variables:
# CryptoPP_ROOT_DIR
# This variable points to the CryptoPP root directory. On Windows the
# library location typically will have to be provided explicitly using the
# -D command-line option. The directory should include the include/cryptopp,
# lib and/or bin sub-directories.
#
# Read-only variables:
# CryptoPP_FOUND
# Indicates whether the library has been found.
#
# CryptoPP_INCLUDE_DIRS
# Points to the CryptoPP include directory.
#
# CryptoPP_LIBRARIES
# Points to the CryptoPP libraries that should be passed to
# target_link_libararies.
#
#
# Copyright (c) 2012 Sergiu Dotenco
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
INCLUDE (FindPackageHandleStandardArgs)
2016-06-20 17:50:15 +00:00
FIND_PATH (
CryptoPP_ROOT_DIR
2016-06-20 17:50:15 +00:00
NAMES cryptopp/cryptlib.h include/cryptopp/cryptlib.h
PATHS ENV CRYPTOPPROOT
DOC "CryptoPP root directory"
)
# Re-use the previous path:
2016-06-20 17:50:15 +00:00
FIND_PATH (
CRYPTOPP_INCLUDE_DIR
NAMES cryptopp/cryptlib.h
HINTS ${CryptoPP_ROOT_DIR}
2016-06-20 17:50:15 +00:00
PATH_SUFFIXES include
DOC "CryptoPP include directory"
)
2016-06-20 17:50:15 +00:00
FIND_LIBRARY (
CRYPTOPP_LIBRARY_DEBUG
NAMES cryptlibd cryptoppd
HINTS ${CryptoPP_ROOT_DIR}
2016-06-20 17:50:15 +00:00
PATH_SUFFIXES lib
DOC "CryptoPP debug library"
)
2016-06-20 17:50:15 +00:00
FIND_LIBRARY (
CRYPTOPP_LIBRARY_RELEASE
NAMES cryptlib cryptopp
HINTS ${CryptoPP_ROOT_DIR}
2016-06-20 17:50:15 +00:00
PATH_SUFFIXES lib
DOC "CryptoPP release library"
)
IF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
2016-06-20 17:50:15 +00:00
SET (
CRYPTOPP_LIBRARY
optimized ${CRYPTOPP_LIBRARY_RELEASE}
debug ${CRYPTOPP_LIBRARY_DEBUG} CACHE DOC "CryptoPP library"
)
ELSEIF (CRYPTOPP_LIBRARY_RELEASE)
2016-06-20 17:50:15 +00:00
SET (
CRYPTOPP_LIBRARY ${CRYPTOPP_LIBRARY_RELEASE} CACHE DOC
"CryptoPP library"
)
ENDIF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
IF (CRYPTOPP_INCLUDE_DIR)
2016-06-20 17:50:15 +00:00
SET (_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_INCLUDE_DIR}/cryptopp/config.h)
2016-06-20 17:50:15 +00:00
IF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
FILE (
STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION_TMP REGEX
"^#define CRYPTOPP_VERSION[ \t]+[0-9]+$"
)
2016-06-20 17:50:15 +00:00
STRING (
REGEX REPLACE
"^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION_TMP
${_CRYPTOPP_VERSION_TMP}
)
2016-06-20 17:50:15 +00:00
STRING (
REGEX REPLACE "([0-9]+)[0-9][0-9]" "\\1" CRYPTOPP_VERSION_MAJOR
${_CRYPTOPP_VERSION_TMP}
)
STRING (
REGEX REPLACE "[0-9]([0-9])[0-9]" "\\1" CRYPTOPP_VERSION_MINOR
${_CRYPTOPP_VERSION_TMP}
)
STRING (
REGEX REPLACE "[0-9][0-9]([0-9])" "\\1" CRYPTOPP_VERSION_PATCH
${_CRYPTOPP_VERSION_TMP}
)
2016-06-20 17:50:15 +00:00
SET (CRYPTOPP_VERSION_COUNT 3)
SET (
CRYPTOPP_VERSION
${CRYPTOPP_VERSION_MAJOR}.${CRYPTOPP_VERSION_MINOR}.${CRYPTOPP_VERSION_PATCH}
)
ENDIF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
ENDIF (CRYPTOPP_INCLUDE_DIR)
SET (CryptoPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIR})
SET (CryptoPP_LIBRARIES ${CRYPTOPP_LIBRARY})
2016-06-20 17:50:15 +00:00
MARK_AS_ADVANCED (
CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY CRYPTOPP_LIBRARY_DEBUG
CRYPTOPP_LIBRARY_RELEASE
)
2016-06-20 17:50:15 +00:00
FIND_PACKAGE_HANDLE_STANDARD_ARGS (
CryptoPP REQUIRED_VARS CryptoPP_ROOT_DIR
2016-06-20 17:50:15 +00:00
CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY VERSION_VAR CRYPTOPP_VERSION
)