2020-03-23 16:44:29 +03:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2021-03-27 14:52:25 +03:00
|
|
|
# Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-03-23 16:44:29 +03:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 16:02:01 +03:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-03-23 16:44:29 +03:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
###########################################################################
|
2021-04-21 16:03:04 +03:00
|
|
|
set(LIB_NAME libcurl)
|
2021-04-22 18:29:45 +03:00
|
|
|
set(LIBCURL_OUTPUT_NAME libcurl CACHE STRING "Basename of the curl library")
|
2009-04-02 17:14:53 +04:00
|
|
|
|
2018-07-10 12:54:34 +03:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set(CURL_STATICLIB NO)
|
|
|
|
else()
|
|
|
|
set(CURL_STATICLIB YES)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Use:
|
|
|
|
# * CURL_STATICLIB
|
2009-07-14 17:25:14 +04:00
|
|
|
configure_file(curl_config.h.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
|
2009-04-02 17:14:53 +04:00
|
|
|
|
2009-06-09 21:29:16 +04:00
|
|
|
transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
|
|
|
include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
|
2009-04-07 02:45:17 +04:00
|
|
|
|
2009-06-09 21:29:16 +04:00
|
|
|
list(APPEND HHEADERS
|
2009-07-14 17:25:14 +04:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h
|
2009-06-09 21:29:16 +04:00
|
|
|
)
|
2009-04-02 17:14:53 +04:00
|
|
|
|
2020-11-17 14:32:27 +03:00
|
|
|
if(WIN32)
|
2009-06-09 21:29:16 +04:00
|
|
|
list(APPEND CSOURCES libcurl.rc)
|
|
|
|
endif()
|
2009-04-02 17:14:53 +04:00
|
|
|
|
2009-04-07 02:45:17 +04:00
|
|
|
# SET(CSOURCES
|
2013-01-04 05:50:28 +04:00
|
|
|
# # memdebug.c -not used
|
|
|
|
# # nwlib.c - Not used
|
|
|
|
# # strtok.c - specify later
|
|
|
|
# # strtoofft.c - specify later
|
2009-04-07 02:45:17 +04:00
|
|
|
# )
|
|
|
|
|
|
|
|
# #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF)
|
|
|
|
# MARK_AS_ADVANCED(CURL_MALLOC_DEBUG)
|
|
|
|
# IF(CURL_MALLOC_DEBUG)
|
2009-06-09 21:29:16 +04:00
|
|
|
# SET(CSOURCES ${CSOURCES}
|
2013-01-04 05:50:28 +04:00
|
|
|
# memdebug.c
|
2009-06-09 21:29:16 +04:00
|
|
|
# )
|
2009-04-07 02:45:17 +04:00
|
|
|
# ENDIF(CURL_MALLOC_DEBUG)
|
|
|
|
|
|
|
|
# # only build compat strtoofft if we need to
|
|
|
|
# IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
|
2009-06-09 21:29:16 +04:00
|
|
|
# SET(CSOURCES ${CSOURCES}
|
2013-01-04 05:50:28 +04:00
|
|
|
# strtoofft.c
|
2009-06-09 21:29:16 +04:00
|
|
|
# )
|
2009-04-07 02:45:17 +04:00
|
|
|
# ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
|
2009-04-02 17:14:53 +04:00
|
|
|
|
|
|
|
|
|
|
|
# The rest of the build
|
|
|
|
|
2009-06-09 21:29:16 +04:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2014-11-06 03:32:45 +03:00
|
|
|
if(USE_ARES)
|
2009-07-14 23:03:31 +04:00
|
|
|
include_directories(${CARES_INCLUDE_DIR})
|
|
|
|
endif()
|
2009-04-02 17:14:53 +04:00
|
|
|
|
2009-06-09 21:29:16 +04:00
|
|
|
add_library(
|
|
|
|
${LIB_NAME}
|
|
|
|
${HHEADERS} ${CSOURCES}
|
|
|
|
)
|
2009-04-02 17:14:53 +04:00
|
|
|
|
2020-04-09 23:42:22 +03:00
|
|
|
add_library(
|
|
|
|
${PROJECT_NAME}::${LIB_NAME}
|
|
|
|
ALIAS ${LIB_NAME}
|
|
|
|
)
|
|
|
|
|
2018-08-01 15:02:26 +03:00
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB)
|
|
|
|
endif()
|
|
|
|
|
2009-06-09 21:29:16 +04:00
|
|
|
target_link_libraries(${LIB_NAME} ${CURL_LIBS})
|
2009-04-02 17:14:53 +04:00
|
|
|
|
2021-04-22 18:29:45 +03:00
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES
|
|
|
|
COMPILE_DEFINITIONS BUILDING_LIBCURL
|
|
|
|
OUTPUT_NAME ${LIBCURL_OUTPUT_NAME}
|
|
|
|
)
|
2009-04-07 00:44:01 +04:00
|
|
|
|
2016-09-04 13:37:46 +03:00
|
|
|
if(HIDES_CURL_PRIVATE_SYMBOLS)
|
|
|
|
set_property(TARGET ${LIB_NAME} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS")
|
|
|
|
set_property(TARGET ${LIB_NAME} APPEND PROPERTY COMPILE_FLAGS ${CURL_CFLAG_SYMBOLS_HIDE})
|
|
|
|
endif()
|
|
|
|
|
2009-04-06 23:43:52 +04:00
|
|
|
# Remove the "lib" prefix since the library is already named "libcurl".
|
2009-06-09 21:29:16 +04:00
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
|
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
|
|
|
|
|
2020-01-09 14:10:55 +03:00
|
|
|
if(CURL_HAS_LTO)
|
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES
|
|
|
|
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
|
|
|
|
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
|
|
|
|
endif()
|
|
|
|
|
2009-06-09 21:29:16 +04:00
|
|
|
if(WIN32)
|
2018-07-10 12:54:34 +03:00
|
|
|
if(BUILD_SHARED_LIBS)
|
2021-11-18 00:21:28 +03:00
|
|
|
set_property(TARGET ${LIB_NAME} APPEND PROPERTY COMPILE_DEFINITIONS "_USRDLL")
|
2020-11-19 21:34:43 +03:00
|
|
|
if(MSVC)
|
|
|
|
# Add "_imp" as a suffix before the extension to avoid conflicting with
|
|
|
|
# the statically linked "libcurl.lib"
|
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
|
|
|
|
endif()
|
2009-06-09 21:29:16 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2011-04-28 00:05:07 +04:00
|
|
|
|
2017-09-10 17:56:16 +03:00
|
|
|
target_include_directories(${LIB_NAME} INTERFACE
|
2021-01-12 16:11:07 +03:00
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
2018-09-07 16:45:11 +03:00
|
|
|
$<BUILD_INTERFACE:${CURL_SOURCE_DIR}/include>)
|
2017-09-10 17:56:16 +03:00
|
|
|
|
2015-02-19 01:19:04 +03:00
|
|
|
install(TARGETS ${LIB_NAME}
|
2018-07-18 02:31:51 +03:00
|
|
|
EXPORT ${TARGETS_EXPORT_NAME}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
2017-09-10 17:56:16 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
export(TARGETS ${LIB_NAME}
|
|
|
|
APPEND FILE ${PROJECT_BINARY_DIR}/libcurl-target.cmake
|
2020-04-09 23:42:22 +03:00
|
|
|
NAMESPACE ${PROJECT_NAME}::
|
2017-09-10 17:56:16 +03:00
|
|
|
)
|