Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Auto detect Crypto++ version available #9

@danielbartz

Description

@danielbartz

On FC20 cryptopp version 5.6.2 is available from the default repository. Would be great to use it.

Here is a patch to autodetect if Crypto++ is available with the correct version. Would be nice if you could merge it (feel free to adapt it if required)

diff -urpN cpp-ethereum-ORIG/CMakeLists.txt cpp-ethereum/CMakeLists.txt --- cpp-ethereum-ORIG/CMakeLists.txt 2014-02-01 22:02:33.648000000 +0100 +++ cpp-ethereum/CMakeLists.txt 2014-02-01 22:02:44.480000000 +0100 @@ -23,6 +23,53 @@ else () message(FATAL_ERROR "Your C++ compiler does not support C++11.") endif () +# Look for availabe Crypto++ version and if it is >= 5.6.2 +if(CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARIES) + set(CRYPTOPP_FOUND TRUE) + message(STATUS "Found Crypto++: ${CRYPTOPP_INCLUDE_DIR}, ${CRYPTOPP_LIBRARIES}") +else() + find_path(CRYPTOPP_INCLUDE_DIR cryptlib.h + /usr/include/crypto++ + /usr/include/cryptopp + /usr/local/include/crypto++ + /usr/local/include/cryptopp + /opt/local/include/crypto++ + /opt/local/include/cryptopp + ) + find_library(CRYPTOPP_LIBRARIES NAMES cryptopp + PATHS + /usr/lib + /usr/local/lib + /opt/local/lib + ) + if(CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARIES) + set(CRYPTOPP_FOUND TRUE) + message(STATUS "Found Crypto++: ${CRYPTOPP_INCLUDE_DIR}, ${CRYPTOPP_LIBRARIES}") + set(_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_INCLUDE_DIR}/config.h) + if(EXISTS ${_CRYPTOPP_VERSION_HEADER}) + file(STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION REGEX "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION ${_CRYPTOPP_VERSION}) + if(${_CRYPTOPP_VERSION} LESS 562) + message(STATUS "Crypto++ version found is smaller than 5.6.2. We use ../cryptopp562") + set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE) + set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE) + else() + message(STATUS "Crypto++ found and version greater or equal to 5.6.2") + endif() + endif() + else() + set(CRYPTOPP_FOUND TRUE) # Ugly + message(STATUS "Crypto++ not found. We use ../cryptopp562") + set(CRYPTOPP_INCLUDE_DIR "../cryptopp562" CACHE FILEPATH "" FORCE) + set(CRYPTOPP_LIBRARIES "../cryptopp562" CACHE FILEPATH "" FORCE) + endif() + mark_as_advanced(CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARIES) +endif() + +if(CRYPTOPP_FOUND) + include_directories(${CRYPTOPP_INCLUDE_DIR}) +endif() + add_subdirectory(libethereum) add_subdirectory(test) add_subdirectory(eth) diff -urpN cpp-ethereum-ORIG/eth/CMakeLists.txt cpp-ethereum/eth/CMakeLists.txt --- cpp-ethereum-ORIG/eth/CMakeLists.txt 2014-02-01 22:02:33.647000000 +0100 +++ cpp-ethereum/eth/CMakeLists.txt 2014-02-01 22:02:53.938000000 +0100 @@ -5,9 +5,6 @@ aux_source_directory(. SRC_LIST) include_directories(../../secp256k1/include) link_directories(../../secp256k1) -include_directories(../../cryptopp562) -link_directories(../../cryptopp562) - include_directories(../libethereum) link_directories(../libethereum) diff -urpN cpp-ethereum-ORIG/libethereum/CMakeLists.txt cpp-ethereum/libethereum/CMakeLists.txt --- cpp-ethereum-ORIG/libethereum/CMakeLists.txt 2014-02-01 22:02:33.642000000 +0100 +++ cpp-ethereum/libethereum/CMakeLists.txt 2014-02-01 22:03:00.918000000 +0100 @@ -3,9 +3,6 @@ cmake_policy(SET CMP0015 NEW) include_directories(../../secp256k1/include) link_directories(../../secp256k1) -include_directories(../../cryptopp562) -link_directories(../../cryptopp562) - aux_source_directory(. SRC_LIST) add_library(ethereum ${SRC_LIST}) diff -urpN cpp-ethereum-ORIG/test/CMakeLists.txt cpp-ethereum/test/CMakeLists.txt --- cpp-ethereum-ORIG/test/CMakeLists.txt 2014-02-01 22:02:33.647000000 +0100 +++ cpp-ethereum/test/CMakeLists.txt 2014-02-01 22:03:07.475000000 +0100 @@ -5,9 +5,6 @@ aux_source_directory(. SRC_LIST) include_directories(../../secp256k1/include) link_directories(../../secp256k1) -include_directories(../../cryptopp562) -link_directories(../../cryptopp562) - include_directories(../libethereum) link_directories(../libethereum) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions