Maximilien Siavelis
2018-01-05 17d71d9ef8adad095b8b06182bc1febca02899d0
fix compilation with MINGW
7个文件已修改
49 ■■■■ 已修改文件
CMakeLists.txt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/base/StringUtils.cpp 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/os/win/os-win.c 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/library/pc-identifiers.c 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tools/base_lib/CMakeLists.txt 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tools/base_lib/CryptoHelper.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tools/bootstrap/CMakeLists.txt 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
CMakeLists.txt
@@ -29,7 +29,7 @@
    set(RELEASE_BUILD 0)
endif(CMAKE_BUILD_TYPE)
if(WIN32)
if(MSVC)
    SET(PLATFORM_LIBS "")
    include(target_arch)
@@ -43,7 +43,7 @@
    endif()
    SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib ) #${CMAKE_FIND_LIBRARY_SUFFIXES}
    add_definitions("/D_CRT_SECURE_NO_WARNINGS")
else(WIN32)
else(MSVC)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -fmessage-length=0 -std=c++11 -Wuninitialized -fPIC") #-Wall
    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -fmessage-length=0 -Wall -Wuninitialized -fPIC") 
    #use static libraries in release to make it easier to distribute it
@@ -59,7 +59,7 @@
    IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
        SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix" FORCE)
    ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
endif(WIN32)
endif(MSVC)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG>)
@@ -75,11 +75,16 @@
add_definitions(-DBOOST_ALL_NO_LIB) #Disable Boost Microsoft magic, all dependencies are handled by cmake
add_definitions(-DBOOST_LIB_DIAGNOSTIC) #Check it is really disabled
if(NOT WIN32)
if(NOT MSVC)
    #find a static version of openssl crypto library
    find_package(OpenSSL REQUIRED)
    include_directories(${OPENSSL_INCLUDE_DIR})
    if(MINGW)
        list(APPEND EXTERNAL_LIBS "-lcrypto -liphlpapi")
    else(MINGW)
    list(APPEND EXTERNAL_LIBS ${OPENSSL_CRYPTO_LIBRARY})
    endif(MINGW)
    MESSAGE(STATUS "Found openssl version ${OPENSSL_VERSION}")
    
    #Zlib required when openssl version < 1.0.1f
@@ -94,7 +99,7 @@
        list(APPEND EXTERNAL_LIBS ${DBUS_LIBRARIES})
    endif(USE_DBUS_IDENTIFIER)    
    list(APPEND EXTERNAL_LIBS dl)
endif(NOT WIN32)
endif(NOT MSVC)
FIND_PACKAGE(Doxygen)
src/library/base/StringUtils.cpp
@@ -11,8 +11,9 @@
#include <string>
#include <cstring>
#include <algorithm>
#include <stdexcept>
#ifdef WIN32
#ifdef _WIN32
#include <time.h> //mktime under windows
#endif
src/library/os/win/os-win.c
@@ -1,4 +1,8 @@
#ifdef __MINGW32__
#include <windows.h>
#else
#include <Windows.h>
#endif
#include <iphlpapi.h>
//definition of size_t
#include <stdlib.h>
src/library/pc-identifiers.c
@@ -16,8 +16,12 @@
#include <stdbool.h>
#include <valgrind/memcheck.h>
#else
#ifdef __MINGW32__
#include <windows.h>
#else
#include <Windows.h>
#endif
#endif
static FUNCTION_RETURN generate_disk_pc_id(PcIdentifier * identifiers,
        unsigned int * num_identifiers, bool use_label);
src/tools/base_lib/CMakeLists.txt
@@ -1,17 +1,17 @@
if(WIN32)
if(MSVC)
ADD_LIBRARY(
    tools_base STATIC
    CryptoHelper.cpp
    win/CryptoHelperWindows.cpp
)
else(WIN32)
else(MSVC)
ADD_LIBRARY(
    tools_base STATIC
    CryptoHelper.cpp
    linux/CryptoHelperLinux.cpp
)
ENDIF(WIN32)
ENDIF(MSVC)
target_link_libraries(
     tools_base
src/tools/base_lib/CryptoHelper.cpp
@@ -1,6 +1,6 @@
#include <memory>
#include "CryptoHelper.h"
#ifdef __unix__
#ifndef _MSC_VER
#include"linux/CryptoHelperLinux.h"
#else
#include"win/CryptoHelperWindows.h"
@@ -10,7 +10,7 @@
namespace license {
unique_ptr<CryptoHelper> CryptoHelper::getInstance() {
#ifdef __unix__
#ifndef _MSC_VER
    unique_ptr<CryptoHelper> ptr((CryptoHelper*) new CryptoHelperLinux());
#else
    unique_ptr<CryptoHelper> ptr((CryptoHelper*) new CryptoHelperWindows());
src/tools/bootstrap/CMakeLists.txt
@@ -13,12 +13,21 @@
)
# add the command to generate the source code
if(MINGW)
add_custom_command (
  OUTPUT "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h"
  COMMAND ./bootstrap.exe "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h"
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  DEPENDS bootstrap)
else(MINGW)
add_custom_command (
  OUTPUT "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h"
  COMMAND bootstrap "${CMAKE_BINARY_DIR}/private-key.h" "${CMAKE_BINARY_DIR}/public-key.h"
  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  DEPENDS bootstrap
)
  DEPENDS bootstrap)
endif(MINGW)
add_custom_target(private_key DEPENDS "${CMAKE_BINARY_DIR}/private-key.h")
add_custom_target(public_key DEPENDS "${CMAKE_BINARY_DIR}/public-key.h")