CMakeLists.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. # The rest of the build
  43. include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include)
  44. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
  45. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
  46. include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
  47. include_directories(${CMAKE_CURRENT_SOURCE_DIR})
  48. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  49. if(USE_ARES)
  50. include_directories(${CARES_INCLUDE_DIR})
  51. endif()
  52. if(CURL_STATICLIB)
  53. # Static lib
  54. set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC)
  55. else()
  56. # DLL / so dynamic lib
  57. set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED)
  58. endif()
  59. add_library(
  60. ${LIB_NAME}
  61. ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC}
  62. ${HHEADERS} ${CSOURCES}
  63. )
  64. if(MSVC AND CURL_STATICLIB)
  65. set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
  66. endif()
  67. target_link_libraries(${LIB_NAME} ${CURL_LIBS})
  68. if(WIN32)
  69. add_definitions( -D_USRDLL )
  70. endif()
  71. set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL)
  72. # Remove the "lib" prefix since the library is already named "libcurl".
  73. set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
  74. set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
  75. if(WIN32)
  76. if(NOT CURL_STATICLIB)
  77. # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib"
  78. set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
  79. endif()
  80. endif()
  81. install(TARGETS ${LIB_NAME} DESTINATION lib)