diff options
author | Zmey Petroff <zmeypetroff@newmail.ru> | 2011-04-28 00:05:07 +0400 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-04-28 10:12:33 +0200 |
commit | 2cbe885c1a4d4f9b64fa0f41582e9d1b68affa25 (patch) | |
tree | 1f6fd2e4bea90d1773dc5a47ea6fe6879a5f344f | |
parent | 4a42e5cdaa344755c6bf5317908849619f61798b (diff) |
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).
-rw-r--r-- | CMakeLists.txt | 56 | ||||
-rwxr-xr-x | docs/INSTALL.cmake | 16 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 2 |
4 files changed, 51 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 55312ccba..3a5bc4a0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) +
\ No newline at end of file diff --git a/docs/INSTALL.cmake b/docs/INSTALL.cmake index 4217cebf1..1e5a0dee4 100755 --- a/docs/INSTALL.cmake +++ b/docs/INSTALL.cmake @@ -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 ========= diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index aec1a3c5b..09b976c4c 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -122,3 +122,5 @@ if(WIN32) set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib") endif() endif() + +install(TARGETS ${LIB_NAME} DESTINATION lib) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index faea09676..eb6933e69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,3 +54,5 @@ if(MSVC) endif() #INCLUDE(ModuleInstall OPTIONAL) + +install(TARGETS ${EXE_NAME} DESTINATION bin) |