From f7c44f38661a16dde03e5831a5ecc192bfefbf6a Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 8 Dec 2014 13:55:54 +0100 Subject: [PATCH] project working on mac, FindGmp.cmake && couple of todos --- cmake/EthDependencies.cmake | 29 +++++++++++++++++++++-------- cmake/FindGmp.cmake | 32 ++++++++++++++++++++++++++++++++ cmake/FindLevelDB.cmake | 2 +- libethereum/CMakeLists.txt | 7 ++++--- secp256k1/CMakeLists.txt | 33 +++++++++++++++++++++++---------- 5 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 cmake/FindGmp.cmake diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index d7542e364..7b756c3d5 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -6,7 +6,12 @@ string(TOLOWER ${CMAKE_SYSTEM_NAME} _system_name) set (CMAKE_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}") set (CMAKE_PREFIX_PATH ${CMAKE_DEPENDENCY_INSTALL_DIR}) -if (WIN32) + +# Qt5 requires opengl +# TODO use proper version of windows SDK (32 vs 64) +# TODO make it possible to use older versions of windows SDK (7.0+ should also work) +# TODO it windows SDK is NOT FOUND, throw ERROR +if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") set (CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "C:/Program Files/Windows Kits/8.1/Lib/winv6.3/um/x86") #set (CMAKE_PREFIX_PATH "C:/Program Files/Windows Kits/8.1/Lib/winv6.3/um/x64") endif() @@ -28,6 +33,7 @@ message(" - Jsoncpp lib : ${JSONCPP_LIBRARIES}") # TODO the JsonRpcCpp package does not yet check for correct version number # json-rpc-cpp support is currently not mandatory +# TODO make headless client optional find_package (JsonRpcCpp 0.3.2) if (${JSON_RPC_CPP_FOUND}) message (" - json-rpc-cpp header: ${JSON_RPC_CPP_INCLUDE_DIRS}") @@ -35,6 +41,13 @@ if (${JSON_RPC_CPP_FOUND}) add_definitions(-DETH_JSONRPC) endif() +# TODO gmp package does not yet check for correct version number +# TODO it is also not required in msvc build +find_package (Gmp 6.0.0) +message(" - Gmp Header: ${GMP_INCLUDE_DIR}") +message(" - Gmp lib : ${GMP_LIBRARY}") + +# TODO make headless client optional find_package (QT5Core REQUIRED) find_package (QT5Gui REQUIRED) find_package (Qt5Quick REQUIRED) @@ -46,18 +59,18 @@ find_package (Qt5WebKitWidgets REQUIRED) # we have to specify here if we want static and boost version, that is really important - -# win32 msvc 2013 boost set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) -set(Boost_COMPILER -vc120) + +# TODO hanlde other msvc versions or it will fail find them +if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") + set(Boost_COMPILER -vc120) +endif() find_package(Boost 1.55.0 REQUIRED COMPONENTS thread date_time system regex chrono filesystem) -if (Boost_FOUND) - message(" - boost header: ${Boost_INCLUDE_DIRS}") - message(" - boost lib : ${Boost_LIBRARIES}") -endif() +message(" - boost header: ${Boost_INCLUDE_DIRS}") +message(" - boost lib : ${Boost_LIBRARIES}") diff --git a/cmake/FindGmp.cmake b/cmake/FindGmp.cmake new file mode 100644 index 000000000..908499865 --- /dev/null +++ b/cmake/FindGmp.cmake @@ -0,0 +1,32 @@ +# Find gmp +# +# Find the gmp includes and library +# +# if you nee to add a custom library search path, do it via via CMAKE_FIND_ROOT_PATH +# +# This module defines +# GMP_INCLUDE_DIR, where to find header, etc. +# GMP_LIBRARY, the libraries needed to use leveldb. +# GMP_FOUND, If false, do not try to use leveldb. + +# only look in default directories +find_path( + GMP_INCLUDE_DIR + NAMES gmp.h + DOC "gmp include dir" + ) + +find_library( + GMP_LIBRARY + NAMES gmp + DOC "gmp library" + ) + + +# handle the QUIETLY and REQUIRED arguments and set GMP_FOUND to TRUE +# if all listed variables are TRUE, hide their existence from configuration view +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(gmp DEFAULT_MSG + GMP_INCLUDE_DIR GMP_LIBRARY) +mark_as_advanced (GMP_INCLUDE_DIR GMP_LIBRARY) + diff --git a/cmake/FindLevelDB.cmake b/cmake/FindLevelDB.cmake index 770c9e65f..26629d35f 100644 --- a/cmake/FindLevelDB.cmake +++ b/cmake/FindLevelDB.cmake @@ -26,7 +26,7 @@ find_library( # message (" - leveldb lib : ${LEVELDB_LIBRARY}") -# handle the QUIETLY and REQUIRED arguments and set JSON_RPC_CPP_FOUND to TRUE +# handle the QUIETLY and REQUIRED arguments and set LEVELDB_FOUND to TRUE # if all listed variables are TRUE, hide their existence from configuration view include(FindPackageHandleStandardArgs) find_package_handle_standard_args(leveldb DEFAULT_MSG diff --git a/libethereum/CMakeLists.txt b/libethereum/CMakeLists.txt index de750fdb8..e9904e9a8 100644 --- a/libethereum/CMakeLists.txt +++ b/libethereum/CMakeLists.txt @@ -5,6 +5,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) +include_directories(${LEVELDB_INCLUDE_DIR}) +include_directories(..) + set(EXECUTABLE ethereum) file(GLOB HEADERS "*.h") @@ -15,10 +18,8 @@ else() add_library(${EXECUTABLE} SHARED ${SRC_LIST} ${HEADERS}) endif() -include_directories(${LEVELDB_INCLUDE_DIR}) -include_directories(..) - target_link_libraries(${EXECUTABLE} ${LEVELDB_LIBRARY}) +target_link_libraries(${EXECUTABLE} ${Boost_REGEX_LIBRARY_RELEASE}) if (MINIUPNPC_LS) target_link_libraries(${EXECUTABLE} ${MINIUPNPC_LS}) diff --git a/secp256k1/CMakeLists.txt b/secp256k1/CMakeLists.txt index baa58e7e8..f02bba238 100644 --- a/secp256k1/CMakeLists.txt +++ b/secp256k1/CMakeLists.txt @@ -3,19 +3,32 @@ set(CMAKE_AUTOMOC OFF) set(CMAKE_ASM_COMPILER "yasm") -include_directories(${Boost_INCLUDE_DIRS}) - set(EXECUTABLE secp256k1) - file(GLOB HEADERS "*.h") -if(ETH_STATIC) - add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c) -else() - add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c) -endif() -set_target_properties(${EXECUTABLE} PROPERTIES COMPILE_FLAGS "/TP") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_NUM_BOOST -DUSE_FIELD_10X26 -DUSE_FIELD_INV_BUILTIN") +if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC") + + include_directories(${Boost_INCLUDE_DIRS}) + if(ETH_STATIC) + add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c) + else() + add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c) + endif() + # /TP - compile project as cpp project + set_target_properties(${EXECUTABLE} PROPERTIES COMPILE_FLAGS "/TP") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_NUM_BOOST -DUSE_FIELD_10X26 -DUSE_FIELD_INV_BUILTIN") + +elseif (APPLE OR UNIX) + + if (ETH_STATIC) + add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c field_5x52_asm.asm) + else() + add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c field_5x52_asm.asm) + endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DUSE_FIELD_GMP -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM") + target_link_libraries(${EXECUTABLE} ${GMP_LIBRARY}) + +endif() install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )