summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorJakub Zakrzewski <slither.jz@gmail.com>2017-09-10 16:56:16 +0200
committerJakub Zakrzewski <slither.jz@gmail.com>2017-10-28 17:22:47 +0200
commit1cb4f5d6e8e470638759a48ba99fda230089712f (patch)
treebb5c4021aae5816656defc0e4a65eb8d6e07604e /CMakeLists.txt
parent58a9e770e331e393f9b16cdbe0edb4de86552c7e (diff)
downloadgnurl-1cb4f5d6e8e470638759a48ba99fda230089712f.tar.gz
gnurl-1cb4f5d6e8e470638759a48ba99fda230089712f.tar.bz2
gnurl-1cb4f5d6e8e470638759a48ba99fda230089712f.zip
cmake: Export libcurl and curl targets to use by other cmake projects
The config files define curl and libcurl targets as imported targets CURL::curl and CURL::libcurl. For backward compatibility with CMake- provided find-module the CURL_INCLUDE_DIRS and CURL_LIBRARIES are also set. Closes #1879
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt27
1 files changed, 26 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3bfb5febd..c41759aa1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,7 @@
# To check:
# (From Daniel Stenberg) The cmake build selected to run gcc with -fPIC on my box while the plain configure script did not.
# (From Daniel Stenberg) The gcc command line use neither -g nor any -O options. As a developer, I also treasure our configure scripts's --enable-debug option that sets a long range of "picky" compiler options.
-cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
include(Utilities)
include(Macros)
@@ -1130,6 +1130,12 @@ function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
endfunction()
+if(WIN32 AND NOT CYGWIN)
+ set(CURL_INSTALL_CMAKE_DIR CMake)
+else()
+ set(CURL_INSTALL_CMAKE_DIR lib/cmake/curl)
+endif()
+
if(USE_MANUAL)
add_subdirectory(docs)
endif()
@@ -1280,6 +1286,25 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/curl"
DESTINATION include
FILES_MATCHING PATTERN "*.h")
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${PROJECT_BINARY_DIR}/curl-config-version.cmake"
+ VERSION ${CURL_VERSION}
+ COMPATIBILITY SameMajorVersion
+)
+
+configure_file(CMake/curl-config.cmake
+ "${PROJECT_BINARY_DIR}/curl-config.cmake"
+ COPYONLY
+)
+
+install(
+ FILES ${PROJECT_BINARY_DIR}/curl-config.cmake
+ ${PROJECT_BINARY_DIR}/curl-config-version.cmake
+ DESTINATION ${CURL_INSTALL_CMAKE_DIR}
+)
+
# Workaround for MSVS10 to avoid the Dialog Hell
# FIXME: This could be removed with future version of CMake.
if(MSVC_VERSION EQUAL 1600)