fix complation with mingw and openssl
This commit is contained in:
parent
d8e683f17e
commit
63c62561d8
9 changed files with 31 additions and 30 deletions
|
@ -6,7 +6,7 @@ set(CMAKE_MODULE_PATH "cmake_modules")
|
|||
set(cppunit_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(cppunit)
|
||||
|
||||
if (WIN32)
|
||||
if (NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||
ADD_SUBDIRECTORY(msvc-deps)
|
||||
else()
|
||||
set(sqlite3_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
|
@ -22,6 +22,10 @@ find_package(purple)
|
|||
set(glib_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(glib)
|
||||
|
||||
set(libxml2_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(libxml2)
|
||||
|
||||
|
||||
if (NOT WIN32)
|
||||
set(popt_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(popt)
|
||||
|
@ -47,7 +51,7 @@ endif()
|
|||
find_package(Boost COMPONENTS program_options date_time system filesystem regex signals REQUIRED)
|
||||
message( STATUS "Found Boost: ${Boost_LIBRARIES}, ${Boost_INCLUDE_DIR}")
|
||||
|
||||
if (NOT WIN32)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(Protobuf_DIR "${CMAKE_SOURCE_DIR}/cmake_modules")
|
||||
find_package(Protobuf REQUIRED)
|
||||
else()
|
||||
|
@ -205,23 +209,14 @@ if (WIN32)
|
|||
ADD_DEFINITIONS(-DLOG4CXX_STATIC)
|
||||
ADD_DEFINITIONS(-D_WIN32_WINNT=0x501)
|
||||
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
|
||||
ADD_DEFINITIONS(-DBOOST_USE_WINDOWS_H)
|
||||
ADD_DEFINITIONS(-DBOOST_THREAD_USE_LIB)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
ADD_DEFINITIONS(-O3)
|
||||
ADD_DEFINITIONS(-ggdb)
|
||||
ADD_DEFINITIONS(-Wall)
|
||||
ADD_DEFINITIONS(-W)
|
||||
ADD_DEFINITIONS(-Wcast-align)
|
||||
ADD_DEFINITIONS(-Wextra -Wno-sign-compare -Wno-unused-parameter)
|
||||
ADD_DEFINITIONS(-Winit-self)
|
||||
ADD_DEFINITIONS(-Wmissing-declarations)
|
||||
ADD_DEFINITIONS(-Wpointer-arith)
|
||||
ADD_DEFINITIONS(-Wreorder)
|
||||
ADD_DEFINITIONS(-Woverloaded-virtual)
|
||||
ADD_DEFINITIONS(-Wsign-promo)
|
||||
ADD_DEFINITIONS(-Wundef -Wunused)
|
||||
endif()
|
||||
ADD_DEFINITIONS(-DDEBUG)
|
||||
message("Debug : yes")
|
||||
|
|
|
@ -3,11 +3,11 @@ FILE(GLOB SRC *.cpp)
|
|||
|
||||
ADD_EXECUTABLE(spectrum2_libpurple_backend ${SRC})
|
||||
|
||||
if(NOT WIN32)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
target_link_libraries(spectrum2_libpurple_backend ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin pthread)
|
||||
else()
|
||||
include_directories("${CMAKE_SOURCE_DIR}/msvc-deps/protobuf/libprotobuf")
|
||||
target_link_libraries(spectrum2_libpurple_backend ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin libprotobuf)
|
||||
target_link_libraries(spectrum2_libpurple_backend ${PURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${LIBXML2_LIBRARIES} ${EVENT_LIBRARIES} transport-plugin libprotobuf)
|
||||
endif()
|
||||
|
||||
INSTALL(TARGETS spectrum2_libpurple_backend RUNTIME DESTINATION bin)
|
||||
|
|
|
@ -4,7 +4,7 @@ FILE(GLOB SRC *.c *.cpp)
|
|||
|
||||
ADD_EXECUTABLE(spectrum2_template_backend ${SRC})
|
||||
|
||||
if (NOT WIN32)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
target_link_libraries(spectrum2_template_backend transport pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES})
|
||||
else()
|
||||
include_directories("${CMAKE_SOURCE_DIR}/msvc-deps/protobuf/libprotobuf")
|
||||
|
|
|
@ -180,15 +180,16 @@ void OpenSSLServerContext::sendPendingDataToApplication() {
|
|||
}
|
||||
}
|
||||
|
||||
bool OpenSSLServerContext::setServerCertificate(const PKCS12Certificate& certificate) {
|
||||
if (certificate.isNull()) {
|
||||
bool OpenSSLServerContext::setServerCertificate(CertificateWithKey::ref certref) {
|
||||
boost::shared_ptr<PKCS12Certificate> certificate = boost::dynamic_pointer_cast<PKCS12Certificate>(certref);
|
||||
if (certificate->isNull()) {
|
||||
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate can't be loaded.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a PKCS12 structure
|
||||
BIO* bio = BIO_new(BIO_s_mem());
|
||||
BIO_write(bio, vecptr(certificate.getData()), certificate.getData().size());
|
||||
BIO_write(bio, vecptr(certificate->getData()), certificate->getData().size());
|
||||
boost::shared_ptr<PKCS12> pkcs12(d2i_PKCS12_bio(bio, NULL), PKCS12_free);
|
||||
BIO_free(bio);
|
||||
if (!pkcs12) {
|
||||
|
@ -200,7 +201,7 @@ bool OpenSSLServerContext::setServerCertificate(const PKCS12Certificate& certifi
|
|||
X509 *certPtr = 0;
|
||||
EVP_PKEY* privateKeyPtr = 0;
|
||||
STACK_OF(X509)* caCertsPtr = 0;
|
||||
int result = PKCS12_parse(pkcs12.get(), reinterpret_cast<const char*>(vecptr(certificate.getPassword())), &privateKeyPtr, &certPtr, &caCertsPtr);
|
||||
int result = PKCS12_parse(pkcs12.get(), reinterpret_cast<const char*>(vecptr(certificate->getPassword())), &privateKeyPtr, &certPtr, &caCertsPtr);
|
||||
if (result != 1) {
|
||||
LOG4CXX_ERROR(logger, "TLS WILL NOT WORK: Certificate is not in PKCS#12 format.");
|
||||
return false;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "Swiften/TLS/TLSServerContext.h"
|
||||
#include "Swiften/Base/ByteArray.h"
|
||||
#include <Swiften/TLS/CertificateWithKey.h>
|
||||
|
||||
namespace Swift {
|
||||
class PKCS12Certificate;
|
||||
|
@ -22,7 +23,7 @@ namespace Swift {
|
|||
~OpenSSLServerContext();
|
||||
|
||||
void connect();
|
||||
bool setServerCertificate(const PKCS12Certificate& cert);
|
||||
bool setServerCertificate(CertificateWithKey::ref cert);
|
||||
|
||||
void handleDataFromNetwork(const SafeByteArray&);
|
||||
void handleDataFromApplication(const SafeByteArray&);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
if (PROTOBUF_FOUND)
|
||||
if (WIN32)
|
||||
if (NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (PROTOBUF_PROTOC_EXECUTABLE protoc)
|
||||
endif()
|
||||
ADD_CUSTOM_COMMAND(
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
|
||||
// TODO(kenton): Use unordered_map instead, which is available in MSVC 2010.
|
||||
#if _MSC_VER < 1310 || _MSC_VER >= 1600
|
||||
#define HASH_NAMESPACE std
|
||||
#define HASH_NAMESPACE ext
|
||||
#else
|
||||
#define HASH_NAMESPACE stdext
|
||||
#endif
|
||||
|
|
|
@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 2.6)
|
|||
FILE(GLOB SRC *.cpp *.h)
|
||||
FILE(GLOB_RECURSE SWIFTEN_SRC ../include/Swiften/*.cpp)
|
||||
|
||||
# Build without openssl on windows
|
||||
if (WIN32)
|
||||
# Build without openssl on msvc
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
string(REGEX REPLACE "[^;]+;?/Schannel/[^;]+;?" "" SWIFTEN_SRC "${SWIFTEN_SRC}")
|
||||
else()
|
||||
string(REGEX REPLACE "[^;]+;?/OpenSSL/[^;]+;?" "" SWIFTEN_SRC "${SWIFTEN_SRC}")
|
||||
endif()
|
||||
|
||||
|
@ -37,15 +39,17 @@ else(PROTOBUF_FOUND)
|
|||
endif(PROTOBUF_FOUND)
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
if (NOT WIN32)
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||
include_directories("${CMAKE_SOURCE_DIR}/msvc-deps/protobuf/libprotobuf")
|
||||
TARGET_LINK_LIBRARIES(transport transport-plugin ${PQXX_LIBRARY} ${PQ_LIBRARY} ${SQLITE3_LIBRARIES} ${MYSQL_LIBRARIES} ${SWIFTEN_LIBRARY} ${PROTOBUF_LIBRARIES} ${LOG4CXX_LIBRARIES})
|
||||
else (WIN32)
|
||||
else ()
|
||||
TARGET_LINK_LIBRARIES(transport transport-plugin ${PQXX_LIBRARY} ${PQ_LIBRARY} ${SQLITE3_LIBRARIES} ${MYSQL_LIBRARIES} ${SWIFTEN_LIBRARY} ${PROTOBUF_LIBRARIES} ${LOG4CXX_LIBRARIES} ${POPT_LIBRARY})
|
||||
endif(WIN32)
|
||||
endif()
|
||||
|
||||
SET_TARGET_PROPERTIES(transport PROPERTIES
|
||||
VERSION ${TRANSPORT_VERSION} SOVERSION ${TRANSPORT_VERSION}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "transport/config.h"
|
||||
#include <fstream>
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#define getcwd _getcwd
|
||||
#include <windows.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue