1set(LIB_NAME libcurl) 2 3configure_file(${CURL_SOURCE_DIR}/include/curl/curlbuild.h.cmake 4 ${CURL_BINARY_DIR}/include/curl/curlbuild.h) 5configure_file(curl_config.h.cmake 6 ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h) 7 8transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") 9include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake) 10 11list(APPEND HHEADERS 12 ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h 13 ${CURL_BINARY_DIR}/include/curl/curlbuild.h 14 ) 15 16if(MSVC) 17 list(APPEND CSOURCES libcurl.rc) 18endif() 19 20# SET(CSOURCES 21# # memdebug.c -not used 22# # nwlib.c - Not used 23# # strtok.c - specify later 24# # strtoofft.c - specify later 25# ) 26 27# # if we have Kerberos 4, right now this is never on 28# #OPTION(CURL_KRB4 "Use Kerberos 4" OFF) 29# IF(CURL_KRB4) 30# SET(CSOURCES ${CSOURCES} 31# krb4.c 32# security.c 33# ) 34# ENDIF(CURL_KRB4) 35 36# #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF) 37# MARK_AS_ADVANCED(CURL_MALLOC_DEBUG) 38# IF(CURL_MALLOC_DEBUG) 39# SET(CSOURCES ${CSOURCES} 40# memdebug.c 41# ) 42# ENDIF(CURL_MALLOC_DEBUG) 43 44# # only build compat strtoofft if we need to 45# IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64) 46# SET(CSOURCES ${CSOURCES} 47# strtoofft.c 48# ) 49# ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64) 50 51 52# The rest of the build 53 54include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include) 55include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) 56include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include) 57include_directories(${CMAKE_CURRENT_BINARY_DIR}/..) 58include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 59include_directories(${CMAKE_CURRENT_BINARY_DIR}) 60if(USE_ARES) 61 include_directories(${CARES_INCLUDE_DIR}) 62endif() 63 64if(CURL_STATICLIB) 65 # Static lib 66 set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC) 67else() 68 # DLL / so dynamic lib 69 set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED) 70endif() 71 72add_library( 73 ${LIB_NAME} 74 ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC} 75 ${HHEADERS} ${CSOURCES} 76 ) 77 78if(MSVC AND CURL_STATICLIB) 79 set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) 80endif() 81 82target_link_libraries(${LIB_NAME} ${CURL_LIBS}) 83 84if(WIN32) 85 add_definitions( -D_USRDLL ) 86endif() 87 88set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL) 89 90# Remove the "lib" prefix since the library is already named "libcurl". 91set_target_properties(${LIB_NAME} PROPERTIES PREFIX "") 92set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "") 93 94if(WIN32) 95 if(NOT CURL_STATICLIB) 96 # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib" 97 set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib") 98 endif() 99endif() 100 101install(TARGETS ${LIB_NAME} 102 ARCHIVE DESTINATION lib 103 LIBRARY DESTINATION lib 104 RUNTIME DESTINATION bin) 105