Browse Source

merge of windows and osx build support

cl-refactor
subtly 11 years ago
parent
commit
42792e6db3
  1. 99
      alethzero/CMakeLists.txt

99
alethzero/CMakeLists.txt

@ -4,38 +4,31 @@ if ("${TARGET_PLATFORM}" STREQUAL "w64")
cmake_policy(SET CMP0020 NEW) cmake_policy(SET CMP0020 NEW)
endif () endif ()
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
aux_source_directory(. SRC_LIST) aux_source_directory(. SRC_LIST)
include_directories(..) include_directories(..)
link_directories(../libethereum) link_directories(../libethereum)
# brew install qt5 libpng # Find Qt5 for Apple and update src_list for windows
# install X11 (now called XQuartz) if (APPLE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # homebrew defaults to qt4 and installs qt5 as 'keg-only'
execute_process( # which places it into /usr/local/opt insteadof /usr/local.
COMMAND brew info qt5 | grep Cellar | awk -F ' ' '{print $1}'
OUTPUT_VARIABLE osx_qt5
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_PREFIX_PATH /usr/local/opt/qt5) set(CMAKE_PREFIX_PATH /usr/local/opt/qt5)
include_directories(/usr/local/opt/qt5/include /usr/local/include) include_directories(/usr/local/opt/qt5/include /usr/local/include)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") elseif (${TARGET_PLATFORM} STREQUAL "w64")
if (${TARGET_PLATFORM} STREQUAL "w64")
set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp)
else ()
endif () endif ()
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Widgets REQUIRED)
qt5_wrap_ui(Main.ui)
if(!APPLE) # Set name of binary and add_executable()
add_executable(alethzero Main.ui ${SRC_LIST}) if (APPLE)
qt5_wrap_ui(ui_Main.h Main.ui) set(EXECUTEABLE AlethZero)
qt5_use_modules(alethzero Widgets Network )
target_link_libraries(alethzero ethereum)
install( TARGETS alethzero RUNTIME DESTINATION bin )
else()
set(CMAKE_INSTALL_PREFIX ./) set(CMAKE_INSTALL_PREFIX ./)
set(BIN_INSTALL_DIR ".") set(BIN_INSTALL_DIR ".")
set(DOC_INSTALL_DIR ".") set(DOC_INSTALL_DIR ".")
@ -47,65 +40,59 @@ else()
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}") set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}")
set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}") set(MACOSX_BUNDLE_COPYRIGHT "${PROJECT_COPYRIGHT_YEAR} ${PROJECT_VENDOR}")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}") set(MACOSX_BUNDLE_GUI_IDENTIFIER "${PROJECT_DOMAIN_SECOND}.${PROJECT_DOMAIN_FIRST}")
set(MACOSX_BUNDLE_BUNDLE_NAME "AlethZero") 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 ()
INCLUDE(BundleUtilities) qt5_use_modules(${EXECUTEABLE} Core Gui Widgets Network)
target_link_libraries(${EXECUTEABLE} ethereum)
ADD_EXECUTABLE(
AlethZero
MACOSX_BUNDLE
Main.ui ${SRC_LIST}
)
set_target_properties(AlethZero PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in")
qt5_wrap_ui(ui_Main.h Main.ui) if (APPLE)
qt5_use_modules(AlethZero Widgets Network) set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in")
target_link_libraries(AlethZero ethereum)
SET_SOURCE_FILES_PROPERTIES( set_source_files_properties(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS)
AlethZero
PROPERTIES
MACOSX_PACKAGE_LOCATION MacOS
)
if(NOT CMAKE_BUILD_TYPE) # This is a workaround for when the build-type defaults to Debug, but isn't
# populated for macros.
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
endif() endif ()
set(BUILD_TYPE ${CMAKE_BUILD_TYPE}) set(BUILD_TYPE ${CMAKE_BUILD_TYPE})
get_filename_component(APP_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} REALPATH) get_filename_component(APP_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} REALPATH)
set(APPS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/AlethZero.app) # CMAKE_CURRENT_BINARY_DIR, CMAKE_RUNTIME_OUTPUT_DIRECTORY set(APPS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${EXECUTEABLE}.app) # CMAKE_CURRENT_BINARY_DIR, CMAKE_RUNTIME_OUTPUT_DIRECTORY
install(CODE " install(CODE "
include(BundleUtilities) include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS 1) set(BU_CHMOD_BUNDLE_ITEMS 1)
fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"\") fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"\")
" COMPONENT RUNTIME ) " COMPONENT RUNTIME )
add_custom_target(addframeworks ALL add_custom_target(addframeworks ALL
COMMAND /usr/local/opt/qt5/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/AlethZero.app COMMAND /usr/local/opt/qt5/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${EXECUTEABLE}.app
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DEPENDS ${PROJECT_NAME} DEPENDS ${PROJECT_NAME}
) )
endif() elseif (${TARGET_PLATFORM} STREQUAL "w64")
if (${TARGET_PLATFORM} STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-keep-inline-dllexport -static-libgcc -static-libstdc++ -static") 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") 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(${EXECUTEABLE} gcc)
target_link_libraries(alethzero mingw32 qtmain mswsock iphlpapi qwindows shlwapi Qt5PlatformSupport gdi32 comdlg32 oleaut32 imm32 winmm ole32 uuid ws2_32) target_link_libraries(${EXECUTEABLE} 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(${EXECUTEABLE} boost_system-mt-s)
target_link_libraries(alethzero boost_filesystem-mt-s) target_link_libraries(${EXECUTEABLE} boost_filesystem-mt-s)
target_link_libraries(alethzero boost_thread_win32-mt-s) target_link_libraries(${EXECUTEABLE} boost_thread_win32-mt-s)
target_link_libraries(alethzero Qt5PlatformSupport) target_link_libraries(${EXECUTEABLE} Qt5PlatformSupport)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS) set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
else () else ()
target_link_libraries(alethzero boost_system) target_link_libraries(${EXECUTEABLE} boost_system)
target_link_libraries(alethzero boost_filesystem) target_link_libraries(${EXECUTEABLE} boost_filesystem)
find_package(Threads REQUIRED) 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 () endif ()
qt5_use_modules(alethzero Core Gui Widgets Network)
install( TARGETS alethzero RUNTIME DESTINATION bin )

Loading…
Cancel
Save