mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
CMake: improve library search, implement install.
Improved library search by check_function_exists_concat() macro: it does not revert the list of libraries any more. Improved OpenSSL library search: first find zlib, then search for openssl libraries that may depend on zlib. For Unix: openssl libraries can now be detected in nonstandard locations. Supply CMAKE_LIBRARY_PATH to CMake on command line. Added installation capability (very basic one yet).
This commit is contained in:
parent
4a42e5cdaa
commit
2cbe885c1a
@ -23,7 +23,6 @@ include(Utilities)
|
||||
|
||||
project( CURL C )
|
||||
|
||||
|
||||
file (READ ${CURL_SOURCE_DIR}/include/curl/curlver.h CURL_VERSION_H_CONTENTS)
|
||||
string (REGEX MATCH "LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)"
|
||||
LIBCURL_VERSION_MJ ${CURL_VERSION_H_CONTENTS})
|
||||
@ -191,12 +190,12 @@ if(WIN32)
|
||||
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)
|
||||
|
||||
@ -224,25 +223,6 @@ check_library_exists("wldap32" cldap_open "" HAVE_WLDAP32)
|
||||
# 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)
|
||||
|
||||
@ -271,6 +251,25 @@ if(CURL_ZLIB) # AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE
|
||||
endif()
|
||||
endif()
|
||||
|
||||
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)
|
||||
|
||||
# If we have features.h, then do the _BSD_SOURCE magic
|
||||
check_include_file("features.h" HAVE_FEATURES_H)
|
||||
|
||||
@ -852,3 +851,14 @@ endif()
|
||||
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)
|
||||
|
@ -18,6 +18,17 @@ Building with CMake
|
||||
CMake builds can be configured either from the command line, or from one
|
||||
of CMake's GUI's.
|
||||
|
||||
Important notice
|
||||
==================
|
||||
If you got your curl sources from a distribution tarball, make sure to
|
||||
delete the generic 'include/curl/curlbuild.h' file that comes with it:
|
||||
rm -f curl/include/curl/curlbuild.h
|
||||
|
||||
The purpose of this file is to provide reasonable definitions for systems
|
||||
where autoconfiguration is not available. CMake will create its own
|
||||
version of this file in its build directory. If the "generic" version
|
||||
is not deleted, weird build errors may occur on some systems.
|
||||
|
||||
Command Line CMake
|
||||
==================
|
||||
A command line build of Curl is similar to the autotools build of Curl. It
|
||||
@ -32,9 +43,10 @@ Command Line CMake
|
||||
# variable prior to running CMake.
|
||||
cmake ../curl
|
||||
make
|
||||
# currently make test and make install are not implemented
|
||||
# currently make test is not implemented
|
||||
#make test
|
||||
#make install
|
||||
# Install to default location:
|
||||
make install
|
||||
|
||||
ccmake
|
||||
=========
|
||||
|
@ -122,3 +122,5 @@ if(WIN32)
|
||||
set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS ${LIB_NAME} DESTINATION lib)
|
||||
|
@ -54,3 +54,5 @@ if(MSVC)
|
||||
endif()
|
||||
|
||||
#INCLUDE(ModuleInstall OPTIONAL)
|
||||
|
||||
install(TARGETS ${EXE_NAME} DESTINATION bin)
|
||||
|
Loading…
Reference in New Issue
Block a user