Merge pull request #1 from arhag/mingw-build

Changes to fc to get MinGW cross-compilation working
This commit is contained in:
Daniel Larimer 2016-05-23 16:54:41 -04:00
commit bc5947d6c7
13 changed files with 41 additions and 25 deletions

3
.gitmodules vendored
View file

@ -4,3 +4,6 @@
[submodule "vendor/websocketpp"] [submodule "vendor/websocketpp"]
path = vendor/websocketpp path = vendor/websocketpp
url = https://github.com/zaphoyd/websocketpp.git url = https://github.com/zaphoyd/websocketpp.git
[submodule "vendor/diff-match-patch-cpp-stl"]
path = vendor/diff-match-patch-cpp-stl
url = https://github.com/leutloff/diff-match-patch-cpp-stl

View file

@ -93,7 +93,7 @@ endif ( WIN32 )
IF( WIN32 ) IF( WIN32 )
MESSAGE(STATUS "Configuring fc to build on Win32") MESSAGE(STATUS "Configuring fc to build on Win32")
set( RPCRT4 Rpcrt4 ) set( RPCRT4 rpcrt4 )
#boost #boost
SET(BOOST_ROOT $ENV{BOOST_ROOT}) SET(BOOST_ROOT $ENV{BOOST_ROOT})
@ -110,7 +110,7 @@ IF( WIN32 )
SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES}) SET(Boost_LIBRARIES ${BOOST_LIBRARIES_TEMP} ${Boost_LIBRARIES})
ENDIF() ENDIF()
set( PLATFORM_SPECIFIC_LIBS WS2_32.lib Userenv.lib) set( PLATFORM_SPECIFIC_LIBS wsock32.lib ws2_32.lib userenv.lib)
# iphlpapi.lib # iphlpapi.lib
ELSE(WIN32) ELSE(WIN32)
@ -272,9 +272,13 @@ IF(WIN32)
# autodetecting code to do the right thing. # autodetecting code to do the right thing.
_WEBSOCKETPP_CPP11_CHRONO_ _WEBSOCKETPP_CPP11_CHRONO_
) )
# Activate C++ exception handling, assume extern C calls don't throw if( MSVC )
# Add /U options to be sure settings specific to dynamic boost link are ineffective # Activate C++ exception handling, assume extern C calls don't throw
target_compile_options(fc PUBLIC /EHsc /UBOOST_ALL_DYN_LINK /UBOOST_LINKING_PYTHON /UBOOST_DEBUG_PYTHON) # Add /U options to be sure settings specific to dynamic boost link are ineffective
target_compile_options(fc PUBLIC /EHsc /UBOOST_ALL_DYN_LINK /UBOOST_LINKING_PYTHON /UBOOST_DEBUG_PYTHON)
elseif( MINGW )
# Put MinGW specific compiler settings here
endif()
ELSE() ELSE()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall")
@ -297,6 +301,7 @@ target_include_directories(fc
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
${Boost_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR}
"vendor/diff-match-patch-cpp-stl"
"${readline_includes}" "${readline_includes}"
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -319,11 +324,11 @@ endif(MSVC)
IF(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\.(a|lib)$") IF(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\.(a|lib)$")
IF(WIN32) IF(MSVC)
add_definitions(/DBOOST_TEST_DYN_LINK) add_definitions(/DBOOST_TEST_DYN_LINK)
ELSE(WIN32) ELSE(MSVC)
add_definitions(-DBOOST_TEST_DYN_LINK) add_definitions(-DBOOST_TEST_DYN_LINK)
ENDIF(WIN32) ENDIF(MSVC)
ENDIF() ENDIF()
add_executable( api tests/api.cpp ) add_executable( api tests/api.cpp )
@ -489,8 +494,15 @@ ELSE()
ENDIF() ENDIF()
IF(WIN32) IF(WIN32)
SET(POST_BUILD_STEP_COMMANDS ${POST_BUILD_STEP_COMMANDS} IF("${OPENSSL_ROOT_DIR}" STREQUAL "")
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf" "${OPENSSL_CONF_TARGET}/openssl.cnf") get_filename_component(OPENSSL_ROOT_DIR "${OPENSSL_INCLUDE_DIR}/.." REALPATH)
ENDIF()
SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/ssl/openssl.cnf")
IF(MINGW)
SET(OPENSSL_CONF_SOURCE "${OPENSSL_ROOT_DIR}/openssl.cnf")
ENDIF(MINGW)
SET(POST_BUILD_STEP_COMMANDS ${POST_BUILD_STEP_COMMANDS}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENSSL_CONF_SOURCE}" "${OPENSSL_CONF_TARGET}/openssl.cnf")
ENDIF(WIN32) ENDIF(WIN32)
ADD_CUSTOM_COMMAND(TARGET fc POST_BUILD ${POST_BUILD_STEP_COMMANDS} ADD_CUSTOM_COMMAND(TARGET fc POST_BUILD ${POST_BUILD_STEP_COMMANDS}

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#ifdef _MSC_VER #ifdef _WIN32
# include <stdlib.h> # include <stdlib.h>
# define bswap_64(x) _byteswap_uint64(x) # define bswap_64(x) _byteswap_uint64(x)
#elif defined(__APPLE__) #elif defined(__APPLE__)

View file

@ -2848,7 +2848,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h,
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
#if defined(_MSC_VER) || defined(__MINGW64__) #if defined(_MSC_VER)
static FILE *mz_fopen(const char *pFilename, const char *pMode) static FILE *mz_fopen(const char *pFilename, const char *pMode)
{ {
FILE* pFile = NULL; FILE* pFile = NULL;

View file

@ -16,8 +16,8 @@
#endif #endif
#include <openssl/crypto.h> #include <openssl/crypto.h>
#if defined(_MSC_VER) #if defined(_WIN32)
# include <Windows.h> # include <windows.h>
#endif #endif
namespace fc { namespace fc {
@ -396,7 +396,7 @@ boost::mutex* openssl_thread_config::openssl_mutexes = nullptr;
unsigned long openssl_thread_config::get_thread_id() unsigned long openssl_thread_config::get_thread_id()
{ {
#ifdef _MSC_VER #ifdef _WIN32
return (unsigned long)::GetCurrentThreadId(); return (unsigned long)::GetCurrentThreadId();
#else #else
return (unsigned long)(&fc::thread::current()); // TODO: should expose boost thread id return (unsigned long)(&fc::thread::current()); // TODO: should expose boost thread id

View file

@ -75,7 +75,7 @@ static uint32_t UNALIGNED_LOAD32(const char *p) {
return result; return result;
} }
#ifdef _MSC_VER #ifdef _WIN32
#include <stdlib.h> #include <stdlib.h>
#define bswap_32(x) _byteswap_ulong(x) #define bswap_32(x) _byteswap_ulong(x)

View file

@ -5,7 +5,7 @@
#include <fc/crypto/openssl.hpp> #include <fc/crypto/openssl.hpp>
#include <fc/crypto/ripemd160.hpp> #include <fc/crypto/ripemd160.hpp>
#ifdef _MSC_VER #ifdef _WIN32
# include <malloc.h> # include <malloc.h>
#else #else
# include <alloca.h> # include <alloca.h>

View file

@ -12,7 +12,7 @@
#include <assert.h> #include <assert.h>
#include <secp256k1.h> #include <secp256k1.h>
#ifdef _MSC_VER #if _WIN32
# include <malloc.h> # include <malloc.h>
#else #else
# include <alloca.h> # include <alloca.h>

View file

@ -11,10 +11,10 @@
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#ifdef WIN32 #ifdef _WIN32
# include <Windows.h> # include <windows.h>
# include <UserEnv.h> # include <userenv.h>
# include <ShlObj.h> # include <shlobj.h>
#else #else
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>

View file

@ -8,7 +8,7 @@
#include <fc/exception/exception.hpp> #include <fc/exception/exception.hpp>
#if defined _WIN32 || defined WIN32 || defined OS_WIN64 || defined _WIN64 || defined WIN64 || defined WINNT #if defined _WIN32 || defined WIN32 || defined OS_WIN64 || defined _WIN64 || defined WIN64 || defined WINNT
# include <MSTcpIP.h> # include <mstcpip.h>
#endif #endif
namespace fc { namespace fc {

View file

@ -5,7 +5,7 @@
#include "thread_d.hpp" #include "thread_d.hpp"
#if defined(_MSC_VER) && !defined(NDEBUG) #if defined(_MSC_VER) && !defined(NDEBUG)
# include <Windows.h> # include <windows.h>
const DWORD MS_VC_EXCEPTION=0x406D1388; const DWORD MS_VC_EXCEPTION=0x406D1388;
#pragma pack(push,8) #pragma pack(push,8)

1
vendor/diff-match-patch-cpp-stl vendored Submodule

@ -0,0 +1 @@
Subproject commit aee799a31d08977b166fb19cad794730717e3304

View file

@ -2,7 +2,7 @@
IF( APPLE ) IF( APPLE )
add_definitions( -DOSX ) add_definitions( -DOSX )
ELSEIF( WIN32 ) ELSEIF( WIN32 )
add_definitions( -DWIN32 )
ELSE() ELSE()
add_definitions( -DLINUX ) add_definitions( -DLINUX )
ENDIF() ENDIF()