1 | set(LIB_NAME libcurl)
|
---|
2 |
|
---|
3 | if(BUILD_SHARED_LIBS)
|
---|
4 | set(CURL_STATICLIB NO)
|
---|
5 | else()
|
---|
6 | set(CURL_STATICLIB YES)
|
---|
7 | endif()
|
---|
8 |
|
---|
9 | # Use:
|
---|
10 | # * CURL_STATICLIB
|
---|
11 | configure_file(curl_config.h.cmake
|
---|
12 | ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
|
---|
13 |
|
---|
14 | transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
|
---|
15 | include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
|
---|
16 |
|
---|
17 | list(APPEND HHEADERS
|
---|
18 | ${CMAKE_CURRENT_BINARY_DIR}/curl_config.h
|
---|
19 | )
|
---|
20 |
|
---|
21 | if(MSVC)
|
---|
22 | list(APPEND CSOURCES libcurl.rc)
|
---|
23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
|
---|
24 | endif()
|
---|
25 |
|
---|
26 | # SET(CSOURCES
|
---|
27 | # # memdebug.c -not used
|
---|
28 | # # nwlib.c - Not used
|
---|
29 | # # strtok.c - specify later
|
---|
30 | # # strtoofft.c - specify later
|
---|
31 | # )
|
---|
32 |
|
---|
33 | # # if we have Kerberos 4, right now this is never on
|
---|
34 | # #OPTION(CURL_KRB4 "Use Kerberos 4" OFF)
|
---|
35 | # IF(CURL_KRB4)
|
---|
36 | # SET(CSOURCES ${CSOURCES}
|
---|
37 | # krb4.c
|
---|
38 | # security.c
|
---|
39 | # )
|
---|
40 | # ENDIF(CURL_KRB4)
|
---|
41 |
|
---|
42 | # #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF)
|
---|
43 | # MARK_AS_ADVANCED(CURL_MALLOC_DEBUG)
|
---|
44 | # IF(CURL_MALLOC_DEBUG)
|
---|
45 | # SET(CSOURCES ${CSOURCES}
|
---|
46 | # memdebug.c
|
---|
47 | # )
|
---|
48 | # ENDIF(CURL_MALLOC_DEBUG)
|
---|
49 |
|
---|
50 | # # only build compat strtoofft if we need to
|
---|
51 | # IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
|
---|
52 | # SET(CSOURCES ${CSOURCES}
|
---|
53 | # strtoofft.c
|
---|
54 | # )
|
---|
55 | # ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
|
---|
56 |
|
---|
57 |
|
---|
58 | # The rest of the build
|
---|
59 |
|
---|
60 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include)
|
---|
61 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
---|
62 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
|
---|
63 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
|
---|
64 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
---|
65 | include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
---|
66 | if(USE_ARES)
|
---|
67 | include_directories(${CARES_INCLUDE_DIR})
|
---|
68 | endif()
|
---|
69 |
|
---|
70 | add_library(
|
---|
71 | ${LIB_NAME}
|
---|
72 | ${HHEADERS} ${CSOURCES}
|
---|
73 | )
|
---|
74 |
|
---|
75 | if(MSVC AND NOT BUILD_SHARED_LIBS)
|
---|
76 | set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
|
---|
77 | endif()
|
---|
78 |
|
---|
79 | if(NOT BUILD_SHARED_LIBS)
|
---|
80 | set_target_properties(${LIB_NAME} PROPERTIES INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB)
|
---|
81 | endif()
|
---|
82 |
|
---|
83 | target_link_libraries(${LIB_NAME} ${CURL_LIBS})
|
---|
84 |
|
---|
85 | if(WIN32)
|
---|
86 | add_definitions(-D_USRDLL)
|
---|
87 | endif()
|
---|
88 |
|
---|
89 | set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL)
|
---|
90 |
|
---|
91 | if(HIDES_CURL_PRIVATE_SYMBOLS)
|
---|
92 | set_property(TARGET ${LIB_NAME} APPEND PROPERTY COMPILE_DEFINITIONS "CURL_HIDDEN_SYMBOLS")
|
---|
93 | set_property(TARGET ${LIB_NAME} APPEND PROPERTY COMPILE_FLAGS ${CURL_CFLAG_SYMBOLS_HIDE})
|
---|
94 | endif()
|
---|
95 |
|
---|
96 | # Remove the "lib" prefix since the library is already named "libcurl".
|
---|
97 | set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
|
---|
98 | set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
|
---|
99 |
|
---|
100 | if(WIN32)
|
---|
101 | if(BUILD_SHARED_LIBS)
|
---|
102 | # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib"
|
---|
103 | set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
|
---|
104 | endif()
|
---|
105 | endif()
|
---|
106 |
|
---|
107 | target_include_directories(${LIB_NAME} INTERFACE
|
---|
108 | $<INSTALL_INTERFACE:include>
|
---|
109 | $<BUILD_INTERFACE:${CURL_SOURCE_DIR}/include>)
|
---|
110 |
|
---|
111 | install(TARGETS ${LIB_NAME}
|
---|
112 | EXPORT ${TARGETS_EXPORT_NAME}
|
---|
113 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
---|
114 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
---|
115 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
---|
116 | )
|
---|
117 |
|
---|
118 | export(TARGETS ${LIB_NAME}
|
---|
119 | APPEND FILE ${PROJECT_BINARY_DIR}/libcurl-target.cmake
|
---|
120 | NAMESPACE CURL::
|
---|
121 | )
|
---|