diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt index b60bca425..fb134a82d 100644 --- a/alethzero/CMakeLists.txt +++ b/alethzero/CMakeLists.txt @@ -64,5 +64,5 @@ if (SERPENT) endif() # eth_install_executable is defined in cmake/EthExecutableHelper.cmake -eth_install_executable(${EXECUTABLE} DLLS ${MHD_DLL_RELEASE}) +eth_install_executable(${EXECUTABLE} DLLS MHD_DLLS) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake old mode 100755 new mode 100644 diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index 4d79d7911..2dfb80ac3 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -4,7 +4,11 @@ # by defining this variable, cmake will look for dependencies first in our own repository before looking in system paths like /usr/local/ ... # this must be set to point to the same directory as $ETH_DEPENDENCY_INSTALL_DIR in /extdep directory string(TOLOWER ${CMAKE_SYSTEM_NAME} _system_name) -set (ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}") +if (CMAKE_CL_64) + set (ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}/x64") +else () + set (ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}/Win32") +endif() set (CMAKE_PREFIX_PATH ${ETH_DEPENDENCY_INSTALL_DIR}) # setup directory for cmake generated files and include it globally @@ -59,6 +63,7 @@ if (JSONRPC) find_package(MHD) message(" - microhttpd header: ${MHD_INCLUDE_DIRS}") message(" - microhttpd lib : ${MHD_LIBRARIES}") + message(" - microhttpd dll : ${MHD_DLLS}") endif() #JSONRPC # TODO readline package does not yet check for correct version number @@ -104,7 +109,7 @@ endif() find_package (OpenCL) if (OpenCL_FOUND) - message(" - opencl header: ${OpenCL_INCLUDE_DIRES}") + message(" - opencl header: ${OpenCL_INCLUDE_DIRS}") message(" - opencl lib : ${OpenCL_LIBRARIES}") endif() diff --git a/cmake/EthExecutableHelper.cmake b/cmake/EthExecutableHelper.cmake index 0c529881f..be4f7ccd1 100644 --- a/cmake/EthExecutableHelper.cmake +++ b/cmake/EthExecutableHelper.cmake @@ -43,6 +43,22 @@ macro(eth_add_executable EXECUTABLE) endmacro() +macro(eth_copy_dlls EXECUTABLE DLLS) + # dlls must be unsubstitud list variable (without ${}) in format + # optimized;path_to_dll.dll;debug;path_to_dlld.dll + list(GET ${DLLS} 1 DLL_RELEASE) + list(GET ${DLLS} 3 DLL_DEBUG) + add_custom_command(TARGET ${EXECUTABLE} + POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS + -DDLL_RELEASE="${DLL_RELEASE}" + -DDLL_DEBUG="${DLL_DEBUG}" + -DCONF="$" + -DDESTINATION="${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + -P "${ETH_SCRIPTS_DIR}/copydlls.cmake" + ) +endmacro() + # # this function requires the following variables to be specified: # ETH_DEPENDENCY_INSTALL_DIR @@ -107,10 +123,7 @@ macro(eth_install_executable EXECUTABLE) #copy additional dlls foreach(dll ${ETH_INSTALL_EXECUTABLE_DLLS}) - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${dll} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" - ) + eth_copy_dlls(${EXECUTABLE} ${dll}) endforeach(dll) install( TARGETS ${EXECUTABLE} RUNTIME diff --git a/cmake/FindCURL.cmake b/cmake/FindCURL.cmake index ba6603784..e2f52fe79 100644 --- a/cmake/FindCURL.cmake +++ b/cmake/FindCURL.cmake @@ -30,6 +30,7 @@ set(CURL_LIBRARIES ${CURL_LIBRARY}) # same naming convention as in qt (appending debug library with d) # boost is using the same "hack" as us with "optimized" and "debug" if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + find_library( CURL_LIBRARY_DEBUG NAMES curld libcurld diff --git a/cmake/FindJsoncpp.cmake b/cmake/FindJsoncpp.cmake index c5b9c87d8..1dbfc2046 100644 --- a/cmake/FindJsoncpp.cmake +++ b/cmake/FindJsoncpp.cmake @@ -30,6 +30,7 @@ set(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY}) # same naming convention as in qt (appending debug library with d) # boost is using the same "hack" as us with "optimized" and "debug" if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + find_library( JSONCPP_LIBRARY_DEBUG NAMES jsoncppd diff --git a/cmake/FindLevelDB.cmake b/cmake/FindLevelDB.cmake index b1a9a5815..1c3465665 100644 --- a/cmake/FindLevelDB.cmake +++ b/cmake/FindLevelDB.cmake @@ -29,6 +29,7 @@ set(LEVELDB_LIBRARIES ${LEVELDB_LIBRARY}) # same naming convention as in qt (appending debug library with d) # boost is using the same "hack" as us with "optimized" and "debug" if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + find_library( LEVELDB_LIBRARY_DEBUG NAMES leveldbd diff --git a/cmake/FindMHD.cmake b/cmake/FindMHD.cmake old mode 100755 new mode 100644 index 5cb8a98d6..1e8ba03aa --- a/cmake/FindMHD.cmake +++ b/cmake/FindMHD.cmake @@ -30,18 +30,20 @@ set(MHD_LIBRARIES ${MHD_LIBRARY}) # official MHD project actually uses _d suffix if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - #TODO: place dlls into CMAKE_CFG_INTDIR subfolders - string(REPLACE ".lib" ".dll" MHD_DLL_RELEASE ${MHD_LIBRARY}) - string(REPLACE "/lib/" "/bin/" MHD_DLL_RELEASE ${MHD_DLL_RELEASE}) - find_library( MHD_LIBRARY_DEBUG NAMES microhttpd_d microhttpd-10_d libmicrohttpd_d libmicrohttpd-dll_d DOC "mhd debug library" ) - # always use release for now - #string(REPLACE ".lib" ".dll" MHD_DLL_DEBUG ${MHD_LIBRARY_DEBUG}) - #set(MHD_LIBRARIES optimized ${MHD_LIBRARIES} debug ${MHD_LIBRARY_DEBUG}) + + set(MHD_LIBRARIES optimized ${MHD_LIBRARIES} debug ${MHD_LIBRARY_DEBUG}) + + # prepare dlls + string(REPLACE ".lib" ".dll" MHD_DLL ${MHD_LIBRARY}) + string(REPLACE "/lib/" "/bin/" MHD_DLL ${MHD_DLL}) + string(REPLACE ".lib" ".dll" MHD_DLL_DEBUG ${MHD_LIBRARY_DEBUG}) + string(REPLACE "/lib/" "/bin/" MHD_DLL_DEBUG ${MHD_DLL_DEBUG}) + set(MHD_DLLS optimized ${MHD_DLL} debug ${MHD_DLL_DEBUG}) endif() diff --git a/cmake/Findjson_rpc_cpp.cmake b/cmake/Findjson_rpc_cpp.cmake index 9b64cda2b..0bdbe4d5c 100644 --- a/cmake/Findjson_rpc_cpp.cmake +++ b/cmake/Findjson_rpc_cpp.cmake @@ -52,6 +52,7 @@ set (JSON_RPC_CPP_CLIENT_LIBRARIES ${JSON_RPC_CPP_COMMON_LIBRARY} ${JSON_RPC_CPP # same naming convention as in qt (appending debug library with d) # boost is using the same "hack" as us with "optimized" and "debug" if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + find_library( JSON_RPC_CPP_COMMON_LIBRARY_DEBUG NAMES jsonrpccpp-commond diff --git a/cmake/scripts/copydlls.cmake b/cmake/scripts/copydlls.cmake new file mode 100644 index 000000000..6d86b8e4e --- /dev/null +++ b/cmake/scripts/copydlls.cmake @@ -0,0 +1,18 @@ +# this module expects +# DLLS +# CONF +# DESTINATION + +# example usage: +# cmake -DDLL_DEBUG=xd.dll -DDLL_RELEASE=x.dll -DCONFIGURATION=Release -DDESTINATION=dest -P scripts/copydlls.cmake + +# this script is created cause we do not know configuration in multiconfiguration generators at cmake configure phase ;) + +if ("${CONF}" STREQUAL "Release") + set(DLL ${DLL_RELEASE}) +else () # Debug + set(DLL ${DLL_DEBUG}) +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${DLL}" "${DESTINATION}") + diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index bd6b8d354..75e0b9e04 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -30,7 +30,7 @@ target_link_libraries(${EXECUTABLE} webthree) target_link_libraries(${EXECUTABLE} ethash) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${MHD_DLL_RELEASE} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") + eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin ) diff --git a/ethrpctest/CMakeLists.txt b/ethrpctest/CMakeLists.txt index 5d3fef542..e28b08d70 100644 --- a/ethrpctest/CMakeLists.txt +++ b/ethrpctest/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(${EXECUTABLE} testutils) target_link_libraries(${EXECUTABLE} web3jsonrpc) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${MHD_DLL_RELEASE} "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}") + eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) endif() install( TARGETS ${EXECUTABLE} DESTINATION bin ) diff --git a/extdep/CMakeLists.txt b/extdep/CMakeLists.txt index e9711754f..8ec381330 100644 --- a/extdep/CMakeLists.txt +++ b/extdep/CMakeLists.txt @@ -34,23 +34,14 @@ if (ETH_COMPILE) # boost include(compile/boost.cmake) else() - eth_download(jsoncpp) - eth_download(microhttpd) - eth_download(json-rpc-cpp - VERSION 4.2 - OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/json-rpc-cpp_osx.sh - ) - - if (APPLE) - eth_download(snappy OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/snappy_osx.sh) - endif() - - eth_download(leveldb OSX_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/leveldb_osx.sh) - eth_download(qt VERSION 5.4) - eth_download(cryptopp) - eth_download(boost) - eth_download(curl) - + eth_download(boost VERSION 1.55.0) + eth_download(cryptopp VERSION 5.6.2) + eth_download(curl VERSION 7.4.2) + eth_download(jsoncpp VERSION 1.6.2) + eth_download(json-rpc-cpp VERSION 0.5.0) + eth_download(leveldb VERSION 1.2) + eth_download(microhttpd VERSION 0.9.2) + eth_download(qt VERSION 5.4.1) endif() # will be re-eanbled later diff --git a/extdep/getstuff.bat b/extdep/getstuff.bat new file mode 100644 index 000000000..e083a97ce --- /dev/null +++ b/extdep/getstuff.bat @@ -0,0 +1,32 @@ +REM get stuff! +if not exist download mkdir download +if not exist install mkdir install +if not exist install\windows mkdir install\windows + +set eth_server=https://build.ethdev.com/builds/windows-precompiled + +call :download boost 1.55.0 +call :download cryptopp 5.6.2 +call :download curl 7.4.2 +call :download jsoncpp 1.6.2 +call :download json-rpc-cpp 0.5.0 +call :download leveldb 1.2 +call :download microhttpd 0.9.2 +call :download qt 5.4.1 + +goto :EOF + +:download + +set eth_name=%1 +set eth_version=%2 + +cd download + +if not exist %eth_name%-%eth_version%.tar.gz curl -o %eth_name%-%eth_version%.tar.gz %eth_server%/%eth_name%-%eth_version%.tar.gz +if not exist %eth_name%-%eth_version% tar -zxvf %eth_name%-%eth_version%.tar.gz +cmake -E copy_directory %eth_name%-%eth_version% ..\install\windows + +cd ..\download + +goto :EOF diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index d5f6792e1..fdc2dad07 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -9,7 +9,7 @@ aux_source_directory(. SRC_LIST) file(GLOB HEADERS "*.h") include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${OpenCL_INCLUDE_DIRS}}) +include_directories(${OpenCL_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_LIBRARIES} ethash) diff --git a/libethcore/CMakeLists.txt b/libethcore/CMakeLists.txt index 6ef7b928c..322ac80ea 100644 --- a/libethcore/CMakeLists.txt +++ b/libethcore/CMakeLists.txt @@ -11,6 +11,11 @@ aux_source_directory(. SRC_LIST) include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) + +if (ETHASHCL) + include_directories(${OpenCL_INCLUDE_DIRS}) +endif () + if (CPUID_FOUND) include_directories(${Cpuid_INCLUDE_DIRS}) endif () diff --git a/libp2p/NodeTable.cpp b/libp2p/NodeTable.cpp index 652aec745..447a7f3c9 100644 --- a/libp2p/NodeTable.cpp +++ b/libp2p/NodeTable.cpp @@ -178,7 +178,7 @@ void NodeTable::discover(NodeId _node, unsigned _round, shared_ptrendpoint.udp, _node); p.sign(m_secret); - m_findNodeTimeout.push_back(make_pair(_node, chrono::steady_clock::now())); + m_findNodeTimeout.push_back(make_pair(r->id, chrono::steady_clock::now())); m_socketPointer->send(p); } @@ -459,11 +459,14 @@ void NodeTable::onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytes case Neighbours::type: { bool expected = false; + auto now = chrono::steady_clock::now(); m_findNodeTimeout.remove_if([&](NodeIdTimePoint const& t) { - if (t.first == nodeid && chrono::steady_clock::now() - t.second < c_reqTimeout) + if (t.first == nodeid && now - t.second < c_reqTimeout) expected = true; - return t.first == nodeid; + else if (t.first == nodeid) + return true; + return false; }); if (!expected) diff --git a/third/CMakeLists.txt b/third/CMakeLists.txt index 397f2b7a6..a173d10fd 100644 --- a/third/CMakeLists.txt +++ b/third/CMakeLists.txt @@ -52,5 +52,5 @@ target_link_libraries(${EXECUTABLE} web3jsonrpc) target_link_libraries(${EXECUTABLE} jsqrc) # eth_install_executable is defined in cmake/EthExecutableHelper.cmake -eth_install_executable(${EXECUTABLE} DLLS ${MHD_DLL_RELEASE}) +eth_install_executable(${EXECUTABLE} DLLS MHD_DLLS)