ENH: allow for shared build of libcurl and fix build with openssl option (ssl tested on linux and windows

This commit is contained in:
Bill Hoffman 2009-04-10 11:59:31 -04:00
parent 3c0e239346
commit 5783d5aab1
2 changed files with 39 additions and 7 deletions

View File

@ -266,7 +266,10 @@ MACRO (CMAKE_BUILD_UTILITIES)
SET(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) SET(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
SET(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) SET(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
SET(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) SET(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" FALSE)
IF(NOT CMAKE_BUILD_CURL_SHARED)
ADD_DEFINITIONS(-DCURL_STATICLIB) ADD_DEFINITIONS(-DCURL_STATICLIB)
ENDIF(NOT CMAKE_BUILD_CURL_SHARED)
SET(CMAKE_CURL_INCLUDES) SET(CMAKE_CURL_INCLUDES)
SET(CMAKE_CURL_LIBRARIES cmcurl) SET(CMAKE_CURL_LIBRARIES cmcurl)
IF(CMAKE_USE_NEW_CURL) IF(CMAKE_USE_NEW_CURL)

View File

@ -180,11 +180,22 @@ IF(NOT CURL_SPECIAL_LIBZ)
CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ) CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ)
ENDIF(NOT CURL_SPECIAL_LIBZ) ENDIF(NOT CURL_SPECIAL_LIBZ)
OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON) OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code." OFF)
MARK_AS_ADVANCED(CMAKE_USE_OPENSSL) MARK_AS_ADVANCED(CMAKE_USE_OPENSSL)
IF(CMAKE_USE_OPENSSL) IF(CMAKE_USE_OPENSSL)
SET(USE_SSLEAY TRUE)
SET(USE_OPENSSL TRUE)
IF(WIN32)
FIND_PATH(SSLINCLUDE openssl/crypto.h
PATHS c:/hoffman/Tools/openssl_w32vc6-0.9.8g/inc32)
INCLUDE_DIRECTORIES(${SSLINCLUDE})
FIND_LIBRARY(LIBEAY NAMES libeay32)
FIND_LIBRARY(SSLEAY NAMES ssleay32)
SET(CURL_LIBS ${CURL_LIBS} ${LIBEAY} ${SSLEAY} )
ELSE(WIN32)
CHECK_LIBRARY_EXISTS_CONCAT("crypto" CRYPTO_lock HAVE_LIBCRYPTO) CHECK_LIBRARY_EXISTS_CONCAT("crypto" CRYPTO_lock HAVE_LIBCRYPTO)
CHECK_LIBRARY_EXISTS_CONCAT("ssl" SSL_connect HAVE_LIBSSL) CHECK_LIBRARY_EXISTS_CONCAT("ssl" SSL_connect HAVE_LIBSSL)
ENDIF(WIN32)
ENDIF(CMAKE_USE_OPENSSL) ENDIF(CMAKE_USE_OPENSSL)
# Check for idn # Check for idn
@ -396,6 +407,11 @@ ENDIF(NOT HAVE_STRNCMPI)
CHECK_SYMBOL_EXISTS(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR) CHECK_SYMBOL_EXISTS(gethostbyaddr "${CURL_INCLUDES}" HAVE_GETHOSTBYADDR)
CHECK_SYMBOL_EXISTS(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY) CHECK_SYMBOL_EXISTS(gettimeofday "${CURL_INCLUDES}" HAVE_GETTIMEOFDAY)
CHECK_SYMBOL_EXISTS(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR) CHECK_SYMBOL_EXISTS(inet_addr "${CURL_INCLUDES}" HAVE_INET_ADDR)
# windows only has this for vista, but will link with it and say
# that it has it at link time! So, force it off
IF(WIN32)
SET(HAVE_INET_PTON 0 CACHE "" INTERNAL )
ENDIF(WIN32)
CHECK_SYMBOL_EXISTS(inet_pton "${CURL_INCLUDES}" HAVE_INET_PTON) CHECK_SYMBOL_EXISTS(inet_pton "${CURL_INCLUDES}" HAVE_INET_PTON)
CHECK_SYMBOL_EXISTS(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA) CHECK_SYMBOL_EXISTS(inet_ntoa "${CURL_INCLUDES}" HAVE_INET_NTOA)
CHECK_SYMBOL_EXISTS(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R) CHECK_SYMBOL_EXISTS(inet_ntoa_r "${CURL_INCLUDES}" HAVE_INET_NTOA_R)
@ -701,13 +717,26 @@ INCLUDE(CMake/OtherTests.cmake)
INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR}) INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR})
INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR}) INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR})
OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" TRUE)
IF(CMAKE_BUILD_CURL_SHARED)
SET(LIBRARY_TYPE SHARED)
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
ELSE(CMAKE_BUILD_CURL_SHARED)
ADD_DEFINITIONS(-DHAVE_CONFIG_H ADD_DEFINITIONS(-DHAVE_CONFIG_H
-DCURL_STATICLIB) -DCURL_STATICLIB)
ENDIF(CMAKE_BUILD_CURL_SHARED)
SET(CURL_STATICLIB)
CONFIGURE_FILE(${LIBCURL_SOURCE_DIR}/config.h.in CONFIGURE_FILE(${LIBCURL_SOURCE_DIR}/config.h.in
${LIBCURL_BINARY_DIR}/config.h) ${LIBCURL_BINARY_DIR}/config.h)
ADD_LIBRARY(cmcurl ${libCurl_SRCS})
ADD_LIBRARY(cmcurl ${LIBRARY_TYPE} ${libCurl_SRCS})
TARGET_LINK_LIBRARIES(cmcurl ${CURL_LIBS}) TARGET_LINK_LIBRARIES(cmcurl ${CURL_LIBS})
IF(CMAKE_BUILD_CURL_SHARED)
SET_TARGET_PROPERTIES(cmcurl PROPERTIES DEFINE_SYMBOL BUILDING_LIBCURL
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
INSTALL_TARGETS(/bin cmcurl)
ENDIF(CMAKE_BUILD_CURL_SHARED)
OPTION(CURL_TESTING "Do libCurl testing" OFF) OPTION(CURL_TESTING "Do libCurl testing" OFF)
IF(CURL_TESTING) IF(CURL_TESTING)