Browse Source

... addition to last commit, these were lost.

cl-refactor
sveneh 10 years ago
parent
commit
26d57961b4
  1. 2
      .gitignore
  2. 24
      CMakeLists.txt
  3. 35
      cmake/EthDependenciesDeprecated.cmake
  4. 109
      cmake/FindCryptoPP.cmake
  5. 10
      extdep/CMakeLists.txt
  6. 12
      extdep/cryptopp.cmake
  7. 6
      libdevcrypto/CMakeLists.txt
  8. 24
      libdevcrypto/CryptoPP.h
  9. 4
      libdevcrypto/EC.cpp
  10. 2
      libethcore/CMakeLists.txt
  11. 4
      test/CMakeLists.txt

2
.gitignore

@ -29,7 +29,9 @@ build_xc
*.user.* *.user.*
*~ *~
# build system
build.*/ build.*/
extdep/install
*.pyc *.pyc

24
CMakeLists.txt

@ -42,6 +42,17 @@ function(configureProject)
endfunction() endfunction()
# all dependencies that are not directly included in the cpp-ethereum distribution are defined here
# for this to work, download the dependency via the cmake script in extdep or install them manually!
function(checkExternalDependencies)
set(ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install")
set (CRYPTOPP_ROOT_DIR ${ETH_DEPENDENCY_INSTALL_DIR})
find_package (CryptoPP 5.6.2 REQUIRED)
endfunction()
function(createBuildInfo) function(createBuildInfo)
# Set build platform; to be written to BuildInfo.h # Set build platform; to be written to BuildInfo.h
if (CMAKE_COMPILER_IS_MINGW) if (CMAKE_COMPILER_IS_MINGW)
@ -66,6 +77,8 @@ function(createBuildInfo)
set(SRC_LIST BuildInfo.h) set(SRC_LIST BuildInfo.h)
endfunction() endfunction()
###################################################################################################### ######################################################################################################
@ -88,19 +101,12 @@ if ("${TARGET_PLATFORM}" STREQUAL "linux")
set(CMAKE_THREAD_LIBS_INIT pthread) set(CMAKE_THREAD_LIBS_INIT pthread)
endif () endif ()
# Set default build type to Release w/debug info
# if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
# set(CMAKE_BUILD_TYPE RelWithDebInfo)
# endif()
include(EthCompilerSettings) include(EthCompilerSettings)
message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}") message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}")
#add_definitions("-DETH_BUILD_TYPE=${ETH_BUILD_TYPE}") checkExternalDependencies()
#add_definitions("-DETH_BUILD_PLATFORM=${ETH_BUILD_PLATFORM}")
# TODO this will go away soon!
include(EthDependenciesDeprecated) include(EthDependenciesDeprecated)
createBuildInfo() createBuildInfo()

35
cmake/EthDependenciesDeprecated.cmake

@ -3,45 +3,10 @@
# deprecated. TODO will rewrite to proper CMake packages # deprecated. TODO will rewrite to proper CMake packages
include(ExternalProject)
ExternalProject_Add(project_cryptopp
URL http://www.cryptopp.com/cryptopp562.zip
BINARY_DIR project_cryptopp-prefix/src/project_cryptopp
CONFIGURE_COMMAND ""
BUILD_COMMAND make -j 3
INSTALL_COMMAND ""
)
if("${TARGET_PLATFORM}" STREQUAL "w64") if("${TARGET_PLATFORM}" STREQUAL "w64")
# set(MINIUPNPC_LS /usr/x86_64-w64-mingw32/lib/libminiupnpc.a) # set(MINIUPNPC_LS /usr/x86_64-w64-mingw32/lib/libminiupnpc.a)
set(LEVELDB_LS leveldb) set(LEVELDB_LS leveldb)
set(CRYPTOPP_LS cryptopp)
set(CRYPTOPP_ID /usr/x86_64-w64-mingw32/include/cryptopp)
else() else()
# Look for available Crypto++ version and if it is >= 5.6.2
set(CRYPTOPP_ID ${CMAKE_CURRENT_BINARY_DIR}/project_cryptopp-prefix/src/project_cryptopp)
set(CRYPTOPP_LS cryptopp)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/project_cryptopp-prefix/src/project_cryptopp)
if (ID AND LS)
message(STATUS "Found Crypto++: ${ID}, ${LS}")
set(_CRYPTOPP_VERSION_HEADER ${ID}/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(FATAL_ERROR "Crypto++ version found is smaller than 5.6.2.")
else()
set(CRYPTOPP_ID ${ID} CACHE FILEPATH "")
set(CRYPTOPP_LS ${LS} CACHE FILEPATH "")
message(STATUS "Crypto++ found and version greater or equal to 5.6.2")
endif()
endif()
else()
message(STATUS "Crypto++ Not Found: ${CRYPTOPP_ID}, ${CRYPTOPP_LS}")
endif()
find_path( LEVELDB_ID leveldb/db.h find_path( LEVELDB_ID leveldb/db.h
/usr/include /usr/include

109
cmake/FindCryptoPP.cmake

@ -1,24 +1,25 @@
# Module for locating the CryptoPP encryption library. # Module for locating the Crypto++ encryption library.
# #
# Cutomizable variables: # Customizable variables:
# CRYPTOPP_ROOT_DIR # CRYPTOPP_ROOT_DIR
# This variable points to the CryptoPP root directory. On Windows the # This variable points to the CryptoPP root directory. On Windows the
# library location typically will have to be provided explicitly using the # library location typically will have to be provided explicitly using the
# -D command-line option. The directory should include the include/cryptopp, # -D command-line option. The directory should include the include/cryptopp,
# lib and/or bin sub-directories. # lib and/or bin sub-directories.
# #
# Read-Only variables: # Read-only variables:
# CRYPTOPP_FOUND # CRYPTOPP_FOUND
# Indicates that the library has been found. # Indicates whether the library has been found.
# #
# CRYPTOPP_INCLUDE_DIR # CRYPTOPP_INCLUDE_DIRS
# Points to the CryptoPP include directory. # Points to the CryptoPP include directory.
# #
# CRYPTOPP_LIBRARIES # CRYPTOPP_LIBRARIES
# Points to the CryptoPP libraries that should be passed to # Points to the CryptoPP libraries that should be passed to
# target_link_libararies. # target_link_libararies.
# #
# Copyright (c) 2010-2011 Sergiu Dotenco #
# Copyright (c) 2012 Sergiu Dotenco
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal # of this software and associated documentation files (the "Software"), to deal
@ -40,68 +41,68 @@
INCLUDE (FindPackageHandleStandardArgs) INCLUDE (FindPackageHandleStandardArgs)
SET (_CRYPTOPP_POSSIBLE_DIRS ${CRYPTOPP_ROOT_DIR})
SET (_CRYPTOPP_POSSIBLE_INCLUDE_SUFFIXES include)
SET (_CRYPTOPP_POSSIBLE_LIB_SUFFIXES /lib /lib64)
FIND_PATH (CRYPTOPP_ROOT_DIR FIND_PATH (CRYPTOPP_ROOT_DIR
NAMES include/cryptopp/cryptlib.h NAMES cryptopp/cryptlib.h include/cryptopp/cryptlib.h
PATHS ${_CRYPTOPP_POSSIBLE_DIRS} PATHS ENV CRYPTOPPROOT
DOC "CryptoPP root directory") DOC "CryptoPP root directory")
# Re-use the previous path: # Re-use the previous path:
FIND_PATH (CRYPTOPP_INCLUDE_DIR FIND_PATH (CRYPTOPP_INCLUDE_DIR
NAMES cryptopp/cryptlib.h NAMES cryptopp/cryptlib.h
PATHS ${CRYPTOPP_ROOT_DIR} HINTS ${CRYPTOPP_ROOT_DIR}
PATH_SUFFIXES ${_CRYPTOPP_POSSIBLE_INCLUDE_SUFFIXES} PATH_SUFFIXES include
DOC "CryptoPP include directory") DOC "CryptoPP include directory")
FIND_LIBRARY (CRYPTOPP_LIBRARIES FIND_LIBRARY (CRYPTOPP_LIBRARY_DEBUG
NAMES cryptlib cryptopp libcryptopp NAMES cryptlibd cryptoppd
PATHS /usr/lib HINTS ${CRYPTOPP_ROOT_DIR}
PATH_SUFFIXES "" lib64) PATH_SUFFIXES lib
DOC "CryptoPP debug library")
FIND_LIBRARY (CRYPTOPP_LIBRARY_RELEASE
NAMES cryptlib cryptopp
HINTS ${CRYPTOPP_ROOT_DIR}
PATH_SUFFIXES lib
DOC "CryptoPP release library")
FIND_PACKAGE_HANDLE_STANDARD_ARGS (CryptoPP DEFAULT_MSG CRYPTOPP_INCLUDE_DIR IF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
CRYPTOPP_LIBRARIES) SET (CRYPTOPP_LIBRARY
optimized ${CRYPTOPP_LIBRARY_RELEASE}
debug ${CRYPTOPP_LIBRARY_DEBUG} CACHE DOC "CryptoPP library")
ELSEIF (CRYPTOPP_LIBRARY_RELEASE)
SET (CRYPTOPP_LIBRARY ${CRYPTOPP_LIBRARY_RELEASE} CACHE DOC
"CryptoPP library")
ENDIF (CRYPTOPP_LIBRARY_DEBUG AND CRYPTOPP_LIBRARY_RELEASE)
IF (CRYPTOPP_FOUND) IF (CRYPTOPP_INCLUDE_DIR)
FILE (STRINGS ${CRYPTOPP_INCLUDE_DIR}/cryptopp/config.h SET (_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_INCLUDE_DIR}/cryptopp/config.h)
_CRYPTOPP_VERSION_TMP REGEX "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
STRING (REGEX REPLACE IF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
"^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION_TMP FILE (STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION_TMP REGEX
${_CRYPTOPP_VERSION_TMP}) "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
STRING (REGEX REPLACE "([0-9]+)[0-9][0-9]" "\\1" CRYPTOPP_VERSION_MAJOR STRING (REGEX REPLACE
${_CRYPTOPP_VERSION_TMP}) "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION_TMP
STRING (REGEX REPLACE "[0-9]([0-9])[0-9]" "\\1" CRYPTOPP_VERSION_MINOR ${_CRYPTOPP_VERSION_TMP})
${_CRYPTOPP_VERSION_TMP})
STRING (REGEX REPLACE "[0-9][0-9]([0-9])" "\\1" CRYPTOPP_VERSION_PATCH
${_CRYPTOPP_VERSION_TMP})
SET (CRYPTOPP_VERSION_COUNT 3) STRING (REGEX REPLACE "([0-9]+)[0-9][0-9]" "\\1" CRYPTOPP_VERSION_MAJOR
SET (CRYPTOPP_VERSION ${_CRYPTOPP_VERSION_TMP})
${CRYPTOPP_VERSION_MAJOR}.${CRYPTOPP_VERSION_MINOR}.${CRYPTOPP_VERSION_PATCH}) STRING (REGEX REPLACE "[0-9]([0-9])[0-9]" "\\1" CRYPTOPP_VERSION_MINOR
ENDIF (CRYPTOPP_FOUND) ${_CRYPTOPP_VERSION_TMP})
STRING (REGEX REPLACE "[0-9][0-9]([0-9])" "\\1" CRYPTOPP_VERSION_PATCH
${_CRYPTOPP_VERSION_TMP})
IF (CRYPTOPP_FOUND) SET (CRYPTOPP_VERSION_COUNT 3)
IF (NOT CRYPTOPP_CACHED) SET (CRYPTOPP_VERSION
IF (NOT PACKAGE_FIND_QUIETLY) ${CRYPTOPP_VERSION_MAJOR}.${CRYPTOPP_VERSION_MINOR}.${CRYPTOPP_VERSION_PATCH})
MESSAGE (STATUS "CryptoPP version: ${CRYPTOPP_VERSION}") ENDIF (EXISTS ${_CRYPTOPP_VERSION_HEADER})
ENDIF (NOT PACKAGE_FIND_QUIETLY) ENDIF (CRYPTOPP_INCLUDE_DIR)
SET (CRYPTOPP_CACHED TRUE CACHE INTERNAL "" FORCE) SET (CRYPTOPP_INCLUDE_DIRS ${CRYPTOPP_INCLUDE_DIR})
ENDIF (NOT CRYPTOPP_CACHED) SET (CRYPTOPP_LIBRARIES ${CRYPTOPP_LIBRARY})
ELSE (CRYPTOPP_FOUND)
SET (CRYPTOPP_CACHED FALSE CACHE INTERNAL "" FORCE)
IF (NOT PACKAGE_FIND_QUIETLY) MARK_AS_ADVANCED (CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY CRYPTOPP_LIBRARY_DEBUG
IF (PACKAGE_FIND_REQUIRED) CRYPTOPP_LIBRARY_RELEASE)
MESSAGE (FATAL_ERROR
"CryptoPP required but some files were not found. "
"Specify the CryptPP location using CRYPTOPP_ROOT_DIR")
ENDIF (PACKAGE_FIND_REQUIRED)
ENDIF (NOT PACKAGE_FIND_QUIETLY)
ENDIF (CRYPTOPP_FOUND)
MARK_AS_ADVANCED (CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARIES) FIND_PACKAGE_HANDLE_STANDARD_ARGS (CryptoPP REQUIRED_VARS CRYPTOPP_ROOT_DIR
CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARY VERSION_VAR CRYPTOPP_VERSION)

10
extdep/CMakeLists.txt

@ -1,5 +1,11 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 2.8)
include(ExternalProject)
# dependencies will be installed into this directory
set(ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/install")
include(cryptopp.cmake) include(cryptopp.cmake)
include(miniupnpc.cmake) #include(miniupnpc.cmake)

12
extdep/cryptopp.cmake

@ -1,11 +1,11 @@
include(ExternalProject) ExternalProject_Add(
cryptopp
ExternalProject_Add(cryptopp URL https://github.com/mmoss/cryptopp/archive/v5.6.2.zip
URL http://www.cryptopp.com/cryptopp562.zip
BINARY_DIR cryptopp-prefix/src/cryptopp BINARY_DIR cryptopp-prefix/src/cryptopp
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND make -j 3 BUILD_COMMAND scons --shared --prefix=${ETH_DEPENDENCY_INSTALL_DIR}
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )

6
libdevcrypto/CMakeLists.txt

@ -11,14 +11,14 @@ else()
add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS})
endif() endif()
include_directories(..) include_directories(..)
include_directories(${CRYPTOPP_INCLUDE_DIR})
add_dependencies(${EXECUTABLE} project_cryptopp)
target_link_libraries(${EXECUTABLE} devcore) target_link_libraries(${EXECUTABLE} devcore)
target_link_libraries(${EXECUTABLE} secp256k1) target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} gmp) target_link_libraries(${EXECUTABLE} gmp)
target_link_libraries(${EXECUTABLE} ${LEVELDB_LS}) target_link_libraries(${EXECUTABLE} ${LEVELDB_LS})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS}) target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LIBRARIES})
if("${TARGET_PLATFORM}" STREQUAL "w64") if("${TARGET_PLATFORM}" STREQUAL "w64")
target_link_libraries(${EXECUTABLE} boost_system-mt-s) target_link_libraries(${EXECUTABLE} boost_system-mt-s)

24
libdevcrypto/CryptoPP.h

@ -33,18 +33,18 @@
#pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor" #pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wextra"
#include <sha.h> #include <cryptopp/sha.h>
#include <sha3.h> #include <cryptopp/sha3.h>
#include <ripemd.h> #include <cryptopp/ripemd.h>
#include <aes.h> #include <cryptopp/aes.h>
#include <pwdbased.h> #include <cryptopp/pwdbased.h>
#include <modes.h> #include <cryptopp/modes.h>
#include <filters.h> #include <cryptopp/filters.h>
#include <eccrypto.h> #include <cryptopp/eccrypto.h>
#include <ecp.h> #include <cryptopp/ecp.h>
#include <files.h> #include <cryptopp/files.h>
#include <osrng.h> #include <cryptopp/osrng.h>
#include <oids.h> #include <cryptopp/oids.h>
#include <secp256k1/secp256k1.h> #include <secp256k1/secp256k1.h>
#pragma warning(pop) #pragma warning(pop)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

4
libdevcrypto/EC.cpp

@ -14,7 +14,8 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file EC.cpp /**
* @file EC.cpp
* @author Alex Leverington <nessence@gmail.com> * @author Alex Leverington <nessence@gmail.com>
* @date 2014 * @date 2014
* *
@ -29,7 +30,6 @@
#pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor" #pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
#pragma GCC diagnostic ignored "-Wextra" #pragma GCC diagnostic ignored "-Wextra"
#include <files.h>
#pragma warning(pop) #pragma warning(pop)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#include "CryptoPP.h" #include "CryptoPP.h"

2
libethcore/CMakeLists.txt

@ -12,13 +12,13 @@ else()
endif() endif()
include_directories(..) include_directories(..)
include_directories(${CRYPTOPP_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE} devcrypto) target_link_libraries(${EXECUTABLE} devcrypto)
target_link_libraries(${EXECUTABLE} devcore) target_link_libraries(${EXECUTABLE} devcore)
target_link_libraries(${EXECUTABLE} secp256k1) target_link_libraries(${EXECUTABLE} secp256k1)
target_link_libraries(${EXECUTABLE} gmp) target_link_libraries(${EXECUTABLE} gmp)
target_link_libraries(${EXECUTABLE} ${LEVELDB_LS}) target_link_libraries(${EXECUTABLE} ${LEVELDB_LS})
target_link_libraries(${EXECUTABLE} ${CRYPTOPP_LS})
if("${TARGET_PLATFORM}" STREQUAL "w64") if("${TARGET_PLATFORM}" STREQUAL "w64")
target_link_libraries(${EXECUTABLE} boost_system-mt-s) target_link_libraries(${EXECUTABLE} boost_system-mt-s)

4
test/CMakeLists.txt

@ -14,10 +14,10 @@ target_link_libraries(testeth ethcore)
target_link_libraries(testeth secp256k1) target_link_libraries(testeth secp256k1)
target_link_libraries(testeth gmp) target_link_libraries(testeth gmp)
target_link_libraries(testeth solidity) target_link_libraries(testeth solidity)
target_link_libraries(testeth ${CRYPTOPP_LS}) target_link_libraries(testeth ${CRYPTOPP_LIBRARIES})
target_link_libraries(testeth webthree) target_link_libraries(testeth webthree)
if(JSONRPC_LS) if(JSONRPC_LS)
target_link_libraries(testeth web3jsonrpc) target_link_libraries(testeth web3jsonrpc)
endif() endif()
target_link_libraries(createRandomTest ethereum) target_link_libraries(createRandomTest ethereum)

Loading…
Cancel
Save