win32 compile

- update openssl to search for libeay too
- saslservtests needs wsock32
- export CertificateInfoPair to fix qca-openssl linking
- add setenv() to pgpunittest.cpp for win32 - maybe add a check for setenv()

svn path=/trunk/kdesupport/qca/; revision=633918
This commit is contained in:
Christian Ehrlicher 2007-02-15 19:17:56 +00:00
parent 8b495aaf32
commit 78406a6651
6 changed files with 136 additions and 74 deletions

View File

@ -1,70 +1,104 @@
# - Try to find the OpenSSL encryption library
# Once done this will define
#
# OPENSSL_FOUND - system has the OpenSSL library
# OPENSSL_INCLUDE_DIR - the OpenSSL include directory
# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF(OPENSSL_LIBRARIES)
SET(OpenSSL_FIND_QUIETLY TRUE)
ENDIF(OPENSSL_LIBRARIES)
IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
SET(LIB_FOUND 1)
ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h )
IF(WIN32 AND MSVC)
# /MD and /MDd are the standard values - if somone wants to use
# others, the libnames have to change here too
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32)
FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32)
IF(MSVC_IDE)
IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG})
ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
MESSAGE(FATAL_ERROR "Could not find the debug and release version of openssl")
ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
ELSE(MSVC_IDE)
STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG})
ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE})
ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
ENDIF(MSVC_IDE)
MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
ELSE(WIN32 AND MSVC)
FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD )
ENDIF(WIN32 AND MSVC)
IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
SET(OPENSSL_FOUND TRUE)
ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
SET(OPENSSL_FOUND FALSE)
ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
IF (OPENSSL_FOUND)
IF (NOT OpenSSL_FIND_QUIETLY)
MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
ENDIF (NOT OpenSSL_FIND_QUIETLY)
ELSE (OPENSSL_FOUND)
IF (OpenSSL_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
ENDIF (OpenSSL_FIND_REQUIRED)
ENDIF (OPENSSL_FOUND)
MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
# - Try to find the OpenSSL encryption library
# Once done this will define
#
# OPENSSL_FOUND - system has the OpenSSL library
# OPENSSL_INCLUDE_DIR - the OpenSSL include directory
# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
# OPENSSL_EAY_LIBRARIES - The additional libraries needed to use OpenSSL on windows
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# on win32 we additional need to link to libeay32.lib
MACRO(OPENSSL_ADD_LIB_EAY_LIBS)
# /MD and /MDd are the standard values - if somone wants to use
# others, the libnames have to change here too
# use also eay and libeay32 in debug as fallback for openssl < 0.9.8b
FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd eay libeay libeay32)
FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD eay libeay libeay32)
IF(MSVC_IDE)
IF(LIB_EAY_DEBUG AND LIB_EAY_RELEASE)
SET(OPENSSL_EAY_LIBRARIES optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG})
ELSE(LIB_EAY_DEBUG AND LIB_EAY_RELEASE)
MESSAGE(FATAL_ERROR "Could not find the debug and release version of openssl (libeay)")
ENDIF(LIB_EAY_DEBUG AND LIB_EAY_RELEASE)
ELSE(MSVC_IDE)
STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_EAY_LIBRARIES ${LIB_EAY_DEBUG})
ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_EAY_LIBRARIES ${LIB_EAY_RELEASE})
ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
ENDIF(MSVC_IDE)
MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE)
ENDMACRO(OPENSSL_ADD_LIB_EAY_LIBS)
IF(OPENSSL_LIBRARIES)
SET(OpenSSL_FIND_QUIETLY TRUE)
ENDIF(OPENSSL_LIBRARIES)
IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
SET(LIB_FOUND 1)
ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h )
IF(WIN32 AND MSVC)
# /MD and /MDd are the standard values - if somone wants to use
# others, the libnames have to change here too
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32)
FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32)
IF(MSVC_IDE)
IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG})
ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
MESSAGE(FATAL_ERROR "Could not find the debug and release version of openssl")
ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE)
ELSE(MSVC_IDE)
STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG})
ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE})
ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
ENDIF(MSVC_IDE)
MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE)
ELSE(WIN32 AND MSVC)
FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD )
ENDIF(WIN32 AND MSVC)
IF(WIN32)
OPENSSL_ADD_LIB_EAY_LIBS()
IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
SET(OPENSSL_FOUND TRUE)
ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
SET(OPENSSL_FOUND FALSE)
ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND OPENSSL_EAY_LIBRARIES)
ELSE(WIN32)
IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
SET(OPENSSL_FOUND TRUE)
ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
SET(OPENSSL_FOUND FALSE)
ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES)
ENDIF(WIN32)
IF (OPENSSL_FOUND)
IF (NOT OpenSSL_FIND_QUIETLY)
MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}")
ENDIF (NOT OpenSSL_FIND_QUIETLY)
ELSE (OPENSSL_FOUND)
IF (OpenSSL_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could NOT find OpenSSL")
ENDIF (OpenSSL_FIND_REQUIRED)
ENDIF (OPENSSL_FOUND)
MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)

View File

@ -5,3 +5,7 @@ MY_AUTOMOC( saslservtest_bin_SRCS)
add_executable(saslservtest ${saslservtest_bin_SRCS})
target_link_libraries( saslservtest qca ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY})
if (WIN32)
target_link_libraries(saslservtest wsock32)
endif (WIN32)

View File

@ -94,7 +94,7 @@ namespace QCA
/**
One entry in a certificate information list
*/
class CertificateInfoPair
class QCA_EXPORT CertificateInfoPair
{
public:
/**

View File

@ -38,9 +38,9 @@
#ifdef Q_OS_WIN32
# ifndef QCA_STATIC
# ifdef QCA_MAKEDLL
# define QCA_EXPORT __declspec(dllexport)
# define QCA_EXPORT Q_DECL_EXPORT
# else
# define QCA_EXPORT __declspec(dllimport)
# define QCA_EXPORT Q_DECL_IMPORT
# endif
# endif
#endif

View File

@ -16,7 +16,7 @@ IF (WIN32)
ADD_DEFINITIONS(-DOSSL_097)
TARGET_LINK_LIBRARIES(qca-openssl gdi32)
TARGET_LINK_LIBRARIES(qca-openssl wsock32)
TARGET_LINK_LIBRARIES(qca-openssl eay32)
TARGET_LINK_LIBRARIES(qca-openssl ${OPENSSL_EAY_LIBRARIES})
ENDIF (WIN32)
INSTALL(TARGETS qca-openssl LIBRARY DESTINATION ${qca_PLUGINSDIR})

View File

@ -28,6 +28,28 @@
#include <stdlib.h>
#ifdef Q_OS_WIN
static int setenv(const char *name, const char *value, int overwrite)
{
int i, iRet;
char * a;
if (!overwrite && getenv(name)) return 0;
i = strlen(name) + strlen(value) + 2;
a = (char*)malloc(i);
if (!a) return 1;
strcpy(a, name);
strcat(a, "=");
strcat(a, value);
iRet = putenv(a);
free(a);
return iRet;
}
#endif
class PgpUnitTest : public QObject
{
Q_OBJECT
@ -76,7 +98,9 @@ void PgpUnitTest::testKeyRing()
QCOMPARE( pgpStore.holdsPGPPublicKeys(), true );
#ifdef __GNUC__
#warning using setenv is dubious in terms of portability
#endif
QByteArray oldGNUPGHOME = qgetenv( "GNUPGHOME" );
// We test a small keyring - I downloaded a publically available one from
// the Amsterdam Internet Exchange.