+#***************************************************************************
+# _ _ ____ _
+# Project ___| | | | _ \| |
+# / __| | | | |_) | |
+# | (__| |_| | _ <| |___
+# \___|\___/|_| \_\_____|
+#
+# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://curl.haxx.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+###########################################################################
# cURL/libcurl CMake script
# by Tetetest and Sukender (Benoit Neil)
project( CURL C )
+message(WARNING "the curl cmake build system is poorly maintained. Be aware")
file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)"
include_directories(${PROJECT_BINARY_DIR}/include/curl)
include_directories( ${CURL_SOURCE_DIR}/include )
-if(WIN32)
- set(NATIVE_WINDOWS ON)
-endif()
-
option(BUILD_CURL_EXE "Set to ON to build cURL executable." ON)
option(BUILD_CURL_TESTS "Set to ON to build cURL tests." ON)
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
option(CURL_DISABLE_LDAPS "to disable LDAPS" OFF)
mark_as_advanced(CURL_DISABLE_LDAPS)
-if(WIN32)
- set(CURL_DEFAULT_DISABLE_LDAP OFF)
- # some windows compilers do not have wldap32
- if( NOT HAVE_WLDAP32)
- set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
- message(STATUS "wldap32 not found CURL_DISABLE_LDAP set ON")
- option(CURL_LDAP_WIN "Use Windows LDAP implementation" OFF)
- else()
- option(CURL_LDAP_WIN "Use Windows LDAP implementation" ON)
- endif()
- mark_as_advanced(CURL_LDAP_WIN)
-endif()
if(HTTP_ONLY)
set(CURL_DISABLE_FTP ON)
set(CURL_DISABLE_LDAP ON)
+ set(CURL_DISABLE_LDAPS ON)
set(CURL_DISABLE_TELNET ON)
set(CURL_DISABLE_DICT ON)
set(CURL_DISABLE_FILE ON)
option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF)
mark_as_advanced(ENABLE_IPV6)
-if(WIN32)
- list_spaces_append_once(CMAKE_C_STANDARD_LIBRARIES wsock32.lib ws2_32.lib) # bufferoverflowu.lib
- if(CURL_DISABLE_LDAP)
- # Remove wldap32.lib from space-separated list
- string(REPLACE " " ";" _LIST ${CMAKE_C_STANDARD_LIBRARIES})
- list(REMOVE_ITEM _LIST "wldap32.lib")
- to_list_spaces(_LIST CMAKE_C_STANDARD_LIBRARIES)
- else()
- # Append wldap32.lib
- list_spaces_append_once(CMAKE_C_STANDARD_LIBRARIES wldap32.lib)
- endif()
- set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}" CACHE STRING "" FORCE)
-endif()
-
# We need ansi c-flags, especially on HP
set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
endif(WIN32)
# This macro checks if the symbol exists in the library and if it
-# does, it appends library to the list.
+# does, it prepends library to the list.
macro(CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE)
- check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} ""
+ check_library_exists("${LIBRARY};${CURL_LIBS}" ${SYMBOL} "${CMAKE_LIBRARY_PATH}"
${VARIABLE})
if(${VARIABLE})
- set(CURL_LIBS ${CURL_LIBS} ${LIBRARY})
+ set(CURL_LIBS ${LIBRARY} ${CURL_LIBS})
endif(${VARIABLE})
endmacro(CHECK_LIBRARY_EXISTS_CONCAT)
check_library_exists_concat("winmm" getch HAVE_LIBWINMM)
check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32)
+if(WIN32)
+ set(CURL_DEFAULT_DISABLE_LDAP OFF)
+ # some windows compilers do not have wldap32
+ if(NOT HAVE_WLDAP32)
+ set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
+ message(STATUS "wldap32 not found CURL_DISABLE_LDAP set ON")
+ option(CURL_LDAP_WIN "Use Windows LDAP implementation" OFF)
+ else()
+ option(CURL_LDAP_WIN "Use Windows LDAP implementation" ON)
+ endif()
+ mark_as_advanced(CURL_LDAP_WIN)
+endif()
+
+
# IF(NOT CURL_SPECIAL_LIBZ)
# CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ)
# ENDIF(NOT CURL_SPECIAL_LIBZ)
-option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON)
-mark_as_advanced(CMAKE_USE_OPENSSL)
-if(CMAKE_USE_OPENSSL)
- if(WIN32)
- find_package(OpenSSL)
- if(OPENSSL_FOUND)
- set(USE_SSLEAY TRUE)
- set(USE_OPENSSL TRUE)
- list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES} )
- else()
- set(CMAKE_USE_OPENSSL FALSE)
- message(STATUS "OpenSSL NOT Found, disabling CMAKE_USE_OPENSSL")
- endif()
- else(WIN32)
- check_library_exists_concat("crypto" CRYPTO_lock HAVE_LIBCRYPTO)
- check_library_exists_concat("ssl" SSL_connect HAVE_LIBSSL)
- endif(WIN32)
-endif(CMAKE_USE_OPENSSL)
-
# Check for idn
check_library_exists_concat("idn" idna_to_ascii_lz HAVE_LIBIDN)
set(HAVE_ZLIB_H ON)
set(HAVE_ZLIB ON)
set(HAVE_LIBZ ON)
+ list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
endif()
endif()
+option(CMAKE_USE_OPENSSL "Use OpenSSL code. Experimental" ON)
+mark_as_advanced(CMAKE_USE_OPENSSL)
+if(CMAKE_USE_OPENSSL)
+
+ set(USE_SSLEAY OFF)
+ set(USE_OPENSSL OFF)
+ set(HAVE_LIBCRYPTO OFF)
+ set(HAVE_LIBSSL OFF)
+
+ find_package(OpenSSL)
+ if(OPENSSL_FOUND)
+ list(APPEND CURL_LIBS ${OPENSSL_LIBRARIES})
+ list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
+ set(USE_SSLEAY ON)
+ set(USE_OPENSSL ON)
+ set(HAVE_LIBCRYPTO ON)
+ set(HAVE_LIBSSL ON)
+ endif(OPENSSL_FOUND)
+endif(CMAKE_USE_OPENSSL)
+
# If we have features.h, then do the _BSD_SOURCE magic
check_include_file("features.h" HAVE_FEATURES_H)
check_include_file_concat("netdb.h" HAVE_NETDB_H)
check_include_file_concat("netinet/in.h" HAVE_NETINET_IN_H)
check_include_file_concat("netinet/tcp.h" HAVE_NETINET_TCP_H)
-check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
-check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
-check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H)
-check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H)
-check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H)
-check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
-check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
-check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H)
+if(CMAKE_USE_OPENSSL AND OPENSSL_FOUND)
+ check_include_file_concat("openssl/crypto.h" HAVE_OPENSSL_CRYPTO_H)
+ check_include_file_concat("openssl/engine.h" HAVE_OPENSSL_ENGINE_H)
+ check_include_file_concat("openssl/err.h" HAVE_OPENSSL_ERR_H)
+ check_include_file_concat("openssl/pem.h" HAVE_OPENSSL_PEM_H)
+ check_include_file_concat("openssl/pkcs12.h" HAVE_OPENSSL_PKCS12_H)
+ check_include_file_concat("openssl/rsa.h" HAVE_OPENSSL_RSA_H)
+ check_include_file_concat("openssl/ssl.h" HAVE_OPENSSL_SSL_H)
+ check_include_file_concat("openssl/x509.h" HAVE_OPENSSL_X509_H)
+ check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H)
+endif(CMAKE_USE_OPENSSL AND OPENSSL_FOUND)
check_include_file_concat("pem.h" HAVE_PEM_H)
check_include_file_concat("poll.h" HAVE_POLL_H)
check_include_file_concat("pwd.h" HAVE_PWD_H)
check_include_file_concat("sys/utsname.h" HAVE_SYS_UTSNAME_H)
check_include_file_concat("idna.h" HAVE_IDNA_H)
-if(CMAKE_USE_OPENSSL)
- check_include_file_concat("openssl/rand.h" HAVE_OPENSSL_RAND_H)
-endif(CMAKE_USE_OPENSSL)
-
-if(NOT HAVE_LDAP_H)
+if(NOT HAVE_LDAP_H)
message(STATUS "LDAP_H not found CURL_DISABLE_LDAP set ON")
set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE)
endif()
+# No ldap, no ldaps.
+if(CURL_DISABLE_LDAP)
+ if(NOT CURL_DISABLE_LDAPS)
+ message(STATUS "LDAP needs to be enabled to support LDAPS")
+ set(CURL_DISABLE_LDAPS ON CACHE BOOL "" FORCE)
+ endif()
+endif()
check_type_size(size_t SIZEOF_SIZE_T)
check_type_size(ssize_t SIZEOF_SSIZE_T)
set(CURL_FORMAT_CURL_OFF_TU "lu")
set(CURL_FORMAT_OFF_T "%ld")
set(CURL_SUFFIX_CURL_OFF_T L)
- set(CURL_SUFFIX_CURL_OFF_TU LU)
+ set(CURL_SUFFIX_CURL_OFF_TU UL)
endif(SIZEOF_LONG EQUAL 8)
if(SIZEOF_LONG_LONG EQUAL 8)
set(CURL_FORMAT_CURL_OFF_TU "llu")
set(CURL_FORMAT_OFF_T "%lld")
set(CURL_SUFFIX_CURL_OFF_T LL)
- set(CURL_SUFFIX_CURL_OFF_TU LLU)
+ set(CURL_SUFFIX_CURL_OFF_TU ULL)
endif(SIZEOF_LONG_LONG EQUAL 8)
if(NOT CURL_TYPEOF_CURL_OFF_T)
check_type_size("socklen_t" CURL_SIZEOF_CURL_SOCKLEN_T)
set(CMAKE_EXTRA_INCLUDE_FILES)
if(NOT HAVE_CURL_SIZEOF_CURL_SOCKLEN_T)
- message(FATAL_ERROR
+ message(FATAL_ERROR
"Check for sizeof socklen_t failed, see CMakeFiles/CMakerror.log")
endif()
else()
set(CURL_SIZEOF_CURL_SOCKLEN_T ${SIZEOF_INT})
endif()
+# TODO test which of these headers are required for the typedefs used in curlbuild.h
+if(WIN32)
+ set(CURL_PULL_WS2TCPIP_H ${HAVE_WS2TCPIP_H})
+else()
+ set(CURL_PULL_SYS_TYPES_H ${HAVE_SYS_TYPES_H})
+ set(CURL_PULL_SYS_SOCKET_H ${HAVE_SYS_SOCKET_H})
+ set(CURL_PULL_SYS_POLL_H ${HAVE_SYS_POLL_H})
+endif()
+set(CURL_PULL_STDINT_H ${HAVE_STDINT_H})
+set(CURL_PULL_INTTYPES_H ${HAVE_INTTYPES_H})
+
include(CMake/OtherTests.cmake)
add_definitions(-DHAVE_CONFIG_H)
function(SETUP_CURL_DEPENDENCIES TARGET_NAME)
if(CURL_ZLIB AND ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIR})
- endif()
- if(CURL_ZLIB AND ZLIB_FOUND)
- target_link_libraries(${TARGET_NAME} ${ZLIB_LIBRARIES})
#ADD_DEFINITIONS( -DHAVE_ZLIB_H -DHAVE_ZLIB -DHAVE_LIBZ )
endif()
include_directories(${OPENSSL_INCLUDE_DIR})
endif()
if(CMAKE_USE_OPENSSL AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
- target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES})
#ADD_DEFINITIONS( -DUSE_SSLEAY )
endif()
+
+ target_link_libraries(${TARGET_NAME} ${CURL_LIBS})
endfunction()
# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
if(NOT CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
set(CURL_CONFIG_HAS_BEEN_RUN_BEFORE 1 CACHE INTERNAL "Flag to track whether this is the first time running CMake or if CMake has been configured before")
endif()
+
+# Installation.
+# First, install generated curlbuild.h
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/curl/curlbuild.h"
+ DESTINATION include/curl )
+# Next, install other headers excluding curlbuild.h
+install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl"
+ DESTINATION include
+ FILES_MATCHING PATTERN "*.h"
+ PATTERN "curlbuild.h" EXCLUDE)
+
+
+# Workaround for MSVS10 to avoid the Dialog Hell
+# FIXME: This could be removed with future version of CMake.
+if(MSVC_VERSION EQUAL 1600)
+ set(CURL_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/CURL.sln")
+ if(EXISTS "${CURL_SLN_FILENAME}")
+ file(APPEND "${CURL_SLN_FILENAME}" "\n# This should be regenerated!\n")
+ endif()
+endif()