|
| 1 | +cmake_policy(SET CMP0015 NEW) |
| 2 | + |
| 3 | +if ("${TARGET_PLATFORM}" STREQUAL "w64") |
| 4 | + cmake_policy(SET CMP0020 NEW) |
| 5 | +endif () |
| 6 | + |
| 7 | + |
| 8 | +set(CMAKE_INCLUDE_CURRENT_DIR ON) |
| 9 | +aux_source_directory(. SRC_LIST) |
| 10 | + |
| 11 | +include_directories(..) |
| 12 | +link_directories(../libethereum) |
| 13 | + |
| 14 | +# Find Qt5 for Apple and update src_list for windows |
| 15 | +if (APPLE) |
| 16 | + # homebrew defaults to qt4 and installs qt5 as 'keg-only' |
| 17 | + # which places it into /usr/local/opt insteadof /usr/local. |
| 18 | + |
| 19 | + set(CMAKE_PREFIX_PATH /usr/local/opt/qt5) |
| 20 | + include_directories(/usr/local/opt/qt5/include /usr/local/include) |
| 21 | +elseif (${TARGET_PLATFORM} STREQUAL "w64") |
| 22 | + set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) |
| 23 | +elseif (UNIX) |
| 24 | + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") |
| 25 | +endif () |
| 26 | + |
| 27 | + |
| 28 | +find_package(Qt5Gui REQUIRED) |
| 29 | +find_package(Qt5Quick REQUIRED) |
| 30 | +find_package(Qt5Qml REQUIRED) |
| 31 | +find_package(Qt5Network REQUIRED) |
| 32 | +find_package(Qt5Widgets REQUIRED) |
| 33 | +find_package(Qt5WebKit REQUIRED) |
| 34 | +find_package(Qt5WebKitWidgets REQUIRED) |
| 35 | + |
| 36 | +set(EXECUTABLE qethereum) |
| 37 | + |
| 38 | +# Set name of binary and add_executable() |
| 39 | +if (APPLE) |
| 40 | + set(CMAKE_INSTALL_PREFIX ./) |
| 41 | + set(BIN_INSTALL_DIR ".") |
| 42 | + set(DOC_INSTALL_DIR ".") |
| 43 | + |
| 44 | + set(PROJECT_VERSION "${ETH_VERSION}") |
| 45 | + set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") |
| 46 | + set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_NAME} ${PROJECT_VERSION}") |
| 47 | + set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") |
| 48 | + set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") |
| 49 | + set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") |
| 50 | + set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") |
| 51 | + set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTABLE}) |
| 52 | + include(BundleUtilities) |
| 53 | + |
| 54 | + add_library(${EXECUTABLE} SHARED ${RESOURCE_ADDED} ${SRC_LIST}) |
| 55 | +else () |
| 56 | + add_library(${EXECUTABLE} ${RESOURCE_ADDED} ${SRC_LIST}) |
| 57 | +endif () |
| 58 | + |
| 59 | +qt5_use_modules(${EXECUTABLE} Core Gui WebKit WebKitWidgets Widgets Network Quick Qml) |
| 60 | +target_link_libraries(${EXECUTABLE} ethereum secp256k1 ${CRYPTOPP_LIBRARIES}) |
| 61 | + |
| 62 | +if (APPLE) |
| 63 | + if (${ADDFRAMEWORKS}) |
| 64 | + set_target_properties(${EXECUTABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") |
| 65 | + endif () |
| 66 | + |
| 67 | + SET_SOURCE_FILES_PROPERTIES(${EXECUTABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) |
| 68 | + |
| 69 | + # 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 |
| 70 | + # will not be set but defaults to release. |
| 71 | + set(generator_lowercase "${CMAKE_GENERATOR}") |
| 72 | + string(TOLOWER "${CMAKE_GENERATOR}" generator_lowercase) |
| 73 | + if (generator_lowercase STREQUAL "xcode") |
| 74 | + # TODO: Not sure how to resolve this. Possibly \${TARGET_BUILD_DIR} |
| 75 | + set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}/Debug") |
| 76 | + else () |
| 77 | + set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}") |
| 78 | + endif () |
| 79 | + |
| 80 | + set(APPS ${binary_build_dir}/${EXECUTABLE}.app) |
| 81 | + |
| 82 | + # This tool and the next will automatically looked at the linked libraries in order to determine what dependencies are required. Thus, target_link_libaries only needs to add ethereum and secp256k1 (above) |
| 83 | + install(CODE " |
| 84 | + include(BundleUtilities) |
| 85 | + set(BU_CHMOD_BUNDLE_ITEMS 1) |
| 86 | + fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"../libethereum ../secp256k1\") |
| 87 | + " COMPONENT RUNTIME ) |
| 88 | + |
| 89 | + if (${ADDFRAMEWORKS}) |
| 90 | + add_custom_target(addframeworks ALL |
| 91 | + COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTABLE}.app |
| 92 | + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} |
| 93 | + DEPENDS ${PROJECT_NAME} |
| 94 | + ) |
| 95 | + endif () |
| 96 | + |
| 97 | +elseif (${TARGET_PLATFORM} STREQUAL "w64") |
| 98 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport -static-libgcc -static-libstdc++ -static") |
| 99 | + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-s -Wl,-subsystem,windows -mthreads -L/usr/x86_64-w64-mingw32/plugins/platforms") |
| 100 | + target_link_libraries(${EXECUTABLE} gcc) |
| 101 | + target_link_libraries(${EXECUTABLE} mingw32 qtmain mswsock iphlpapi qwindows shlwapi Qt5PlatformSupport gdi32 comdlg32 oleaut32 imm32 winmm ole32 uuid ws2_32) |
| 102 | + target_link_libraries(${EXECUTABLE} boost_system-mt-s) |
| 103 | + target_link_libraries(${EXECUTABLE} boost_filesystem-mt-s) |
| 104 | + target_link_libraries(${EXECUTABLE} boost_thread_win32-mt-s) |
| 105 | + target_link_libraries(${EXECUTABLE} Qt5PlatformSupport) |
| 106 | + set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) |
| 107 | +elseif (UNIX) |
| 108 | +else () |
| 109 | + target_link_libraries(${EXECUTABLE} boost_system) |
| 110 | + target_link_libraries(${EXECUTABLE} boost_filesystem) |
| 111 | + find_package(Threads REQUIRED) |
| 112 | + target_link_libraries(${EXECUTABLE} ${CMAKE_THREAD_LIBS_INIT}) |
| 113 | + install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ) |
| 114 | +endif () |
| 115 | + |
0 commit comments