CMakeLists.txt 3.1 KB

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