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"
@ -60,6 +67,7 @@ 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}
${PASS_STRENGTH_FILES}
${QR_CODE_FILES} ${QR_CODE_FILES}
${QML_QRC} ${QML_QRC}
) )
@ -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,7 +118,6 @@ 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