debian: fix build-deps for focal
[amule.git] / src / CMakeLists.txt
blob09175b4f9cf505e011239b2a9474dde5dc88bfe8
1 set (LIBS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs")
2 set (INCLUDE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
3 set (SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
4 set (EC_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs/ec/cpp")
6 add_custom_command (
7         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pixmaps/flags_xpm/CountryFlags.h
8         COMMAND ${CMAKE_COMMAND} -DHEADER_FILE="${CMAKE_CURRENT_BINARY_DIR}/pixmaps/flags_xpm/CountryFlags.h" -P ${CMAKE_CURRENT_SOURCE_DIR}/pixmaps/flags_xpm/CMakeLists.txt
9         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/pixmaps/flags_xpm"
12 add_custom_command (
13         OUTPUT ${EC_INCLUDE_DIR}/ECCodes.h
14         COMMAND ${CMAKE_COMMAND} -DHEADER_FILE="${CMAKE_CURRENT_BINARY_DIR}/libs/ec/cpp/ECCodes.h" -P ${CMAKE_CURRENT_SOURCE_DIR}/libs/ec/abstracts/CMakeLists.txt
15         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/ec/abstracts"
18 add_custom_command (
19         OUTPUT ${EC_INCLUDE_DIR}/ECTagTypes.h
20         COMMAND ${CMAKE_COMMAND} -DHEADER_FILE="${CMAKE_CURRENT_BINARY_DIR}/libs/ec/cpp/ECTagTypes.h" -P ${CMAKE_CURRENT_SOURCE_DIR}/libs/ec/abstracts/CMakeLists.txt
21         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/ec/abstracts"
24 add_custom_target (generate_CountryFlags.h DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pixmaps/flags_xpm/CountryFlags.h)
25 add_custom_target (generate_ECCodes.h DEPENDS ${EC_INCLUDE_DIR}/ECCodes.h)
26 add_custom_target (generate_ECTagTypes.h DEPENDS ${EC_INCLUDE_DIR}/ECTagTypes.h)
27 set_source_files_properties (${CMAKE_CURRENT_BINARY_DIR}/pixmaps/flags_xpm/CountryFlags.h PROPERTIES GENERATED TRUE)
28 set_source_files_properties (${EC_INCLUDE_DIR}/ECCodes.h PROPERTIES GENERATED TRUE)
29 set_source_files_properties (${EC_INCLUDE_DIR}/ECTagTypes.h PROPERTIES GENERATED TRUE)
30 include (${CMAKE_SOURCE_DIR}/cmake/source-vars.cmake)
32 if (BUILD_UTIL)
33         add_subdirectory (utils)
34 endif()
36 if (BUILD_WEBSERVER)
37         add_subdirectory (webserver)
38 endif()
40 if (INSTALL_SKINS)
41         add_subdirectory (skins)
42 endif()
45 if (ENABLE_IP2COUNTRY)
46         set_source_files_properties (${IP2COUNTRY}
47                 PROPERTIES COMPILE_FLAGS "-I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}/pixmaps/flags_xpm"
48         )
49 endif()
51 if (NEED_LIB)
52         add_subdirectory (libs)
53 endif()
55 if (BUILD_AMULECMD)
56         add_executable (amulecmd
57                 DataToText.cpp
58                 ExternalConnector.cpp
59                 LoggerConsole.cpp
60                 NetworkFunctions.cpp
61                 OtherFunctions.cpp
62                 TextClient.cpp
63         )
65         if (WIN32)
66                 target_sources (amulecmd
67                         PRIVATE ${CMAKE_SOURCE_DIR}/version.rc
68                 )
69         endif()
71         target_compile_definitions (amulecmd
72                 PRIVATE wxUSE_GUI=0
73         )
75         target_include_directories (amulecmd
76                 PRIVATE ${SRC_DIR}
77         )
79         target_link_libraries (amulecmd
80                 mulecommon
81                 mulesocket
82                 ec
83         )
85         if (HAVE_BFD)
86                 target_link_libraries (amulecmd ${LIBBFD})
87         endif (HAVE_BFD)
89         if (HAVE_LIBREADLINE)
90                 target_link_libraries (amulecmd ${READLINE_LIBRARIES})
91         endif()
93         install (TARGETS amulecmd
94                 RUNTIME DESTINATION bin
95         )
96 endif (BUILD_AMULECMD)
98 if (BUILD_DAEMON)
99         add_executable (amuled
100                 ${CORE_SOURCES}
101                 ${COMMON_SOURCES}
102                 amuled.cpp
103         )
105         if (WIN32)
106                 target_sources (amuled
107                         PRIVATE ${CMAKE_SOURCE_DIR}/version.rc
108                 )
109         endif()
111         target_compile_definitions (amuled
112                 PRIVATE AMULE_DAEMON
113                 PRIVATE wxUSE_GUI=0
114         )
116         target_include_directories (amuled
117                 PRIVATE ${SRC_DIR}
118         )
120         target_link_libraries (amuled
121                 ec
122                 muleappcommon
123                 muleappcore
124                 mulecommon
125                 mulesocket
126                 wxWidgets::NET
127         )
129         if (HAVE_BFD)
130                 target_link_libraries (amuled
131                         ${LIBBFD}
132                 )
133         endif()
135         if (WIN32)
136                 target_link_libraries (amuled
137                         shlwapi.lib
138                 )
139         endif()
141         install (TARGETS amuled
142                 RUNTIME DESTINATION bin
143         )
144 endif()
146 if (BUILD_ED2K)
147         add_executable (ed2k
148                 ED2KLinkParser.cpp
149                 MagnetURI.cpp
150                 MuleCollection.cpp
151         )
153         if (WIN32)
154                 target_sources (ed2k
155                         PRIVATE ${CMAKE_SOURCE_DIR}/version.rc
156                 )
157         endif()
159         target_compile_definitions (ed2k
160                 PRIVATE "USE_STD_STRING"
161         )
163         if (WIN32)
164                 target_link_libraries (ed2k
165                         shlwapi.lib
166                 )
167         endif()
169         install (TARGETS ed2k
170                 RUNTIME DESTINATION bin
171         )
172 endif()
174 if (BUILD_MONOLITHIC)
175         add_executable (amule
176                 ${COMMON_SOURCES}
177                 ${CORE_SOURCES}
178                 ${GUI_SOURCES}
179                 CaptchaDialog.cpp
180                 CaptchaGenerator.cpp
181                 PartFileConvert.cpp
182                 PartFileConvertDlg.cpp
183         )
185         if (WIN32)
186                 target_sources (amule
187                         PRIVATE ${CMAKE_SOURCE_DIR}/version.rc
188                 )
189         endif()
191         target_link_libraries (amule
192                 ec
193                 muleappcommon
194                 muleappcore
195                 muleappgui
196                 mulecommon
197                 mulesocket
198                 $<$<VERSION_LESS:${wxWidgets_VERSION_STRING},3.1.2>:wxWidgets::ADV>
199                 wxWidgets::NET
200         )
202         if (HAVE_BFD)
203                 target_link_libraries (amule ${LIBBFD})
204         endif()
206         if (WIN32)
207                 target_link_libraries (amule
208                         shlwapi.lib
209                 )
211                 set_target_properties (amule
212                         PROPERTIES WIN32_EXECUTABLE TRUE
213                 )
214         endif()
216         install (TARGETS amule
217                 RUNTIME DESTINATION bin
218         )
219 endif (BUILD_MONOLITHIC)
221 if (BUILD_REMOTEGUI)
222         add_executable (amulegui
223                 ${COMMON_SOURCES}
224                 ${GUI_SOURCES}
225                 kademlia/utils/UInt128.cpp
226                 amule-remote-gui.cpp
227         )
229         if (WIN32)
230                 target_sources (amulegui
231                         PRIVATE ${CMAKE_SOURCE_DIR}/version.rc
232                 )
233         endif()
235         target_compile_definitions (amulegui
236                 PRIVATE "CLIENT_GUI"
237         )
239         target_include_directories (amulegui
240                 PRIVATE ${SRC_DIR}
241         )
243         target_link_libraries (amulegui
244                 ec
245                 muleappcommon
246                 muleappgui
247                 mulecommon
248                 mulesocket
249                 $<$<VERSION_LESS:${wxWidgets_VERSION_STRING},3.1.2>:wxWidgets::ADV>
250                 wxWidgets::NET
251         )
253         if (HAVE_BFD)
254                 target_link_libraries (amulegui
255                         ${LIBBFD}
256                 )
257         endif()
259         if (WIN32)
260                 set_target_properties (amulegui
261                         PROPERTIES WIN32_EXECUTABLE TRUE
262                 )
263         endif()
265         install (TARGETS amulegui
266                 RUNTIME DESTINATION bin
267         )
268 endif()
270 if (NEED_LIB_MULEAPPCOMMON)
271         add_library (muleappcommon STATIC
272                 ${UPNP_SOURCES}
273                 CFile.cpp
274                 ClientCredits.cpp
275                 DataToText.cpp
276                 ED2KLink.cpp
277                 Friend.cpp
278                 GapList.cpp
279                 MagnetURI.cpp
280                 MemFile.cpp
281                 NetworkFunctions.cpp
282                 OtherFunctions.cpp
283                 Packet.cpp
284                 RLE.cpp
285                 SafeFile.cpp
286                 SHA.cpp
287                 Tag.cpp
288                 TerminationProcess.cpp
289                 Timer.cpp
290         )
292         target_compile_definitions (muleappcommon
293                 PRIVATE wxUSE_GUI=0
294                 PRIVATE WXUSINGDLL
295         )
297         target_include_directories (muleappcommon
298                 PUBLIC ${amule_BINARY_DIR}
299                 PUBLIC ${EC_INCLUDE_DIR}
300                 PRIVATE ${INCLUDE_INCLUDE_DIR}
301                 PRIVATE ${LIBS_INCLUDE_DIR}
302                 PRIVATE ${wxWidgets_INCLUDE_DIRS}
303                 PRIVATE ${ZLIB_INCLUDE_DIR}
304         )
306         add_dependencies (muleappcommon
307                 generate_ECCodes.h
308                 generate_ECTagTypes.h
309         )
311         if (ENABLE_UPNP)
312                 target_link_libraries (muleappcommon
313                         PUBLIC UPNP::Shared
314                 )
315         endif()
316 endif()
318 if (NEED_LIB_MULEAPPCORE)
319         if (BISON_FOUND)
320                 bison_target (Parser.cpp
321                         ${CMAKE_CURRENT_SOURCE_DIR}/Parser.y
322                         ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp
323                         COMPILE_FLAGS "-t -d -v"
324                 )
326                 set (PARSER ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp)
327         else()
328                 set (PARSER ${CMAKE_CURRENT_SOURCE_DIR}/Parser.cpp)
329         endif (BISON_FOUND)
331         if (FLEX_FOUND)
332                 if (FLEX_MATCH)
333                         set (FLEX_FLAGS "--header-file=${CMAKE_CURRENT_BINARY_DIR}/Scanner.h")
335                         set_source_files_properties (Parser.cpp
336                                 COMPILE_FLAGS "-I${CMAKE_CURRENT_BINARY_DIR}"
337                         )
338                 endif()
340                 flex_target (Scanner.cpp
341                         ${CMAKE_CURRENT_SOURCE_DIR}/Scanner.l
342                         ${CMAKE_CURRENT_BINARY_DIR}/Scanner.cpp
343                         COMPILE_FLAGS "${FLEX_FLAGS}"
344                 )
346                 flex_target (IPFilterScanner.cpp
347                         ${CMAKE_CURRENT_SOURCE_DIR}/IPFilterScanner.l
348                         ${CMAKE_CURRENT_BINARY_DIR}/IPFilterScanner.cpp
349                         COMPILE_FLAGS "-Pyyip"
350                 )
352                 set (SCANNER ${CMAKE_CURRENT_BINARY_DIR}/Scanner.cpp)
353                 set (IPFILTERSCANNER ${CMAKE_CURRENT_BINARY_DIR}/IPFilterScanner.cpp)
354         else()
355                 set (SCANNER ${CMAKE_CURRENT_SOURCE_DIR}/Scanner.cpp)
356                 set (IPFILTERSCANNER ${CMAKE_CURRENT_SOURCE_DIR}/IPFilterScanner.cpp)
357         endif()
359         add_library (muleappcore STATIC
360                 ${IPFILTERSCANNER}
361                 ${PARSER}
362                 ${SCANNER}
363                 kademlia/kademlia/Entry.cpp
364                 kademlia/kademlia/Indexed.cpp
365                 kademlia/kademlia/SearchManager.cpp
366                 kademlia/routing/RoutingBin.cpp
367                 kademlia/utils/UInt128.cpp
368                 AsyncDNS.cpp
369                 CanceledFileList.cpp
370                 DeadSourceList.cpp
371                 FileArea.cpp
372                 FileAutoClose.cpp
373                 PlatformSpecific.cpp
374                 RandomFunctions.cpp
375                 RC4Encrypt.cpp
376                 StateMachine.cpp
377                 TerminationProcessAmuleweb.cpp
378                 ThreadScheduler.cpp
379                 UPnPBase.cpp
380         )
382         target_compile_definitions (muleappcore
383                 PRIVATE wxUSE_GUI=0
384                 PRIVATE WXUSINGDLL
385         )
387         target_include_directories (muleappcore
388                 PRIVATE ${CMAKE_BINARY_DIR}
389                 PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
390                 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
391                 PRIVATE ${INCLUDE_INCLUDE_DIR}
392                 PRIVATE ${LIBS_INCLUDE_DIR}
393                 PRIVATE ${wxWidgets_INCLUDE_DIRS}
394         )
396         if (ENABLE_UPNP)
397                 target_include_directories (muleappcore
398                         PRIVATE $<TARGET_PROPERTY:UPNP::Shared,INTERFACE_INCLUDE_DIRECTORIES>
399                 )
400         endif()
402         target_link_libraries (muleappcore
403                 CRYPTOPP::CRYPTOPP
404         )
405 endif()
407 if (NEED_LIB_MULEAPPGUI)
408         add_library (muleappgui STATIC
409                 ${IP2COUNTRY}
410                 extern/wxWidgets/listctrl.cpp
411                 BarShader.cpp
412                 ColorFrameCtrl.cpp
413                 EditServerListDlg.cpp
414                 FileDetailListCtrl.cpp
415                 MuleCollection.cpp
416                 MuleColour.cpp
417                 MuleGifCtrl.cpp
418                 MuleListCtrl.cpp
419                 MuleNotebook.cpp
420                 MuleTextCtrl.cpp
421                 muuli_wdr.cpp
422         )
424         if (ENABLE_IP2COUNTRY)
425                 target_link_libraries (muleappgui
426                         PUBLIC GeoIP::Shared
427                 )
428         endif()
430         target_compile_definitions (muleappgui
431                 PRIVATE WXUSINGDLL
432         )
434         target_include_directories (muleappgui
435                 PRIVATE ${amule_BINARY_DIR}
436                 PRIVATE ${INCLUDE_INCLUDE_DIR}
437                 PRIVATE ${LIBS_INCLUDE_DIR}
438         )
440         target_link_libraries (muleappgui
441                 PRIVATE wxWidgets::CORE
442         )
444         if (ENABLE_IP2COUNTRY)
445                 add_dependencies (muleappgui
446                         generate_CountryFlags.h)
447         endif()
448 endif()
450 IF (NEED_LIB_MULESOCKET)
451         add_library (mulesocket STATIC
452                 LibSocket.cpp
453         )
455         target_compile_definitions (mulesocket
456                 PRIVATE wxUSE_GUI=0
457         )
458         
459         target_include_directories (mulesocket
460                 PRIVATE ${amule_BINARY_DIR}
461                 PUBLIC ${INCLUDE_INCLUDE_DIR}
462                 PUBLIC ${LIBS_INCLUDE_DIR}
463         )
465         if (ENABLE_BOOST)
466                 target_include_directories (mulesocket
467                         PRIVATE ${Boost_INCLUDE_DIR}
468                         PRIVATE ${wxWidgets_INCLUDE_DIRS}
469                 )
471                 target_link_libraries (mulesocket
472                         ${Boost_LIBRARIES}
473                         wxWidgets::BASE
474                 )
475         else()
476                 target_link_libraries (mulesocket
477                         wxWidgets::NET
478                 )
479         endif()
480 endif()