Fix cross-compilation and MSVC build with OpenSSL

When building for multiple platforms I encountered several issues.
Fist of all MSVC (Windows) build with TLS support through OpenSSL
requires additional library "crypt32".
Secondly, detection of pthread library failed when a cross-compiler
was used (target platform is not identical to source/build platform).
The "FIND_PACKAGE(Threads)" works fine but "FIND_LIBRARY(...)"
either fails or finds pthread library for the wrong platform.
It seems to methat presence of "CMAKE_THREAD_LIBS_INIT" which
is set by the "FIND_PACKAGE(Threads)" test is a sufficiently
reliable to use it to set "VMIME_HAVE_PTHREAD" but I must admit
that this is not really my cup of coffee :-)
This commit is contained in:
Jan Osusky 2017-11-03 19:35:47 +01:00
parent eb5d9db693
commit 23bfd43a16

View File

@ -678,6 +678,10 @@ IF(VMIME_HAVE_TLS_SUPPORT)
)
ENDIF()
IF(WIN32)
SET(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} crypt32.lib")
ENDIF()
SET(VMIME_PKGCONFIG_REQUIRES "${VMIME_PKGCONFIG_REQUIRES} openssl")
SET(VMIME_TLS_SUPPORT_LIB_IS_GNUTLS "OFF")
@ -958,9 +962,9 @@ IF(VMIME_BUILD_SHARED_LIBRARY)
)
ENDIF()
FIND_LIBRARY(PTHREAD_LIB pthread)
#FIND_LIBRARY(PTHREAD_LIB pthread)
IF(PTHREAD_LIB)
IF(CMAKE_THREAD_LIBS_INIT)
SET(VMIME_HAVE_PTHREAD 1)
IF(VMIME_BUILD_SHARED_LIBRARY)
@ -1007,6 +1011,9 @@ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
#SET(CMAKE_EXE_LINKER_FLAGS "-s")
ELSE()
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /EHsc")
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)