b2bcf090467074c3676025336d45bc010a70cfc8
[platform/upstream/curl.git] / lib / CMakeLists.txt
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 if(HAVE_FEATURES_H)
52   set_source_files_properties(
53     cookie.c
54     easy.c
55     formdata.c
56     getenv.c
57     nonblock.c
58     hash.c
59     http.c
60     if2ip.c
61     mprintf.c
62     multi.c
63     sendf.c
64     telnet.c
65     transfer.c
66     url.c
67     COMPILE_FLAGS -D_BSD_SOURCE)
68 endif(HAVE_FEATURES_H)
69
70
71 # The rest of the build
72
73 include_directories(${CMAKE_CURRENT_BINARY_DIR}/../include)
74 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
75 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
76 include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
77 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
78 include_directories(${CMAKE_CURRENT_BINARY_DIR})
79 if(CURL_USE_ARES)
80   include_directories(${CARES_INCLUDE_DIR})
81 endif()
82
83 if(CURL_STATICLIB)
84   # Static lib
85   set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC)
86 else()
87   # DLL / so dynamic lib
88   set(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED)
89 endif()
90
91 add_library(
92   ${LIB_NAME}
93   ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC}
94   ${HHEADERS} ${CSOURCES}
95   )
96
97 if(MSVC AND CURL_STATICLIB)
98   set_target_properties(${LIB_NAME} PROPERTIES STATIC_LIBRARY_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
99 endif()
100
101 target_link_libraries(${LIB_NAME} ${CURL_LIBS})
102
103 if(WIN32)
104   add_definitions( -D_USRDLL )
105 endif()
106
107 set_target_properties(${LIB_NAME} PROPERTIES COMPILE_DEFINITIONS BUILDING_LIBCURL)
108
109 setup_curl_dependencies(${LIB_NAME})
110
111 # Remove the "lib" prefix since the library is already named "libcurl".
112 set_target_properties(${LIB_NAME} PROPERTIES PREFIX "")
113 set_target_properties(${LIB_NAME} PROPERTIES IMPORT_PREFIX "")
114
115 if(WIN32)
116   if(NOT CURL_STATICLIB)
117     # Add "_imp" as a suffix before the extension to avoid conflicting with the statically linked "libcurl.lib"
118     set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
119   endif()
120 endif()
121
122 install(TARGETS ${LIB_NAME} DESTINATION lib)