Home | History | Annotate | Download | only in lib
      1 set(LIB_NAME libcurl)
      2 
      3 configure_file(${CURL_SOURCE_DIR}/include/curl/curlbuild.h.cmake
      4   ${CURL_BINARY_DIR}/include/curl/curlbuild.h)
      5 configure_file(curl_config.h.cmake
      6   ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
      7 
      8 transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
      9 include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
     10 
     11 list(APPEND HHEADERS
     12   ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h
     13   ${CURL_BINARY_DIR}/include/curl/curlbuild.h
     14   )
     15 
     16 if(MSVC)
     17   list(APPEND CSOURCES libcurl.rc)
     18 endif()
     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 
     54 include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include)
     55 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
     56 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
     57 include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
     58 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
     59 include_directories(${CMAKE_CURRENT_BINARY_DIR})
     60 if(USE_ARES)
     61   include_directories(${CARES_INCLUDE_DIR})
     62 endif()
     63 
     64 if(CURL_STATICLIB)
     65   # Static lib
     66   set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC)
     67 else()
     68   # DLL / so dynamic lib
     69   set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED)
     70 endif()
     71 
     72 add_library(
     73   ${LIB_NAME}
     74   ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC}
     75   ${HHEADERS} ${CSOURCES}
     76   )
     77 
     78 if(MSVC AND CURL_STATICLIB)
     79   set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
     80 endif()
     81 
     82 target_link_libraries(${LIB_NAME} ${CURL_LIBS})
     83 
     84 if(WIN32)
     85   add_definitions( -D_USRDLL )
     86 endif()
     87 
     88 set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL)
     89 
     90 # Remove the "lib" prefix since the library is already named "libcurl".
     91 set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
     92 set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
     93 
     94 if(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()
     99 endif()
    100 
    101 install(TARGETS ${LIB_NAME}
    102   ARCHIVE DESTINATION lib
    103   LIBRARY DESTINATION lib
    104   RUNTIME DESTINATION bin)
    105