2009-06-09 13:29:16 -04:00
|
|
|
set(LIB_NAME libcurl)
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2018-07-10 05:54:34 -04:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set(CURL_STATICLIB NO)
|
|
|
|
else()
|
|
|
|
set(CURL_STATICLIB YES)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Use:
|
|
|
|
# * CURL_STATICLIB
|
2009-07-14 09:25:14 -04:00
|
|
|
configure_file(curl_config.h.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2009-06-09 13: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-06 18:45:17 -04:00
|
|
|
|
2009-06-09 13:29:16 -04:00
|
|
|
list(APPEND HHEADERS
|
2009-07-14 09:25:14 -04:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h
|
2009-06-09 13:29:16 -04:00
|
|
|
)
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2009-06-09 13:29:16 -04:00
|
|
|
if(MSVC)
|
|
|
|
list(APPEND CSOURCES libcurl.rc)
|
2017-07-18 12:46:53 -04:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
|
2009-06-09 13:29:16 -04:00
|
|
|
endif()
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2009-04-06 18:45:17 -04:00
|
|
|
# SET(CSOURCES
|
2013-01-03 20:50:28 -05:00
|
|
|
# # memdebug.c -not used
|
|
|
|
# # nwlib.c - Not used
|
|
|
|
# # strtok.c - specify later
|
|
|
|
# # strtoofft.c - specify later
|
2009-04-06 18:45:17 -04:00
|
|
|
# )
|
|
|
|
|
|
|
|
# # if we have Kerberos 4, right now this is never on
|
|
|
|
# #OPTION(CURL_KRB4 "Use Kerberos 4" OFF)
|
|
|
|
# IF(CURL_KRB4)
|
2009-06-09 13:29:16 -04:00
|
|
|
# SET(CSOURCES ${CSOURCES}
|
2013-01-03 20:50:28 -05:00
|
|
|
# krb4.c
|
|
|
|
# security.c
|
2009-06-09 13:29:16 -04:00
|
|
|
# )
|
2009-04-06 18:45:17 -04:00
|
|
|
# ENDIF(CURL_KRB4)
|
|
|
|
|
|
|
|
# #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF)
|
|
|
|
# MARK_AS_ADVANCED(CURL_MALLOC_DEBUG)
|
|
|
|
# IF(CURL_MALLOC_DEBUG)
|
2009-06-09 13:29:16 -04:00
|
|
|
# SET(CSOURCES ${CSOURCES}
|
2013-01-03 20:50:28 -05:00
|
|
|
# memdebug.c
|
2009-06-09 13:29:16 -04:00
|
|
|
# )
|
2009-04-06 18: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 13:29:16 -04:00
|
|
|
# SET(CSOURCES ${CSOURCES}
|
2013-01-03 20:50:28 -05:00
|
|
|
# strtoofft.c
|
2009-06-09 13:29:16 -04:00
|
|
|
# )
|
2009-04-06 18:45:17 -04:00
|
|
|
# ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
|
2009-04-02 09:14:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
# The rest of the build
|
|
|
|
|
2009-06-09 13: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-05 19:32:45 -05:00
|
|
|
if(USE_ARES)
|
2009-07-14 15:03:31 -04:00
|
|
|
include_directories(${CARES_INCLUDE_DIR})
|
|
|
|
endif()
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2009-06-09 13:29:16 -04:00
|
|
|
add_library(
|
|
|
|
${LIB_NAME}
|
|
|
|
${HHEADERS} ${CSOURCES}
|
|
|
|
)
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2018-07-10 05:54:34 -04:00
|
|
|
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
2013-07-09 11:20:41 -04:00
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
|
|
|
|
endif()
|
|
|
|
|
2018-08-01 08:02:26 -04:00
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB)
|
|
|
|
endif()
|
|
|
|
|
2009-06-09 13:29:16 -04:00
|
|
|
target_link_libraries(${LIB_NAME} ${CURL_LIBS})
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2009-06-09 13:29:16 -04:00
|
|
|
if(WIN32)
|
2018-07-17 02:36:59 -04:00
|
|
|
add_definitions(-D_USRDLL)
|
2009-06-09 13:29:16 -04:00
|
|
|
endif()
|
2009-04-02 09:14:53 -04:00
|
|
|
|
2009-06-09 13:29:16 -04:00
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL)
|
2009-04-06 16:44:01 -04:00
|
|
|
|
2016-09-04 06:37:46 -04: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 15:43:52 -04:00
|
|
|
# Remove the "lib" prefix since the library is already named "libcurl".
|
2009-06-09 13:29:16 -04:00
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
|
|
|
|
set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
|
|
|
|
|
|
|
|
if(WIN32)
|
2018-07-10 05:54:34 -04:00
|
|
|
if(BUILD_SHARED_LIBS)
|
2009-06-09 13:29:16 -04:00
|
|
|
# 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()
|
|
|
|
endif()
|
2011-04-27 16:05:07 -04:00
|
|
|
|
2017-09-10 10:56:16 -04:00
|
|
|
target_include_directories(${LIB_NAME} INTERFACE
|
2018-07-17 02:36:59 -04:00
|
|
|
$<INSTALL_INTERFACE:include>)
|
2017-09-10 10:56:16 -04:00
|
|
|
|
2015-02-18 17:19:04 -05:00
|
|
|
install(TARGETS ${LIB_NAME}
|
2017-09-10 10:56:16 -04:00
|
|
|
EXPORT libcurl-target
|
2015-02-18 17:19:04 -05:00
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib
|
2017-09-10 10:56:16 -04:00
|
|
|
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 ${CURL_INSTALL_CMAKE_DIR}
|
|
|
|
)
|