diff --git a/CMakeLists.txt b/CMakeLists.txt index 21c17e9ea..33f1052bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,6 +108,7 @@ message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}") # this must be an include, as a function it would messs up with variable scope! include(EthDependencies) +include(EthExecutableHelper) createBuildInfo() diff --git a/alethzero/EthereumMacOSXBundleInfo.plist.in b/EthereumMacOSXBundleInfo.plist.in similarity index 100% rename from alethzero/EthereumMacOSXBundleInfo.plist.in rename to EthereumMacOSXBundleInfo.plist.in diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt index a8d258efc..b72491984 100644 --- a/alethzero/CMakeLists.txt +++ b/alethzero/CMakeLists.txt @@ -3,43 +3,29 @@ cmake_policy(SET CMP0015 NEW) cmake_policy(SET CMP0020 NEW) # this policy was introduced in cmake 3.0 # remove if, once 3.0 will be used on unix -if (APPLE) +if (${CMAKE_MAJOR_VERSION} GREATER 2) cmake_policy(SET CMP0043 OLD) endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) aux_source_directory(. SRC_LIST) -include_directories(..) + include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) +include_directories(..) qt5_wrap_ui(ui_Main.h Main.ui) -# Set name of binary and add_executable() file(GLOB HEADERS "*.h") + if (APPLE) set(EXECUTABLE AlethZero) - set(BIN_INSTALL_DIR ".") - set(DOC_INSTALL_DIR ".") - - set(PROJECT_VERSION "${ETH_VERSION}") - set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") - set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") - set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") - set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTABLE}) - set(MACOSX_BUNDLE_ICON_FILE alethzero) - include(BundleUtilities) - - add_executable(${EXECUTABLE} MACOSX_BUNDLE alethzero.icns Main.ui ${SRC_LIST} ${HEADERS}) - set_target_properties(${EXECUTABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") - SET_SOURCE_FILES_PROPERTIES(${EXECUTABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) - SET_SOURCE_FILES_PROPERTIES(${MACOSX_BUNDLE_ICON_FILE}.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") else () set(EXECUTABLE alethzero) - add_executable(${EXECUTABLE} Main.ui ${SRC_LIST} ${HEADERS}) endif () + +# eth_add_executable is defined in cmake/EthExecutableHelper.cmake +# including SRC_LIST && HEADERS is implicit +eth_add_executable(${EXECUTABLE} ICON alethzero) add_dependencies(${EXECUTABLE} BuildInfo.h) @@ -60,48 +46,6 @@ target_link_libraries(${EXECUTABLE} devcore) target_link_libraries(${EXECUTABLE} web3jsonrpc) target_link_libraries(${EXECUTABLE} jsqrc) -if (APPLE) - # First have qt5 install plugins and frameworks - # replace CMAKE_PREFIX_PATH with QT_PATH ? - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD - COMMAND ${CMAKE_DEPENDENCY_INSTALL_DIR}/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - - # This tool and next will inspect linked libraries in order to determine which dependencies are required - if (${CMAKE_CFG_INTDIR} STREQUAL ".") - set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}.app") - else () - set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/\$ENV{CONFIGURATION}/${EXECUTABLE}.app") - endif () - install(CODE " - include(BundleUtilities) - set(BU_CHMOD_BUNDLE_ITEMS 1) - fixup_bundle(\"${APP_BUNDLE_PATH}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") - " COMPONENT RUNTIME ) - # Cleanup duplicate libs from macdeployqt - install(CODE " - file(GLOB LINGER_RM \"${APP_BUNDLE_PATH}/Contents/Frameworks/*.dylib\") - if (LINGER_RM) - file(REMOVE \${LINGER_RM}) - endif () - ") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin) - - file (GLOB DLLS ${CMAKE_DEPENDENCY_INSTALL_DIR}/bin/*.dll) - - foreach(DLL ${DLLS}) - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD - COMMAND cmake -E copy ${DLL} $ - ) - endforeach() - - add_custom_command(TARGET ${EXECUTABLE} POST_BUILD - COMMAND cmake -E copy_directory - "${CMAKE_DEPENDENCY_INSTALL_DIR}/plugins/platforms" - $/platforms - ) -else() - install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin) -endif () +# eth_install_executable is defined in cmake/EthExecutableHelper.cmake +eth_install_executable(${EXECUTABLE}) diff --git a/cmake/EthDependencies.cmake b/cmake/EthDependencies.cmake index 8d65bc62b..31f9420ad 100644 --- a/cmake/EthDependencies.cmake +++ b/cmake/EthDependencies.cmake @@ -4,8 +4,8 @@ # 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 (CMAKE_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}") -set (CMAKE_PREFIX_PATH ${CMAKE_DEPENDENCY_INSTALL_DIR}) +set (ETH_DEPENDENCY_INSTALL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extdep/install/${_system_name}") +set (CMAKE_PREFIX_PATH ${ETH_DEPENDENCY_INSTALL_DIR}) # Qt5 requires opengl # TODO use proper version of windows SDK (32 vs 64) diff --git a/cmake/EthExecutableHelper.cmake b/cmake/EthExecutableHelper.cmake new file mode 100644 index 000000000..a3196389f --- /dev/null +++ b/cmake/EthExecutableHelper.cmake @@ -0,0 +1,103 @@ +# +# this function requires the following variables to be specified: +# ETH_VERSION +# PROJECT_NAME +# PROJECT_VERSION +# PROJECT_COPYRIGHT_YEAR +# PROJECT_VENDOR +# PROJECT_DOMAIN_SECOND +# PROJECT_DOMAIN_FIRST +# SRC_LIST +# HEADERS +# +# params: +# ICON +# + +macro(eth_add_executable EXECUTABLE) + set (extra_macro_args ${ARGN}) + set (options) + set (one_value_args ICON) + set (multi_value_args) + cmake_parse_arguments (ETH_ADD_EXECUTABLE "${options}" "${one_value_args}" "${multi_value_args}" "${extra_macro_args}") + + if (APPLE) + + add_executable(${EXECUTABLE} MACOSX_BUNDLE alethzero.icns Main.ui ${SRC_LIST} ${HEADERS}) + set(PROJECT_VERSION "${ETH_VERSION}") + set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") + set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") + set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") + set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") + set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") + set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") + set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTABLE}) + set(MACOSX_BUNDLE_ICON_FILE ${ETH_ADD_EXECUTABLE_ICON}) + set_target_properties(${EXECUTABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") + set_source_files_properties(${EXECUTABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) + set_source_files_properties(${MACOSX_BUNDLE_ICON_FILE}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources) + + else () + add_executable(${EXECUTABLE} Main.ui ${SRC_LIST} ${HEADERS}) + endif() + +endmacro() + +# +# this function requires the following variables to be specified: +# ETH_DEPENDENCY_INSTALL_DIR +# + +macro(eth_install_executable EXECUTABLE) + + if (APPLE) + # First have qt5 install plugins and frameworks + add_custom_command(TARGET ${EXECUTABLE} POST_BUILD + COMMAND ${ETH_DEPENDENCY_INSTALL_DIR}/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + + # This tool and next will inspect linked libraries in order to determine which dependencies are required + if (${CMAKE_CFG_INTDIR} STREQUAL ".") + set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}.app") + else () + set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/\$ENV{CONFIGURATION}/${EXECUTABLE}.app") + endif () + + # TODO check, how fixup_bundle works and if it is required + install(CODE " + include(BundleUtilities) + set(BU_CHMOD_BUNDLE_ITEMS 1) + fixup_bundle(\"${APP_BUNDLE_PATH}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") + " COMPONENT RUNTIME ) + # Cleanup duplicate libs from macdeployqt + install(CODE " + file(GLOB LINGER_RM \"${APP_BUNDLE_PATH}/Contents/Frameworks/*.dylib\") + if (LINGER_RM) + file(REMOVE \${LINGER_RM}) + endif () + ") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + + # copy all dlls to executable directory + file (GLOB DLLS ${CMAKE_DEPENDENCY_INSTALL_DIR}/bin/*.dll) + + foreach(DLL ${DLLS}) + add_custom_command(TARGET ${EXECUTABLE} POST_BUILD + COMMAND cmake -E copy ${DLL} $ + ) + endforeach() + + add_custom_command(TARGET ${EXECUTABLE} POST_BUILD + COMMAND cmake -E copy_directory + "${ETH_DEPENDENCY_INSTALL_DIR}/plugins/platforms" + $/platforms + ) + + install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin) + else() + install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin) + endif () + +endmacro() + + diff --git a/extdep/CMakeLists.txt b/extdep/CMakeLists.txt index ea708fbe3..bfba8e962 100644 --- a/extdep/CMakeLists.txt +++ b/extdep/CMakeLists.txt @@ -40,6 +40,7 @@ else() 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) eth_download(cryptopp) diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt index 8f73c546b..e36bf3812 100644 --- a/mix/CMakeLists.txt +++ b/mix/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_libraries(${EXECUTABLE} jsqrc) if (APPLE) # First have qt5 install plugins and frameworks add_custom_command(TARGET ${EXECUTABLE} POST_BUILD - COMMAND ${CMAKE_DEPENDENCY_INSTALL_DIR}/bin/macdeployqt -qmldir=${CMAKE_CURRENT_SOURCE_DIR}/qml ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app + COMMAND ${ETH_DEPENDENCY_INSTALL_DIR}/bin/macdeployqt -qmldir=${CMAKE_CURRENT_SOURCE_DIR}/qml ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # This tool and next will inspect linked libraries in order to determine which dependencies are required diff --git a/third/CMakeLists.txt b/third/CMakeLists.txt index b28210719..9c8a9e4f0 100644 --- a/third/CMakeLists.txt +++ b/third/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_libraries(${EXECUTABLE} jsqrc) if (APPLE) # First have qt5 install plugins and frameworks add_custom_command(TARGET ${EXECUTABLE} POST_BUILD - COMMAND ${CMAKE_DEPENDENCY_INSTALL_DIR}/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app + COMMAND ${ETH_DEPENDENCY_INSTALL_DIR}/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # This tool and next will inspect linked libraries in order to determine which dependencies are required