Skip to content

Commit

Permalink
Merge aa2a4ec into 64bb7ae
Browse files Browse the repository at this point in the history
  • Loading branch information
jzakrzewski committed Sep 10, 2017
2 parents 64bb7ae + aa2a4ec commit e9b0317
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 3 deletions.
30 changes: 30 additions & 0 deletions CMake/curl-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

if(NOT curl_FIND_COMPONENTS)
set(curl_FIND_COMPONENTS curl libcurl)
if(curl_FIND_REQUIRED)
set(curl_FIND_REQUIRED_curl TRUE)
set(curl_FIND_REQUIRED_libcurl TRUE)
endif()
endif()

set(_curl_missing_components)
foreach(_comp ${curl_FIND_COMPONENTS})
if(EXISTS "${_DIR}/${_comp}-target.cmake")
include("${_DIR}/${_comp}-target.cmake")
set(curl_${_comp}_FOUND TRUE)
else()
set(curl_${_comp}_FOUND FALSE)
if(curl_FIND_REQUIRED_${_comp})
set(curl_FOUND FALSE)
list(APPEND _curl_missing_components ${_comp})
endif()
endif()
endforeach()

if(NOT curl_FOUND)
set(curl_NOT_FOUND_MESSAGE "Following required components not found: " ${_curl_missing_components})
endif()

unset(_curl_missing_components)
27 changes: 26 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.8 FATAL_ERROR)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
include(Utilities)
include(Macros)
Expand Down Expand Up @@ -1149,6 +1149,12 @@ function(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)

endfunction()

if(WIN32 AND NOT CYGWIN)
set(INSTALL_CMAKE_DIR CMake)
else()
set(INSTALL_CMAKE_DIR lib/cmake/curl)
endif()

add_subdirectory(docs)
add_subdirectory(lib)
if(BUILD_CURL_EXE)
Expand Down Expand Up @@ -1295,6 +1301,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 ${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)
Expand Down
16 changes: 15 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,20 @@ if(WIN32)
endif()

install(TARGETS ${LIB_NAME}
EXPORT libcurl-target
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
RUNTIME DESTINATION bin
)

export(TARGETS ${LIB_NAME}
APPEND FILE ${PROJECT_BINARY_DIR}/libcurl-target.cmake
NAMESPACE curl::
)

install(EXPORT libcurl-target
FILE libcurl-target.cmake
NAMESPACE curl::
DESTINATION ${INSTALL_CMAKE_DIR}
)

13 changes: 12 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,15 @@ set_target_properties(${EXE_NAME} PROPERTIES

#INCLUDE(ModuleInstall OPTIONAL)

install(TARGETS ${EXE_NAME} DESTINATION bin)
install(TARGETS ${EXE_NAME} EXPORT curl-target DESTINATION bin)
export(TARGETS ${EXE_NAME}
APPEND FILE ${PROJECT_BINARY_DIR}/curl-target.cmake
NAMESPACE curl::
)

install(EXPORT curl-target
FILE curl-target.cmake
NAMESPACE curl::
DESTINATION ${INSTALL_CMAKE_DIR}
)

0 comments on commit e9b0317

Please sign in to comment.