From f9a56e06182dabe9bab8a344069ea9817dc40cd4 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 3 Dec 2014 21:52:01 +0100 Subject: [PATCH] improved eth_download.cmake --- cmake/EthDependencies.cmake | 3 +++ extdep/CMakeLists.txt | 14 +++++++++----- extdep/compile/leveldb.cmake | 5 +++-- extdep/eth_download.cmake | 33 +++++++++++++++++++++++++-------- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index 7b938ae5f..bf7ff487a 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -6,6 +6,9 @@ string(TOLOWER ${CMAKE_SYSTEM_NAME} _system_name) set (CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}") +# mac os +# https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html +set(ENV{DYLD_FALLBACK_LIBRARY_PATH} ${CMAKE_PREFIX_PATH}/lib) # Dependencies must have a version number, to ensure reproducible build. The version provided here is the one that is in the extdep repository. If you use system libraries, version numbers may be different. diff --git a/extdep/CMakeLists.txt b/extdep/CMakeLists.txt index 54412e6a6..642e10eee 100644 --- a/extdep/CMakeLists.txt +++ b/extdep/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 2.8) include(ExternalProject) +include(CMakeParseArguments) include(eth_download.cmake) # all dependencies will be installed into this directory, separated by platform @@ -30,11 +31,14 @@ if (ETH_COMPILE) # cryptopp include(compile/cryptopp.cmake) else() - eth_download("json-rpc-cpp") - eth_download("qt") - eth_download("cryptopp") - #include(compile/snappy.cmake) - eth_download("leveldb") + eth_download(json-rpc-cpp VERSION 0.3.2) + eth_download(qt) + eth_download(cryptopp) + eth_download(snappy) + eth_download(leveldb) + + #include(compile/leveldb.cmake) + #eth_download("leveldb") endif() # will be re-eanbled later diff --git a/extdep/compile/leveldb.cmake b/extdep/compile/leveldb.cmake index a22773d59..9774c8c57 100644 --- a/extdep/compile/leveldb.cmake +++ b/extdep/compile/leveldb.cmake @@ -1,9 +1,10 @@ if (APPLE) ExternalProject_Add(leveldb - DEPENDS snappy + #DEPENDS snappy URL https://leveldb.googlecode.com/files/leveldb-1.15.0.tar.gz BINARY_DIR leveldb-prefix/src/leveldb - CONFIGURE_COMMAND patch < ${CMAKE_CURRENT_SOURCE_DIR}/compile/leveldb_osx.patch + #CONFIGURE_COMMAND patch < ${CMAKE_CURRENT_SOURCE_DIR}/compile/leveldb_osx.patch + CONFIGURE_COMMAND "" BUILD_COMMAND export ETH_DEPENDENCY_INSTALL_DIR=${ETH_DEPENDENCY_INSTALL_DIR} && make -j 3 INSTALL_COMMAND cp -rf include/leveldb ${ETH_DEPENDENCY_INSTALL_DIR}/include/ && cp libleveldb.a ${ETH_DEPENDENCY_INSTALL_DIR}/lib && cp libleveldb.dylib.1.15 ${ETH_DEPENDENCY_INSTALL_DIR}/lib/libleveldb.dylib ) diff --git a/extdep/eth_download.cmake b/extdep/eth_download.cmake index dafd065b7..1567eafaa 100644 --- a/extdep/eth_download.cmake +++ b/extdep/eth_download.cmake @@ -6,7 +6,13 @@ # usage: # # eth_download("json-rpc-cpp") -# eth_download("json-rpc-cpp" "0.3.2") +# eth_download("json-rpc-cpp" VERSION "0.3.2") +# +# parsing arguments +# http://www.cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html +# +# for macos you may need to specify OSX_SCRIPT with install_name_tool to fix dylib +# http://stackoverflow.com/questions/2985315/using-install-name-tool-whats-going-wrong # # TODO: # check if install_command is handling symlinks correctly on linux and windows @@ -14,30 +20,41 @@ macro(eth_download eth_package_name) set (extra_macro_args ${ARGN}) - if (extra_macro_args GREATER 0) - set(eth_tar_name "${eth_package_name}-${ARGV1}.tar.gz") + set (options) + set (one_value_args VERSION OSX_SCRIPT UNIX_SCRIPT WIN_SCRIPT) + set (multi_value_args) + cmake_parse_arguments (ETH_DOWNLOAD "${options}" "${one_value_args}" "${multi_value_args}" ${extra_macro_args}) + + if (ETH_DOWNLOAD_VERSION) + set(eth_tar_name "${eth_package_name}-${ETH_DOWNLOAD_VERSION}.tar.gz") else() set(eth_tar_name "${eth_package_name}.tar.gz") endif() - message(STATUS "download path for ${eth_package_name} is : ${ETH_DEPENDENCY_SERVER}/${eth_tar_name}.tar.gz") + message(STATUS "download path for ${eth_package_name} is : ${ETH_DEPENDENCY_SERVER}/${eth_tar_name}") # we need that to copy symlinks # see http://superuser.com/questions/138587/how-to-copy-symbolic-links if (APPLE) - set (eth_package_install cp -a . ${ETH_DEPENDENCY_INSTALL_DIR}) + set (eth_package_copy cp -a . ${ETH_DEPENDENCY_INSTALL_DIR}) + set (eth_package_install ${ETH_DOWNLOAD_OSX_SCRIPT}) elseif (UNIX) - set (eth_package_install cp -a . ${ETH_DEPENDENCY_INSTALL_DIR}) + set (eth_package_copy cp -a . ${ETH_DEPENDENCY_INSTALL_DIR}) + set (eth_package_install ${ETH_DOWNLOAD_UNIX_SCRIPT}) else () - set (eth_package_install cmake -E copy_directory . ${ETH_DEPENDENCY_INSTALL_DIR}) + set (eth_package_copy cmake -E copy_directory . ${ETH_DEPENDENCY_INSTALL_DIR}) + set (eth_package_install ${ETH_DOWNLOAD_WIN_SCRIPT}) endif() + if (eth_package_install) + message(STATUS "install script is at: ${eth_package_install}") + endif() ExternalProject_Add(${eth_package_name} URL ${ETH_DEPENDENCY_SERVER}/${eth_tar_name} BINARY_DIR ${eth_package_name}-prefix/src/${eth_package_name} CONFIGURE_COMMAND "" - BUILD_COMMAND "" + BUILD_COMMAND ${eth_package_copy} INSTALL_COMMAND ${eth_package_install} ) endmacro()