Initial CMake scripts (libcurl only), based on the merge of tetest scripts and mine...
[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(config.h.cmake
6   ${CMAKE_CURRENT_BINARY_DIR}/config.h)
7
8 SET(libCurl_HEADERS
9         ${CMAKE_CURRENT_BINARY_DIR}/config.h
10         ${CURL_BINARY_DIR}/include/curl/curlbuild.h
11         arpa_telnet.h netrc.h file.h timeval.h qssl.h hostip.h
12         progress.h formdata.h cookie.h http.h sendf.h ftp.h url.h dict.h
13         if2ip.h speedcheck.h urldata.h curl_ldap.h ssluse.h escape.h telnet.h
14         getinfo.h strequal.h krb4.h memdebug.h http_chunks.h
15         strtok.h connect.h llist.h hash.h content_encoding.h share.h
16         curl_md5.h http_digest.h http_negotiate.h http_ntlm.h inet_pton.h
17         strtoofft.h strerror.h inet_ntop.h curlx.h memory.h setup.h
18         transfer.h select.h easyif.h multiif.h parsedate.h sslgen.h gtls.h
19         tftp.h sockaddr.h splay.h strdup.h setup_once.h socks.h ssh.h nssg.h
20         curl_base64.h rawstr.h curl_addrinfo.h curl_sspi.h slist.h
21 )
22
23 SET(libCurl_SRCS
24   #  amigaos.c - does not build on AmigaOS
25   base64.c
26   connect.c
27   content_encoding.c
28   cookie.c
29   curl_addrinfo.c
30   curl_sspi.c
31   dict.c
32   easy.c
33   escape.c
34   file.c
35   formdata.c
36   ftp.c
37   getenv.c
38   getinfo.c
39   gtls.c
40   hash.c
41   hostares.c
42   hostasyn.c
43   hostip4.c
44   hostip6.c
45   hostip.c
46   hostsyn.c
47   hostthre.c
48   http.c
49   http_chunks.c
50   http_digest.c
51   http_negotiate.c
52   http_ntlm.c
53   if2ip.c
54   inet_ntop.c
55   inet_pton.c
56   krb4.c
57   ldap.c
58   llist.c
59   md5.c
60 #  memdebug.c -not used
61   mprintf.c
62   multi.c
63   netrc.c
64   # nwlib.c - Not used
65   parsedate.c
66   progress.c
67   rawstr.c
68   security.c
69   select.c
70   sendf.c
71   slist.c
72   share.c
73   socks.c
74   speedcheck.c
75   splay.c
76   ssh.c
77   sslgen.c
78   ssluse.c
79   strdup.c
80   strequal.c
81   strerror.c
82   # strtok.c - specify later
83   # strtoofft.c - specify later
84   telnet.c
85   tftp.c
86   timeval.c
87   transfer.c
88   url.c
89   version.c
90 )
91
92 IF(MSVC)
93         LIST(APPEND libCurl_SRCS libcurl.rc)
94 ENDIF()
95
96 # if we have Kerberos 4, right now this is never on
97 #OPTION(CURL_KRB4 "Use Kerberos 4" OFF)
98 IF(CURL_KRB4)
99   SET(libCurl_SRCS ${libCurl_SRCS}
100     krb4.c
101     security.c
102     )
103 ENDIF(CURL_KRB4)
104
105 #OPTION(CURL_MALLOC_DEBUG "Debug mallocs in Curl" OFF)
106 MARK_AS_ADVANCED(CURL_MALLOC_DEBUG)
107 IF(CURL_MALLOC_DEBUG)
108   SET(libCurl_SRCS ${libCurl_SRCS}
109     memdebug.c
110     )
111 ENDIF(CURL_MALLOC_DEBUG)
112
113 IF(CURL_ZLIB AND ZLIB_FOUND)
114         INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
115 ENDIF()
116
117 IF(HAVE_FEATURES_H)
118   SET_SOURCE_FILES_PROPERTIES(
119     cookie.c
120     easy.c
121     formdata.c
122     getenv.c
123     hash.c
124     http.c
125     if2ip.c 
126     mprintf.c
127     multi.c
128     sendf.c
129     telnet.c
130     transfer.c
131     url.c
132     COMPILE_FLAGS -D_BSD_SOURCE)
133 ENDIF(HAVE_FEATURES_H)
134
135 #strtoll \
136 #socket \
137 #select \
138 #strdup \
139 #strstr \
140 #strtok_r \
141 #uname \
142 #strcasecmp \
143 #stricmp \
144 #strcmpi \
145 #gethostbyaddr \
146 #gettimeofday \
147 #inet_addr \
148 #inet_ntoa \
149 #inet_pton \
150 #perror \
151 #closesocket \
152 #siginterrupt \
153 #sigaction \
154 #signal \
155 #getpass_r \
156 #strlcat \
157 #getpwuid \
158 #geteuid \
159 #dlopen \
160 #utime \
161 #sigsetjmp \
162 #basename \
163 #setlocale \
164 #ftruncate \
165 #pipe \
166 #poll \
167 #getprotobyname \
168 #getrlimit \
169 #setrlimit \
170 #fork
171
172 # only build compat strtok if we need to
173 IF (NOT HAVE_STRTOK_R)
174   SET(libCurl_SRCS ${libCurl_SRCS}
175     strtok.c
176     )
177 ENDIF (NOT HAVE_STRTOK_R)
178
179 # only build compat strtoofft if we need to
180 IF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
181   SET(libCurl_SRCS ${libCurl_SRCS}
182     strtoofft.c
183     )
184 ENDIF(NOT HAVE_STRTOLL AND NOT HAVE__STRTOI64)
185
186 # The rest of the build
187
188 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../include)
189 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
190 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
191 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/..)
192 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
193 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
194
195 IF(CURL_STATICLIB)
196         SET(CURL_USER_DEFINED_DYNAMIC_OR_STATIC STATIC)
197 ELSE()
198         SET(CURL_USER_DEFINED_DYNAMIC_OR_STATIC SHARED)
199 ENDIF()
200
201 ADD_LIBRARY(
202         ${LIB_NAME}
203         ${CURL_USER_DEFINED_DYNAMIC_OR_STATIC}
204         ${libCurl_HEADERS} ${libCurl_SRCS}
205 )
206
207 TARGET_LINK_LIBRARIES(${LIB_NAME} ${CURL_LIBS})
208
209 IF(WIN32)
210         ADD_DEFINITIONS( -D_USRDLL )
211 ENDIF()
212
213 IF(CURL_ZLIB AND ZLIB_FOUND)
214         TARGET_LINK_LIBRARIES(${LIB_NAME} ${ZLIB_LIBRARIES})
215         #ADD_DEFINITIONS( -DHAVE_ZLIB_H -DHAVE_ZLIB -DHAVE_LIBZ )
216 ENDIF()
217
218 # IF(CURL_SSL AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
219         # LIST(APPEND DEPENDENCIES_NAMES OpenSSL)
220         # ADD_DEFINITIONS( -DUSE_SSLEAY )
221 # ENDIF()
222
223 # IF(MSVC)
224         # IF(NOT BUILD_RELEASE_DEBUG_DIRS)
225                 # # Ugly workaround to remove the "/debug" or "/release" in each output
226                 # SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES PREFIX "../")
227                 # SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_PREFIX "../")
228         # ENDIF()
229         # # Add "_imp" as a suffix before the extension
230         # SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_imp.lib")
231 # ENDIF()