Add support for msys/mingw32

This commit is contained in:
TheCharlatan 2019-10-02 17:11:59 +02:00
parent 8dd2a20ff8
commit d06ae80e0a
3 changed files with 117 additions and 36 deletions

View file

@ -65,8 +65,7 @@ endif()
# Include password strength library # Include password strength library
if(ENABLE_PASS_STRENGTH_METER) if(ENABLE_PASS_STRENGTH_METER)
find_library(ZXCVBN_LIBRARY zxcvbn) message(STATUS "Buildin with pass strength meter support.")
message(STATUS "Found zxcvbn library: ${ZXCVBN_LIBRARY}")
else() else()
add_definitions(-DDISABLE_PASS_STRENGTH_METER) add_definitions(-DDISABLE_PASS_STRENGTH_METER)
endif() endif()
@ -175,9 +174,63 @@ if(LINUX)
endif() endif()
endif() endif()
if(MINGW)
string(REGEX MATCH "^[^/]:/[^/]*" msys2_install_path "${CMAKE_C_COMPILER}")
message(STATUS "MSYS location: ${msys2_install_path}")
set(CMAKE_INCLUDE_PATH "${msys2_install_path}/mingw${ARCH_WIDTH}/include")
# This is necessary because otherwise CMake will make Boost libraries -lfoo
# rather than a full path. Unfortunately, this makes the shared libraries get
# linked due to a bug in CMake which misses putting -static flags around the
# -lfoo arguments.
set(DEFLIB ${msys2_install_path}/mingw${ARCH_WIDTH}/lib)
list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_DIRECTORIES ${DEFLIB})
list(REMOVE_ITEM CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES ${DEFLIB})
endif()
message(STATUS "Using Boost include dir at ${Boost_INCLUDE_DIRS}") message(STATUS "Using Boost include dir at ${Boost_INCLUDE_DIRS}")
message(STATUS "Using Boost libraries at ${Boost_LIBRARIES}") message(STATUS "Using Boost libraries at ${Boost_LIBRARIES}")
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj")
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi;crypt32;bcrypt)
if(DEPENDS)
set(ICU_LIBRARIES icuio icui18n icuuc icudata icutu iconv)
else()
set(ICU_LIBRARIES icuio icuin icuuc icudt icutu iconv)
endif()
elseif(APPLE OR OPENBSD OR ANDROID)
set(EXTRA_LIBRARIES "")
elseif(FREEBSD)
set(EXTRA_LIBRARIES execinfo)
elseif(DRAGONFLY)
find_library(COMPAT compat)
set(EXTRA_LIBRARIES execinfo ${COMPAT})
elseif(CMAKE_SYSTEM_NAME MATCHES "(SunOS|Solaris)")
set(EXTRA_LIBRARIES socket nsl resolv)
elseif(NOT MSVC AND NOT DEPENDS)
find_library(RT rt)
set(EXTRA_LIBRARIES ${RT})
endif()
list(APPEND EXTRA_LIBRARIES ${CMAKE_DL_LIBS})
if (HIDAPI_FOUND OR LibUSB_COMPILE_TEST_PASSED)
if (APPLE)
if(DEPENDS)
list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework IOKit")
else()
find_library(COREFOUNDATION CoreFoundation)
find_library(IOKIT IOKit)
list(APPEND EXTRA_LIBRARIES ${IOKIT})
list(APPEND EXTRA_LIBRARIES ${COREFOUNDATION})
endif()
endif()
if (WIN32)
list(APPEND EXTRA_LIBRARIES setupapi)
endif()
endif()
add_subdirectory(src) add_subdirectory(src)
# Required to make wallet_merged build before the gui # Required to make wallet_merged build before the gui

View file

@ -1,11 +1,32 @@
ANDROID_STANDALONE_TOOLCHAIN_PATH ?= /usr/local/toolchain
dotgit=$(shell ls -d .git/config)
ifneq ($(dotgit), .git/config)
USE_SINGLE_BUILDDIR=1
endif
subbuilddir:=$(shell echo `uname | sed -e 's|[:/\\ \(\)]|_|g'`/`git branch | grep '\* ' | cut -f2- -d' '| sed -e 's|[:/\\ \(\)]|_|g'`)
ifeq ($(USE_SINGLE_BUILDDIR),)
builddir := build/"$(subbuilddir)"
topdir := ../../../..
deldirs := $(builddir)
else
builddir := build
topdir := ../..
deldirs := $(builddir)/debug $(builddir)/release $(builddir)/fuzz
endif
default: default:
mkdir -p build && cd build && cmake -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release .. && $(MAKE) mkdir -p build && cd build && cmake -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release .. && $(MAKE)
debug: debug:
mkdir -p build && cd build && ccmake .. && $(MAKE) VERBOSE=1 mkdir -p build && cd build && ccmake .. && $(MAKE) VERBOSE=1
devmode: devmode:
mkdir -p build && cd build && cmake -D STATIC=ON -D ARCH="x86-64" -D DEV_MODE=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release .. && $(MAKE) mkdir -p build && cd build && cmake -D ARCH="x86-64" -D DEV_MODE=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release .. && $(MAKE)
clean: clean:
mkdir -p build && cd build && rm -rf * mkdir -p build && cd build && rm -rf *
scanner: scanner:
mkdir -p build && cd build && cmake -D STATIC=ON -D ARCH="x86-64" -D DEV_MODE=ON -D WITH_SCANNER=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release .. && $(MAKE) mkdir -p build && cd build && cmake -D ARCH="x86-64" -D DEV_MODE=ON -D WITH_SCANNER=ON -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release .. && $(MAKE)
debug-static-win64:
mkdir -p $(builddir)/debug && cd $(builddir)/debug && cmake -G "MSYS Makefiles" -D DEV_MODE=ON -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Debug -D BUILD_TAG="win-x64" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=c:/msys64 -D MINGW=ON $(topdir) && $(MAKE)

View file

@ -48,6 +48,13 @@ file(GLOB SOURCE_FILES
"qt/*.cpp" "qt/*.cpp"
) )
if(ENABLE_PASS_STRENGTH_METER)
file(GLOB PASS_STRENGTH_FILES
"zxcvbn-c/zxcvbn.h"
"zxcvbn-c/zxcvbn.c"
)
endif()
if(WITH_SCANNER) if(WITH_SCANNER)
file(GLOB QR_CODE_FILES file(GLOB QR_CODE_FILES
"QR-Code-generator/*.h" "QR-Code-generator/*.h"
@ -59,10 +66,11 @@ endif()
message(STATUS ${QML_QRC}) message(STATUS ${QML_QRC})
add_executable(monero-gui main/main.cpp add_executable(monero-gui main/main.cpp
${SOURCE_FILES} ${SOURCE_FILES}
${QR_CODE_FILES} ${PASS_STRENGTH_FILES}
${QML_QRC} ${QR_CODE_FILES}
) ${QML_QRC}
)
# OpenGL # OpenGL
target_include_directories(monero-gui PUBLIC ${OPENGL_INCLUDE_DIR}) target_include_directories(monero-gui PUBLIC ${OPENGL_INCLUDE_DIR})
@ -83,7 +91,7 @@ target_include_directories(monero-gui PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/model ${CMAKE_CURRENT_SOURCE_DIR}/model
${CMAKE_CURRENT_SOURCE_DIR}/QR-Code-generator ${CMAKE_CURRENT_SOURCE_DIR}/QR-Code-generator
${CMAKE_CURRENT_SOURCE_DIR}/QR-Code-scanner ${CMAKE_CURRENT_SOURCE_DIR}/QR-Code-scanner
${CMAKE_CURRENT_SOURCE_DIR}/daemon/zxcvbn-c ${CMAKE_CURRENT_SOURCE_DIR}/zxcvbn-c
${LibUSB_INCLUDE_DIRS} ${LibUSB_INCLUDE_DIRS}
${HIDAPI_INCLUDE_DIRS} ${HIDAPI_INCLUDE_DIRS}
${X11_INCLUDE_DIR} ${X11_INCLUDE_DIR}
@ -110,31 +118,30 @@ if(DEVICE_TREZOR_READY)
endif() endif()
target_link_libraries(monero-gui target_link_libraries(monero-gui
${ZXCVBN_LIBRARY} ${CMAKE_BINARY_DIR}/lib/libwallet_merged.a
${CMAKE_BINARY_DIR}/lib/libwallet_merged.a ${LMDB_LIBRARY}
${LMDB_LIBRARY} ${CMAKE_BINARY_DIR}/monero/contrib/epee/src/libepee.a
${CMAKE_BINARY_DIR}/monero/contrib/epee/src/libepee.a ${CMAKE_BINARY_DIR}/monero/external/unbound/libunbound.a
${CMAKE_BINARY_DIR}/monero/external/unbound/libunbound.a ${SODIUM_LIBRARY}
${SODIUM_LIBRARY} ${CMAKE_BINARY_DIR}/monero/external/easylogging++/libeasylogging.a
${CMAKE_BINARY_DIR}/monero/external/easylogging++/libeasylogging.a ${CMAKE_BINARY_DIR}/monero/src/blockchain_db/libblockchain_db.a
${CMAKE_BINARY_DIR}/monero/src/blockchain_db/libblockchain_db.a ${CMAKE_BINARY_DIR}/monero/external/randomx/librandomx.a
${CMAKE_BINARY_DIR}/monero/external/randomx/librandomx.a ${CMAKE_BINARY_DIR}/monero/src/hardforks/libhardforks.a
${CMAKE_BINARY_DIR}/monero/src/hardforks/libhardforks.a ${Boost_LIBRARIES}
${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}
${OPENSSL_LIBRARIES} ${CMAKE_DL_LIBS}
${CMAKE_DL_LIBS} ${LibUSB_LIBRARIES}
${LibUSB_LIBRARIES} ${HIDAPI_LIBRARIES}
${HIDAPI_LIBRARIES} Qt5::Core
Qt5::Core Qt5::Quick
Qt5::Quick Qt5::Widgets
Qt5::Widgets Qt5::Gui
Qt5::Gui Qt5::Network
Qt5::Network Qt5::Qml
Qt5::Qml Qt5::Multimedia
Qt5::Multimedia Qt5::Xml
Qt5::Xml Qt5::XmlPatterns
Qt5::XmlPatterns Qt5::Svg
Qt5::Svg
) )
if(WITH_SCANNER) if(WITH_SCANNER)
@ -148,5 +155,5 @@ if(WITH_SCANNER)
endif() endif()
install(TARGETS monero-gui install(TARGETS monero-gui
DESTINATION ${CMAKE_INSTALL_PREFIX} DESTINATION ${CMAKE_INSTALL_PREFIX}
) )