Browse Source

cmake updates, mianly for macos, and refactor of others. #210, #170, #63

cl-refactor
subtly 11 years ago
parent
commit
c48edab82f
  1. 198
      CMakeLists.txt
  2. 66
      alethzero/CMakeLists.txt
  3. 11
      libqethereum/CMakeLists.txt
  4. 9
      secp256k1/CMakeLists.txt

198
CMakeLists.txt

@ -1,51 +1,37 @@
# cmake global
project(ethereum) project(ethereum)
cmake_minimum_required(VERSION 2.8.9) cmake_minimum_required(VERSION 2.8.9)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
cmake_policy(SET CMP0015 NEW) cmake_policy(SET CMP0015 NEW)
set(HEADLESS CACHE BOOL 0) # user defined, defaults
set(LANGUAGES CACHE BOOL 0) # Normally, set(...CACHE...) creates cache variables, but does not modify them.
if ("x${PARANOIA}" STREQUAL "x") set(HEADLESS OFF CACHE BOOL "Do not compile GUI (AlethZero)")
if ("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") set(LANGUAGES OFF CACHE BOOL "Limit build to Serpent/LLL tools")
set(PARANOIA CACHE BOOL 1) set(VMTRACE OFF CACHE BOOL "VM tracing and run-time checks (useful for cross-implementation VM debugging)")
else () set(PARANOIA OFF CACHE BOOL "Additional run-time checks")
set(PARANOIA CACHE BOOL 0)
endif ()
endif ()
if ("x${VMTRACE}" STREQUAL "x") if (LANGUAGES)
if ("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") add_definitions(-DETH_LANGUAGES)
set(VMTRACE CACHE BOOL 1)
else ()
set(VMTRACE CACHE BOOL 0)
endif ()
endif () endif ()
if (PARANOIA) if (PARANOIA)
add_definitions(-DETH_PARANOIA) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
else() add_definitions(-DETH_PARANOIA)
set(PARANOIA 0) else ()
message(FATAL_ERROR "Paranoia requires debug.")
endif ()
endif () endif ()
if (VMTRACE) if (VMTRACE)
add_definitions(-DETH_VMTRACE) if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
else() add_definitions(-DETH_VMTRACE)
set(VMTRACE 0) else ()
endif () message(FATAL_ERROR "VM tracing requires debug.")
endif ()
if (LANGUAGES)
add_definitions(-DETH_LANGUAGES)
else()
set(LANGUAGES 0)
endif () endif ()
if (NOT HEADLESS)
set(HEADLESS 0)
endif()
message("LANGUAGES: ${LANGUAGES}; VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}") message("LANGUAGES: ${LANGUAGES}; VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}")
# Default TARGET_PLATFORM to "linux". # Default TARGET_PLATFORM to "linux".
@ -58,13 +44,19 @@ if ("${TARGET_PLATFORM}" STREQUAL "linux")
set(CMAKE_THREAD_LIBS_INIT pthread) set(CMAKE_THREAD_LIBS_INIT pthread)
endif () endif ()
# Initialize CXXFLAGS. # Set default build type to Release w/debug info
# if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
# set(CMAKE_BUILD_TYPE RelWithDebInfo)
# endif()
# Initialize CXXFLAGS
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -DSHAREDLIB") set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wno-unknown-pragmas -Wextra -DSHAREDLIB")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DETH_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DETH_RELEASE") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG -DETH_RELEASE")
set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG -DETH_RELEASE") set(CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG -DETH_RELEASE")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DETH_DEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DETH_DEBUG")
# Windows
if ("${TARGET_PLATFORM}" STREQUAL "w64") if ("${TARGET_PLATFORM}" STREQUAL "w64")
set(CMAKE_SYSTEM_NAME Windows) set(CMAKE_SYSTEM_NAME Windows)
@ -96,6 +88,7 @@ else ()
set(ETH_SHARED 1) set(ETH_SHARED 1)
endif() endif()
# Set build platform; to be written to BuildInfo.h
if (CMAKE_COMPILER_IS_MINGW) if (CMAKE_COMPILER_IS_MINGW)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/mingw") set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/mingw")
elseif (CMAKE_COMPILER_IS_MSYS) elseif (CMAKE_COMPILER_IS_MSYS)
@ -104,16 +97,17 @@ elseif (CMAKE_COMPILER_IS_GNUCXX)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/g++") set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/g++")
elseif (CMAKE_COMPILER_IS_MSVC) elseif (CMAKE_COMPILER_IS_MSVC)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msvc") set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msvc")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/clang")
else () else ()
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown") set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown")
endif () endif ()
message("CXXFLAGS: ${CMAKE_CXX_FLAGS}") message("CXXFLAGS: ${CMAKE_CXX_FLAGS}")
#add_definitions("-DETH_BUILD_TYPE=${ETH_BUILD_TYPE}") #add_definitions("-DETH_BUILD_TYPE=${ETH_BUILD_TYPE}")
#add_definitions("-DETH_BUILD_PLATFORM=${ETH_BUILD_PLATFORM}") #add_definitions("-DETH_BUILD_PLATFORM=${ETH_BUILD_PLATFORM}")
# Compiler-specific C++11 activation. # C++11 check and activation
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process( execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
@ -133,51 +127,43 @@ if("${TARGET_PLATFORM}" STREQUAL "w64")
set(CRYPTOPP_ID /usr/x86_64-w64-mingw32/include/cryptopp) set(CRYPTOPP_ID /usr/x86_64-w64-mingw32/include/cryptopp)
else() else()
# Look for available Crypto++ version and if it is >= 5.6.2 # Look for available Crypto++ version and if it is >= 5.6.2
find_path(CRYPTOPP_ID cryptlib.h find_path(ID cryptlib.h
../cryptopp/src ../cryptopp/src
../../cryptopp/src) ../../cryptopp/src
if(CRYPTOPP_ID STREQUAL "CRYPTOPP_ID-NOTFOUND") /usr/include/cryptopp
message("Trying system cryptopp...") /usr/include/crypto++
find_path(CRYPTOPP_ID cryptlib.h /usr/local/include/cryptopp
/usr/include/cryptopp /usr/local/include/crypto++
/usr/include/crypto++ /opt/local/include/cryptopp
/usr/local/include/cryptopp /opt/local/include/crypto++
/usr/local/include/crypto++ )
/opt/local/include/cryptopp find_library(LS NAMES cryptoppeth cryptopp
/opt/local/include/crypto++ ../cryptopp/src/../target/build/release
) ../../cryptopp/src/../target/build/release
find_library(CRYPTOPP_LS NAMES cryptoppeth cryptopp PATHS
PATHS /usr/lib
/usr/lib /usr/local/lib
/usr/local/lib /opt/local/lib
/opt/local/lib )
)
else()
message("Local cryptopp OK.")
set(CRYPTOPP_LS ${CRYPTOPP_ID}/../target/build/release/libcryptopp.so)
endif()
if (CRYPTOPP_LS STREQUAL "CRYPTOPP_LS-NOTFOUND") if (ID AND LS)
message(FATAL_ERROR "Couldn't find Crypto++ version >= 5.6.2.") message(STATUS "Found Crypto++: ${ID}, ${LS}")
else() set(_CRYPTOPP_VERSION_HEADER ${ID}/config.h)
message(STATUS "Found Crypto++: ${CRYPTOPP_ID}, ${CRYPTOPP_LS}")
set(_CRYPTOPP_VERSION_HEADER ${CRYPTOPP_ID}/config.h)
if(EXISTS ${_CRYPTOPP_VERSION_HEADER}) if(EXISTS ${_CRYPTOPP_VERSION_HEADER})
file(STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION REGEX "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$") file(STRINGS ${_CRYPTOPP_VERSION_HEADER} _CRYPTOPP_VERSION REGEX "^#define CRYPTOPP_VERSION[ \t]+[0-9]+$")
string(REGEX REPLACE "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION ${_CRYPTOPP_VERSION}) string(REGEX REPLACE "^#define CRYPTOPP_VERSION[ \t]+([0-9]+)" "\\1" _CRYPTOPP_VERSION ${_CRYPTOPP_VERSION})
if(${_CRYPTOPP_VERSION} LESS 562) if(${_CRYPTOPP_VERSION} LESS 562)
set(CRYPTOPP_ID CACHE FILEPATH "" FORCE) message(FATAL_ERROR "Crypto++ version found is smaller than 5.6.2.")
set(CRYPTOPP_LS CACHE FILEPATH "" FORCE)
message(STATUS "Crypto++ version found is smaller than 5.6.2.")
else() else()
set(CRYPTOPP_ID ${ID} CACHE FILEPATH "")
set(CRYPTOPP_LS ${LS} CACHE FILEPATH "")
message(STATUS "Crypto++ found and version greater or equal to 5.6.2") message(STATUS "Crypto++ found and version greater or equal to 5.6.2")
endif() endif()
endif() endif()
else()
message(STATUS "Crypto++ Not Found: ${CRYPTOPP_ID}, ${CRYPTOPP_LS}")
endif() endif()
# Not really worth caching. We want to reevaluate anyway.
mark_as_advanced(CRYPTOPP_ID CRYPTOPP_LS)
find_path( LEVELDB_ID leveldb/db.h find_path( LEVELDB_ID leveldb/db.h
/usr/include /usr/include
/usr/local/include /usr/local/include
@ -310,40 +296,32 @@ else()
endif() endif()
if(CRYPTOPP_ID) if(CRYPTOPP_ID)
include_directories(${CRYPTOPP_ID}) include_directories(${CRYPTOPP_ID})
endif() endif()
if(PYTHON_ID) if(PYTHON_ID)
include_directories(${PYTHON_ID}) include_directories(${PYTHON_ID})
endif() endif()
if(MINIUPNPC_ID) if(MINIUPNPC_ID)
include_directories(${MINIUPNPC_ID}) include_directories(${MINIUPNPC_ID})
endif() endif()
if(LEVELDB_ID) if(LEVELDB_ID)
include_directories(${LEVELDB_ID}) include_directories(${LEVELDB_ID})
endif() endif()
if(READLINE_ID) if(READLINE_ID)
include_directories(${READLINE_ID}) include_directories(${READLINE_ID})
endif() endif()
if(JSONRPC_ID) if(JSONRPC_ID)
include_directories(${JSONRPC_ID}) include_directories(${JSONRPC_ID})
endif() endif()
# if (NOT APPLE)
# link_directories(${CRYPTOPP_LS})
# link_directories(${LEVELDB_LS})
# link_directories(${MINIUPNPC_LS})
# link_directories(${PYTHON_LS})
# link_directories(${READLINE_LS})
# link_directories(${JSONRPC_LS})
# endif()
# Generate header file containing useful build information # Generate header file containing useful build information
add_custom_target(BuildInfo.h ALL COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BUILD_TYPE} ${ETH_BUILD_PLATFORM}) add_custom_target(BuildInfo.h ALL COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo.sh ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BUILD_TYPE} ${ETH_BUILD_PLATFORM})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
link_directories(/usr/local/lib) link_directories(/usr/local/lib)
include_directories(/usr/local/include) include_directories(/usr/local/include)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif()
add_subdirectory(libethential) add_subdirectory(libethential)
add_subdirectory(libevmface) add_subdirectory(libevmface)
@ -357,34 +335,40 @@ endif()
add_subdirectory(lllc) add_subdirectory(lllc)
add_subdirectory(sc) add_subdirectory(sc)
if (NOT LANGUAGES) if (NOT LANGUAGES)
add_subdirectory(secp256k1) add_subdirectory(secp256k1)
add_subdirectory(libethcore) add_subdirectory(libethcore)
add_subdirectory(libevm) add_subdirectory(libevm)
add_subdirectory(libethereum) add_subdirectory(libethereum)
add_subdirectory(test) add_subdirectory(test)
add_subdirectory(eth) add_subdirectory(eth)
if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug") if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug")
add_subdirectory(exp) add_subdirectory(exp)
endif () endif ()
if(NOT ("${TARGET_PLATFORM}" STREQUAL "w64")) if(NOT ("${TARGET_PLATFORM}" STREQUAL "w64"))
add_subdirectory(neth) add_subdirectory(neth)
endif () endif ()
if(QTQML) if(QTQML)
add_definitions(-DETH_QTQML) add_definitions(-DETH_QTQML)
endif() endif()
if(NOT HEADLESS) if(NOT HEADLESS)
add_subdirectory(libqethereum) if ("${TARGET_PLATFORM}" STREQUAL "w64")
add_subdirectory(alethzero) cmake_policy(SET CMP0020 NEW)
if(QTQML) endif ()
add_subdirectory(walleth)
endif() add_subdirectory(libqethereum)
endif() add_subdirectory(alethzero)
if(QTQML)
add_subdirectory(walleth)
endif()
endif()
endif() endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SRC_LIST BuildInfo.h)
enable_testing() enable_testing()
add_test(NAME alltests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testeth) add_test(NAME alltests WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/test COMMAND testeth)
#unset(HEADLESS CACHE)
#unset(TARGET_PLATFORM CACHE) #unset(TARGET_PLATFORM CACHE)

66
alethzero/CMakeLists.txt

@ -1,30 +1,18 @@
cmake_policy(SET CMP0015 NEW)
if ("${TARGET_PLATFORM}" STREQUAL "w64")
cmake_policy(SET CMP0020 NEW)
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(..)
# Find Qt5 for Apple and update src_list for windows
if (APPLE) if (APPLE)
# homebrew defaults to qt4 and installs qt5 as 'keg-only' # Add homebrew path for qt5
# which places it into /usr/local/opt insteadof /usr/local.
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)
elseif ("${TARGET_PLATFORM}" STREQUAL "w64") elseif ("${TARGET_PLATFORM}" STREQUAL "w64")
set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp) set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp)
include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets) include_directories(/usr/x86_64-w64-mingw32/include /usr/x86_64-w64-mingw32/include/QtCore /usr/x86_64-w64-mingw32/include/QtGui /usr/x86_64-w64-mingw32/include/QtQuick /usr/x86_64-w64-mingw32/include/QtQml /usr/x86_64-w64-mingw32/include/QtNetwork /usr/x86_64-w64-mingw32/include/QtWidgets /usr/x86_64-w64-mingw32/include/QtWebKit /usr/x86_64-w64-mingw32/include/QtWebKitWidgets)
elseif (UNIX) elseif (UNIX)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake") set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ";$ENV{QTDIR}/lib/cmake")
endif () endif ()
find_package(Qt5Core REQUIRED) find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED) find_package(Qt5Gui REQUIRED)
find_package(Qt5Quick REQUIRED) find_package(Qt5Quick REQUIRED)
@ -33,12 +21,12 @@ find_package(Qt5Network REQUIRED)
find_package(Qt5Widgets REQUIRED) find_package(Qt5Widgets REQUIRED)
find_package(Qt5WebKit REQUIRED) find_package(Qt5WebKit REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED) find_package(Qt5WebKitWidgets REQUIRED)
qt5_wrap_ui(ui_Main.h Main.ui) qt5_wrap_ui(ui_Main.h Main.ui)
# Set name of binary and add_executable() # Set name of binary and add_executable()
if (APPLE) if (APPLE)
set(EXECUTEABLE AlethZero) set(EXECUTEABLE AlethZero)
set(CMAKE_INSTALL_PREFIX ./)
set(BIN_INSTALL_DIR ".") set(BIN_INSTALL_DIR ".")
set(DOC_INSTALL_DIR ".") set(DOC_INSTALL_DIR ".")
@ -50,9 +38,14 @@ if (APPLE)
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 ${EXECUTEABLE}) set(MACOSX_BUNDLE_BUNDLE_NAME ${EXECUTEABLE})
set(MACOSX_BUNDLE_ICON_FILE alethzero)
include(BundleUtilities) include(BundleUtilities)
add_executable(${EXECUTEABLE} MACOSX_BUNDLE Main.ui ${SRC_LIST}) add_executable(${EXECUTEABLE} MACOSX_BUNDLE alethzero.icns Main.ui ${SRC_LIST})
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)
SET_SOURCE_FILES_PROPERTIES(${MACOSX_BUNDLE_ICON_FILE}.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
else () else ()
set(EXECUTEABLE alethzero) set(EXECUTEABLE alethzero)
add_executable(${EXECUTEABLE} Main.ui ${SRC_LIST}) add_executable(${EXECUTEABLE} Main.ui ${SRC_LIST})
@ -62,36 +55,29 @@ qt5_use_modules(${EXECUTEABLE} Core)# Gui Widgets Network WebKit WebKitWidgets)
target_link_libraries(${EXECUTEABLE} qethereum ethereum evm ethcore secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface ethential) target_link_libraries(${EXECUTEABLE} qethereum ethereum evm ethcore secp256k1 gmp ${CRYPTOPP_LS} serpent lll evmface ethential)
if (APPLE) if (APPLE)
set_target_properties(${EXECUTEABLE} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/EthereumMacOSXBundleInfo.plist.in") # First have qt5 install plugins and frameworks
add_custom_command(TARGET ${EXECUTEABLE} POST_BUILD
SET_SOURCE_FILES_PROPERTIES(${EXECUTEABLE} PROPERTIES MACOSX_PACKAGE_LOCATION MacOS) COMMAND /usr/local/opt/qt5/bin/macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTEABLE}.app
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# 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. # This tool and next will inspect linked libraries in order to determine which dependencies are required
set(generator_lowercase "${CMAKE_GENERATOR}") if (${CMAKE_CFG_INTDIR} STREQUAL ".")
string(TOLOWER "${CMAKE_GENERATOR}" generator_lowercase) set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTEABLE}.app")
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 () else ()
set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}") set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/\$ENV{CONFIGURATION}/${EXECUTEABLE}.app")
endif () endif ()
set(APPS ${binary_build_dir}/${EXECUTEABLE}.app)
# 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)
install(CODE " install(CODE "
include(BundleUtilities) include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS 1) set(BU_CHMOD_BUNDLE_ITEMS 1)
fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") fixup_bundle(\"${APP_BUNDLE_PATH}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\")
" COMPONENT RUNTIME ) " COMPONENT RUNTIME )
# Cleanup duplicate libs from macdeployqt
add_custom_target(addframeworks ALL install(CODE "
COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTEABLE}.app file(GLOB LINGER_RM \"${APP_BUNDLE_PATH}/Contents/Frameworks/*.dylib\")
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} if (LINGER_RM)
DEPENDS ${PROJECT_NAME} file(REMOVE \${LINGER_RM})
) endif ()
")
elseif ("${TARGET_PLATFORM}" STREQUAL "w64") elseif ("${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")

11
libqethereum/CMakeLists.txt

@ -79,18 +79,11 @@ if (APPLE)
set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}") set(binary_build_dir "${CMAKE_CURRENT_BINARY_DIR}")
endif () endif ()
set(APPS ${binary_build_dir}/${EXECUTABLE}.app) set(APPS ${binary_build_dir}/${EXECUTABLE})
# 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)
install(CODE "
include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS 1)
fixup_bundle(\"${APPS}\" \"${BUNDLELIBS}\" \"../libethereum ../secp256k1\")
" COMPONENT RUNTIME )
if (${ADDFRAMEWORKS}) if (${ADDFRAMEWORKS})
add_custom_target(addframeworks ALL add_custom_target(addframeworks ALL
COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTABLE}.app COMMAND /usr/local/opt/qt5/bin/macdeployqt ${binary_build_dir}/${EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DEPENDS ${PROJECT_NAME} DEPENDS ${PROJECT_NAME}
) )

9
secp256k1/CMakeLists.txt

@ -5,7 +5,6 @@ set(CMAKE_ASM_COMPILER "yasm")
set(EXECUTABLE secp256k1) set(EXECUTABLE secp256k1)
file(GLOB HEADERS "*.h") file(GLOB HEADERS "*.h")
#aux_source_directory(. SRC_LIST)
if ("${TARGET_PLATFORM}" STREQUAL "w64") if ("${TARGET_PLATFORM}" STREQUAL "w64")
add_custom_command( add_custom_command(
@ -23,10 +22,10 @@ if ("${TARGET_PLATFORM}" STREQUAL "w64")
endif() endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -DUSE_FIELD_5X52 -DUSE_FIELD_5X52_ASM -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -DUSE_FIELD_5X52 -DUSE_FIELD_5X52_ASM -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM")
elseif(APPLE) elseif(APPLE)
# set(CMAKE_INSTALL_PREFIX ../lib)
if(ETH_STATIC) if(ETH_STATIC)
add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c field_5x52_asm.asm) add_library(${EXECUTABLE} STATIC ${EXECUTABLE}.c field_5x52_asm.asm)
else() else()
find_library(GMP_LS gmp /usr/local/lib)
add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c field_5x52_asm.asm) add_library(${EXECUTABLE} SHARED ${EXECUTABLE}.c field_5x52_asm.asm)
endif() endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DUSE_FIELD_GMP -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DUSE_FIELD_GMP -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM")
@ -39,7 +38,11 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DUSE_FIELD_GMP -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DUSE_FIELD_GMP -DUSE_NUM_GMP -DUSE_FIELD_INV_NUM")
endif() endif()
target_link_libraries(${EXECUTABLE} gmp) if (NOT GMP_LS)
set(GMP_LS gmp)
endif ()
target_link_libraries(${EXECUTABLE} ${GMP_LS})
install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( TARGETS ${EXECUTABLE} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib )
install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} )

Loading…
Cancel
Save