CMakeLists.txt 3.1 KB

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