Browse Source

cmake can now build to linux and windows. Use -DTARGET_PLATFORM=<linux|w64>

cl-refactor
Eric Lombrozo 11 years ago
parent
commit
6907a75623
  1. 28
      CMakeLists.txt
  2. 26
      alethzero/CMakeLists.txt
  3. 23
      eth/CMakeLists.txt
  4. 20
      libethereum/CMakeLists.txt
  5. 23
      test/CMakeLists.txt
  6. 4
      windows/qt_plugin_import.cpp

28
CMakeLists.txt

@ -19,6 +19,31 @@ elseif (CMAKE_COMPILER_IS_MSVC)
else () else ()
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown") set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown")
endif () endif ()
set(TARGET_PLATFORM CACHE STRING "linux")
if (${TARGET_PLATFORM} STREQUAL "w64")
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_CXX_LIBRARY_ARCHITECTURE x86_64-w64-mingw32)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
set(CMAKE_AR x86_64-w64-mingw32-ar)
set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib)
set(CMAKE_EXECUTABLE_SUFFIX .exe)
set(CMAKE_FIND_ROOT_PATH
/usr/x86_64-w64-mingw32
)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_INSTALL_PREFIX /usr/x86_64-w64-mingw32)
endif()
# Initialize CXXFLAGS. # Initialize CXXFLAGS.
set(CMAKE_CXX_FLAGS "-Wall -std=c++11") set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
@ -44,6 +69,8 @@ else ()
message(FATAL_ERROR "Your C++ compiler does not support C++11.") message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif () endif ()
if (${TARGET_PLATFORM} STREQUAL "w64")
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(ID cryptlib.h find_path(ID cryptlib.h
/usr/include/cryptopp /usr/include/cryptopp
@ -93,6 +120,7 @@ mark_as_advanced(CRYPTOPP_INCLUDE_DIR CRYPTOPP_LIBRARIES)
# Always "found", given last block. # Always "found", given last block.
include_directories(${CRYPTOPP_INCLUDE_DIR}) include_directories(${CRYPTOPP_INCLUDE_DIR})
link_directories(${CRYPTOPP_LIBRARIES}) link_directories(${CRYPTOPP_LIBRARIES})
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
link_directories(/usr/local/lib) link_directories(/usr/local/lib)

26
alethzero/CMakeLists.txt

@ -1,4 +1,5 @@
cmake_policy(SET CMP0015 NEW) cmake_policy(SET CMP0015 NEW)
cmake_policy(SET CMP0020 NEW)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
aux_source_directory(. SRC_LIST) aux_source_directory(. SRC_LIST)
@ -15,12 +16,35 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(/usr/local/Cellar/qt5/5.2.0/include /usr/local/include) include_directories(/usr/local/Cellar/qt5/5.2.0/include /usr/local/include)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (${TARGET_PLATFORM} STREQUAL "w64")
set(SRC_LIST ${SRC_LIST} ../windows/qt_plugin_import.cpp)
else ()
endif ()
find_package(Qt5Widgets REQUIRED) find_package(Qt5Widgets REQUIRED)
add_executable(alethzero Main.ui ${SRC_LIST}) add_executable(alethzero Main.ui ${SRC_LIST})
qt5_wrap_ui(ui_Main.h Main.ui) qt5_wrap_ui(ui_Main.h Main.ui)
qt5_use_modules(alethzero Widgets Network )
target_link_libraries(alethzero ethereum) target_link_libraries(alethzero ethereum)
if (${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)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
else ()
target_link_libraries(alethzero boost_system)
target_link_libraries(alethzero boost_filesystem)
find_package(Threads REQUIRED)
target_link_libraries(alethzero ${CMAKE_THREAD_LIBS_INIT})
endif ()
qt5_use_modules(alethzero Core Gui Widgets Network)
install( TARGETS alethzero RUNTIME DESTINATION bin ) install( TARGETS alethzero RUNTIME DESTINATION bin )

23
eth/CMakeLists.txt

@ -7,7 +7,26 @@ link_directories(../libethereum)
add_executable(eth ${SRC_LIST}) add_executable(eth ${SRC_LIST})
if (${TARGET_PLATFORM} STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
target_link_libraries(eth gcc)
target_link_libraries(eth gdi32)
target_link_libraries(eth ws2_32)
target_link_libraries(eth mswsock)
target_link_libraries(eth shlwapi)
target_link_libraries(eth iphlpapi)
target_link_libraries(eth cryptopp)
target_link_libraries(eth boost_system-mt-s)
target_link_libraries(eth boost_filesystem-mt-s)
target_link_libraries(eth boost_thread_win32-mt-s)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
else ()
target_link_libraries(eth ${CRYPTOPP_LIBRARIES})
target_link_libraries(eth boost_system)
target_link_libraries(eth boost_filesystem)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries(eth ${CMAKE_THREAD_LIBS_INIT})
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(/usr/local/include) include_directories(/usr/local/include)
@ -16,11 +35,7 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(eth ethereum) target_link_libraries(eth ethereum)
target_link_libraries(eth miniupnpc) target_link_libraries(eth miniupnpc)
target_link_libraries(eth leveldb) target_link_libraries(eth leveldb)
target_link_libraries(eth ${CRYPTOPP_LIBRARIES})
target_link_libraries(eth gmp) target_link_libraries(eth gmp)
target_link_libraries(eth boost_system)
target_link_libraries(eth boost_filesystem)
target_link_libraries(eth ${CMAKE_THREAD_LIBS_INIT})
install( TARGETS eth DESTINATION bin ) install( TARGETS eth DESTINATION bin )

20
libethereum/CMakeLists.txt

@ -1,21 +1,35 @@
cmake_policy(SET CMP0015 NEW) cmake_policy(SET CMP0015 NEW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB")
aux_source_directory(. SRC_LIST) aux_source_directory(. SRC_LIST)
add_library(ethereum ${SRC_LIST}) add_library(ethereum ${SRC_LIST})
file(GLOB HEADERS "*.h") file(GLOB HEADERS "*.h")
find_package(Threads REQUIRED)
include_directories(../secp256k1) include_directories(../secp256k1)
target_link_libraries(ethereum secp256k1) target_link_libraries(ethereum secp256k1)
target_link_libraries(ethereum miniupnpc) target_link_libraries(ethereum miniupnpc)
target_link_libraries(ethereum leveldb) target_link_libraries(ethereum leveldb)
target_link_libraries(ethereum ${CRYPTOPP_LIBRARIES})
target_link_libraries(ethereum gmp) target_link_libraries(ethereum gmp)
if(${TARGET_PLATFORM} STREQUAL "w64")
include_directories(/usr/x86_64-w64-mingw32/include/cryptopp)
target_link_libraries(ethereum cryptopp)
target_link_libraries(ethereum boost_system-mt-s)
target_link_libraries(ethereum boost_filesystem-mt-s)
target_link_libraries(ethereum boost_thread_win32-mt-s)
target_link_libraries(ethereum iphlpapi)
target_link_libraries(ethereum ws2_32)
target_link_libraries(ethereum mswsock)
target_link_libraries(ethereum shlwapi)
else ()
target_link_libraries(ethereum ${CRYPTOPP_LIBRARIES})
target_link_libraries(ethereum boost_system) target_link_libraries(ethereum boost_system)
target_link_libraries(ethereum boost_filesystem) target_link_libraries(ethereum boost_filesystem)
find_package(Threads REQUIRED)
target_link_libraries(ethereum ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(ethereum ${CMAKE_THREAD_LIBS_INIT})
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(/usr/local/include) include_directories(/usr/local/include)

23
test/CMakeLists.txt

@ -8,7 +8,26 @@ link_directories(../libethereum)
add_executable(testeth ${SRC_LIST}) add_executable(testeth ${SRC_LIST})
if (${TARGET_PLATFORM} STREQUAL "w64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
target_link_libraries(testeth gcc)
target_link_libraries(testeth gdi32)
target_link_libraries(testeth ws2_32)
target_link_libraries(testeth mswsock)
target_link_libraries(testeth shlwapi)
target_link_libraries(testeth iphlpapi)
target_link_libraries(testeth cryptopp)
target_link_libraries(testeth boost_system-mt-s)
target_link_libraries(testeth boost_filesystem-mt-s)
target_link_libraries(testeth boost_thread_win32-mt-s)
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
else ()
target_link_libraries(testeth ${CRYPTOPP_LIBRARIES})
target_link_libraries(testeth boost_system)
target_link_libraries(testeth boost_filesystem)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
target_link_libraries(testeth ${CMAKE_THREAD_LIBS_INIT})
endif ()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(/usr/local/include) include_directories(/usr/local/include)
@ -17,8 +36,4 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(testeth ethereum) target_link_libraries(testeth ethereum)
target_link_libraries(testeth secp256k1) target_link_libraries(testeth secp256k1)
target_link_libraries(testeth miniupnpc) target_link_libraries(testeth miniupnpc)
target_link_libraries(testeth ${CRYPTOPP_LIBRARIES})
target_link_libraries(testeth gmp) target_link_libraries(testeth gmp)
target_link_libraries(testeth boost_system)
target_link_libraries(testeth boost_filesystem)
target_link_libraries(testeth ${CMAKE_THREAD_LIBS_INIT})

4
windows/qt_plugin_import.cpp

@ -0,0 +1,4 @@
// This file is autogenerated by qmake. It imports static plugin classes for
// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables.
#include <QtPlugin>
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
Loading…
Cancel
Save