Browse Source

Merge pull request #36 from subtly/master

macos app bundle
cl-refactor
Gav Wood 11 years ago
parent
commit
6ca7f5426f
  1. 5
      CMakeLists.txt
  2. 102
      alethzero/CMakeLists.txt
  3. 38
      alethzero/EthereumMacOSXBundleInfo.plist.in
  4. 11
      libethereum/CMakeLists.txt
  5. 7
      secp256k1/CMakeLists.txt

5
CMakeLists.txt

@ -127,7 +127,10 @@ else ()
# Always "found", given last block.
include_directories(${CRYPTOPP_INCLUDE_DIR})
link_directories(${CRYPTOPP_LIBRARIES})
if (NOT APPLE)
link_directories(${CRYPTOPP_LIBRARIES})
endif ()
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

102
alethzero/CMakeLists.txt

@ -4,50 +4,100 @@ if ("${TARGET_PLATFORM}" STREQUAL "w64")
cmake_policy(SET CMP0020 NEW)
endif ()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
aux_source_directory(. SRC_LIST)
include_directories(..)
link_directories(../libethereum)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
execute_process(
COMMAND brew info qt5 | grep Cellar | awk -F ' ' '{print $1}'
OUTPUT_VARIABLE osx_qt5
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_PREFIX_PATH /usr/local/Cellar/qt5/5.2.0)
include_directories(/usr/local/Cellar/qt5/5.2.0/include /usr/local/include)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Find Qt5 for Apple and update src_list for windows
if (APPLE)
# homebrew defaults to qt4 and installs qt5 as 'keg-only'
# which places it into /usr/local/opt insteadof /usr/local.
if (${TARGET_PLATFORM} STREQUAL "w64")
set(CMAKE_PREFIX_PATH /usr/local/opt/qt5)
include_directories(/usr/local/opt/qt5/include /usr/local/include)
elseif (${TARGET_PLATFORM} STREQUAL "w64")
set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp)
else ()
endif ()
find_package(Qt5Widgets REQUIRED)
add_executable(alethzero Main.ui ${SRC_LIST})
find_package(Qt5Widgets REQUIRED)
qt5_wrap_ui(ui_Main.h Main.ui)
target_link_libraries(alethzero ethereum)
# Set name of binary and add_executable()
if (APPLE)
set(EXECUTEABLE AlethZero)
# set(CMAKE_INSTALL_PREFIX ./)
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 ${EXECUTEABLE})
include(BundleUtilities)
add_executable(${EXECUTEABLE} MACOSX_BUNDLE Main.ui ${SRC_LIST})
else ()
set(EXECUTABLE alethzero)
add_executable(${EXECUTEABLE} Main.ui ${SRC_LIST})
endif ()
if (${TARGET_PLATFORM} STREQUAL "w64")
qt5_use_modules(${EXECUTEABLE} Core Gui Widgets Network)
target_link_libraries(${EXECUTEABLE} ethereum secp256k1 cryptopp)
if (APPLE)
# target_link_libraries(${EXECUTEABLE} boost_system boost_filesystem gmp leveldb miniupnpc snappy)
set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in")
SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)
# This is a workaround for when the build-type defaults to Debug, and when a multi-config generator like xcode is used, where the type
# will not be set but defaults to release.
set(generator_lowercase "${CMAKE_GENERATOR}")
string(TOLOWER "${CMAKE_GENERATOR}" generator_lowercase)
if (generator_lowercase STREQUAL "xcode")
# TODO: Not sure how to resolve this. Possibly \${TARGET_BUILD_DIR}
set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}/Debug")
else ()
set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}")
endif ()
set(APPS ${binary_build_dir}/${EXECUTEABLE}.app)
install(CODE "
include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS 1)
fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"../libethereum ../secp256k1\")
" COMPONENT RUNTIME )
add_custom_target(addframeworks ALL
COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTEABLE}.app
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DEPENDS ${PROJECT_NAME}
)
elseif (${TARGET_PLATFORM} STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport -static-libgcc -static-libstdc++ -static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-s -Wl,-subsystem,windows -mthreads -L/usr/x86_64-w64-mingw32/plugins/platforms")
target_link_libraries(alethzero gcc)
target_link_libraries(alethzero mingw32 qtmain mswsock iphlpapi qwindows shlwapi Qt5PlatformSupport gdi32 comdlg32 oleaut32 imm32 winmm ole32 uuid ws2_32)
target_link_libraries(alethzero boost_system-mt-s)
target_link_libraries(alethzero boost_filesystem-mt-s)
target_link_libraries(alethzero boost_thread_win32-mt-s)
target_link_libraries(alethzero Qt5PlatformSupport)
target_link_libraries(${EXECUTEABLE} gcc)
target_link_libraries(${EXECUTEABLE} mingw32 qtmain mswsock iphlpapi qwindows shlwapi Qt5PlatformSupport gdi32 comdlg32 oleaut32 imm32 winmm ole32 uuid ws2_32)
target_link_libraries(${EXECUTEABLE} boost_system-mt-s)
target_link_libraries(${EXECUTEABLE} boost_filesystem-mt-s)
target_link_libraries(${EXECUTEABLE} boost_thread_win32-mt-s)
target_link_libraries(${EXECUTEABLE} Qt5PlatformSupport)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
else ()
target_link_libraries(alethzero boost_system)
target_link_libraries(alethzero boost_filesystem)
target_link_libraries(${EXECUTEABLE} boost_system)
target_link_libraries(${EXECUTEABLE} boost_filesystem)
find_package(Threads REQUIRED)
target_link_libraries(alethzero ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${EXECUTEABLE} ${CMAKE_THREAD_LIBS_INIT})
install( TARGETS ${EXECUTEABLE} RUNTIME DESTINATION bin )
endif ()
qt5_use_modules(alethzero Core Gui Widgets Network)
install( TARGETS alethzero RUNTIME DESTINATION bin )

38
alethzero/EthereumMacOSXBundleInfo.plist.in

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSRequiresCarbon</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>

11
libethereum/CMakeLists.txt

@ -3,7 +3,14 @@ cmake_policy(SET CMP0015 NEW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB")
aux_source_directory(. SRC_LIST)
add_library(ethereum ${SRC_LIST})
if(APPLE)
# set(CMAKE_INSTALL_PREFIX ../lib)
add_library(ethereum SHARED ${SRC_LIST})
else()
add_library(ethereum ${SRC_LIST})
endif()
file(GLOB HEADERS "*.h")
include_directories(../secp256k1)
@ -13,6 +20,7 @@ target_link_libraries(ethereum miniupnpc)
target_link_libraries(ethereum leveldb)
target_link_libraries(ethereum gmp)
if(${TARGET_PLATFORM} STREQUAL "w64")
include_directories(/usr/x86_64-w64-mingw32/include/cryptopp)
target_link_libraries(ethereum cryptopp)
@ -32,6 +40,7 @@ else ()
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
link_directories(/usr/local/lib)
include_directories(/usr/local/include)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

7
secp256k1/CMakeLists.txt

@ -3,7 +3,12 @@ cmake_policy(SET CMP0015 NEW)
set(CMAKE_ASM_COMPILER "yasm")
#aux_source_directory(. SRC_LIST)
add_library(secp256k1 secp256k1.c field_5x52_asm.asm)
if(APPLE)
# set(CMAKE_INSTALL_PREFIX ../lib)
add_library(secp256k1 SHARED secp256k1.c field_5x52_asm.asm)
else()
add_library(secp256k1 secp256k1.c field_5x52_asm.asm)
endif()
#set(CMAKE_C_FLAGS "-DUSE_FIELD_5X52 -DUSE_FIELD_5X52_ASM -DUSE_NUM_OPENSSL -DUSE_FIELD_INV_BUILTIN")
#target_link_libraries(secp256k1 crypto)

Loading…
Cancel
Save