Rewrite client media download and support hash-based remote download
[oweals/minetest.git] / src / CMakeLists.txt
1 project(minetest)
2 cmake_minimum_required( VERSION 2.6 )
3
4 # Set some random things default to not being visible in the GUI
5 mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
6 mark_as_advanced(SQLITE3_INCLUDE_DIR SQLITE3_LIBRARY)
7 mark_as_advanced(JSON_INCLUDE_DIR JSON_LIBRARY)
8
9 option(ENABLE_CURL "Enable cURL support for fetching media" 1)
10
11 if (NOT ENABLE_CURL)
12         mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR)
13 endif(NOT ENABLE_CURL)
14
15 if( ENABLE_CURL )
16         find_package(CURL)
17 endif( ENABLE_CURL )
18 set(USE_CURL 0)
19 if (CURL_FOUND AND ENABLE_CURL)
20         message(STATUS "cURL support enabled")
21         set(USE_CURL 1)
22 endif(CURL_FOUND AND ENABLE_CURL)
23
24 # user-visible option to enable/disable gettext usage
25 OPTION(ENABLE_GETTEXT "Use GetText for internationalization" 0)
26
27 # this is only set to 1 if gettext is enabled _and_ available
28 set(USE_GETTEXT 0)
29
30 if(ENABLE_GETTEXT)
31         find_package(GettextLib)
32 else()
33         MARK_AS_ADVANCED(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT)
34 endif()
35
36 if(GETTEXT_FOUND AND ENABLE_GETTEXT)
37         message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}")
38         message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}")
39         if(WIN32)
40                 message(STATUS "gettext library: ${GETTEXT_LIBRARY}")
41                 message(STATUS "gettext dll: ${GETTEXT_DLL}")
42                 message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}")
43         endif()
44         set(USE_GETTEXT 1)
45         message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}")
46 elseif(GETTEXT_FOUND AND NOT ENABLE_GETTEXT)
47         MESSAGE(STATUS "GetText found but disabled;")
48 else(GETTEXT_FOUND AND ENABLE_GETTEXT)
49         message(STATUS "GetText disabled")
50 endif(GETTEXT_FOUND AND ENABLE_GETTEXT)
51
52 # user visible option to enable/disable sound
53 OPTION(ENABLE_SOUND "Enable sound" ON)
54
55 # this is only set to 1 if sound is enabled _and_ available
56 set(USE_SOUND 0)
57 set(SOUND_PROBLEM 0)
58
59 if(ENABLE_SOUND AND BUILD_CLIENT)
60         # Sound libraries
61         find_package(OpenAL)
62         find_package(Vorbis)
63         if(NOT OPENAL_FOUND)
64                 message(STATUS "Sound enabled, but OpenAL not found!")
65                 set(SOUND_PROBLEM 1)
66                 MARK_AS_ADVANCED(CLEAR OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
67         endif()
68         if(NOT VORBIS_FOUND)
69                 message(STATUS "Sound enabled, but Vorbis libraries not found!")
70                 set(SOUND_PROBLEM 1)
71                 MARK_AS_ADVANCED(CLEAR OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY)
72         endif()
73         if(OPENAL_FOUND AND VORBIS_FOUND)
74                 set(USE_SOUND 1)
75                 message(STATUS "Sound enabled")
76         endif()
77 endif(ENABLE_SOUND AND BUILD_CLIENT)
78
79 if(SOUND_PROBLEM)
80         message(FATAL_ERROR "Sound enabled, but cannot be used.\n"
81                 "To continue, either fill in the required paths or disable sound. (-DENABLE_SOUND=0)")
82 endif()
83 if(USE_SOUND)
84         set(sound_SRCS sound_openal.cpp)
85         set(SOUND_INCLUDE_DIRS
86                 ${OPENAL_INCLUDE_DIR}
87                 ${VORBIS_INCLUDE_DIR}
88                 ${OGG_INCLUDE_DIR}
89                 )
90         set(SOUND_LIBRARIES
91                 ${OPENAL_LIBRARY}
92                 ${VORBIS_LIBRARIES}
93                 )
94 endif()
95
96 option(ENABLE_FREETYPE "Enable freetype2 (truetype fonts and basic unicode support)" OFF)
97 set(USE_FREETYPE 0)
98 if(ENABLE_FREETYPE)
99         set(USE_FREETYPE 1)
100 endif(ENABLE_FREETYPE)
101
102 if(NOT MSVC)
103         set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++")
104 endif()
105
106 # Use cmake_config.h
107 add_definitions ( -DUSE_CMAKE_CONFIG_H )
108
109 if(WIN32)
110         # Windows
111         if(MSVC) # MSVC Specifics
112                 # Surpress some useless warnings
113                 add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
114         else() # Probably MinGW = GCC
115                 set(PLATFORM_LIBS ws2_32.lib)
116         endif()
117         # Zlib stuff
118         set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
119                         CACHE PATH "Zlib include directory")
120         set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib"
121                         CACHE FILEPATH "Path to zlibwapi.lib")
122         set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll"
123                         CACHE FILEPATH "Path to zlibwapi.dll (for installation)")
124         set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2"
125                         CACHE PATH "irrlicht dir")
126         if(USE_FREETYPE)
127                 set(FREETYPE_INCLUDE_DIR_ft2build "${PROJECT_SOURCE_DIR}/../../freetype2/include/"
128                                 CACHE PATH "freetype include dir")
129                 set(FREETYPE_INCLUDE_DIR_freetype2 "${PROJECT_SOURCE_DIR}/../../freetype2/include/freetype"
130                                 CACHE PATH "freetype include dir")
131                 set(FREETYPE_LIBRARY "${PROJECT_SOURCE_DIR}/../../freetype2/objs/win32/vc2005/freetype247.lib"
132                                 CACHE FILEPATH "Path to freetype247.lib")
133         endif(USE_FREETYPE)
134         set(MINGWM10_DLL ""
135                         CACHE FILEPATH "Path to mingwm10.dll (for installation)")
136         if(ENABLE_SOUND)
137                 set(OPENAL_DLL "" CACHE FILEPATH "Path to OpenAL32.dll for installation (optional)")
138                 set(OGG_DLL "" CACHE FILEPATH "Path to libogg.dll for installation (optional)")
139                 set(VORBIS_DLL "" CACHE FILEPATH "Path to libvorbis.dll for installation (optional)")
140                 set(VORBISFILE_DLL "" CACHE FILEPATH "Path to libvorbisfile.dll for installation (optional)")
141         endif()
142 else()
143         # Unix probably
144         if(BUILD_CLIENT)
145                 find_package(X11 REQUIRED)
146                 find_package(OpenGL REQUIRED)
147                 find_package(JPEG REQUIRED)
148                 find_package(BZip2 REQUIRED)
149                 find_package(PNG REQUIRED)
150                 if(APPLE)
151                         FIND_LIBRARY(CARBON_LIB Carbon)
152                         FIND_LIBRARY(COCOA_LIB Cocoa)
153                         FIND_LIBRARY(IOKIT_LIB IOKit)
154                         mark_as_advanced(
155                                 CARBON_LIB
156                                 COCOA_LIB
157                                 IOKIT_LIB
158                         )
159                         SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB})
160                 endif(APPLE)
161         endif(BUILD_CLIENT)
162         find_package(ZLIB REQUIRED)
163         set(PLATFORM_LIBS -lpthread -lrt ${CMAKE_DL_LIBS})
164         #set(CLIENT_PLATFORM_LIBS -lXxf86vm)
165         # This way Xxf86vm is found on OpenBSD too
166         find_library(XXF86VM_LIBRARY Xxf86vm)
167         mark_as_advanced(XXF86VM_LIBRARY)
168         set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
169 endif()
170
171 find_package(Sqlite3 REQUIRED)
172 find_package(Json REQUIRED)
173 find_package(OpenGLES2)
174
175 if(USE_FREETYPE)
176         find_package(Freetype REQUIRED)
177         set(CGUITTFONT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cguittfont")
178         set(CGUITTFONT_LIBRARY cguittfont)
179 endif(USE_FREETYPE)
180
181
182 find_library(LUA_LIBRARY luajit
183                 NAMES luajit-5.1)
184 find_path(LUA_INCLUDE_DIR luajit.h
185         NAMES luajit.h
186         PATH_SUFFIXES luajit-2.0)
187 message (STATUS "LuaJIT library: ${LUA_LIBRARY}")
188 message (STATUS "LuaJIT headers: ${LUA_INCLUDE_DIR}")
189
190 set(USE_LUAJIT 0)
191 if(LUA_LIBRARY AND LUA_INCLUDE_DIR)
192         message (STATUS "LuaJIT found.")
193         set(USE_LUAJIT 1)
194 else(LUA_LIBRARY AND LUA_INCLUDE_DIR)
195         message (STATUS "LuaJIT not found, using bundled Lua.")
196         set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src")
197         set(LUA_LIBRARY "lua")
198         add_subdirectory(lua)
199 endif(LUA_LIBRARY AND LUA_INCLUDE_DIR)
200
201 mark_as_advanced(LUA_LIBRARY)
202 mark_as_advanced(LUA_INCLUDE_DIR)
203
204 set(USE_LEVELDB 0)
205
206 OPTION(ENABLE_LEVELDB "Enable LevelDB backend")
207
208 if(ENABLE_LEVELDB)
209         find_library(LEVELDB_LIBRARY leveldb)
210         find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb)
211         message (STATUS "LevelDB library: ${LEVELDB_LIBRARY}")
212         message (STATUS "LevelDB headers: ${LEVELDB_INCLUDE_DIR}")
213         if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
214                 set(USE_LEVELDB 1)
215                 message(STATUS "LevelDB backend enabled")
216                 include_directories(${LEVELDB_INCLUDE_DIR})
217         else(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
218                 set(USE_LEVELDB 0)
219                 message(STATUS "LevelDB not found!")
220         endif(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
221 endif(ENABLE_LEVELDB)
222
223 configure_file(
224         "${PROJECT_SOURCE_DIR}/cmake_config.h.in"
225         "${PROJECT_BINARY_DIR}/cmake_config.h"
226 )
227
228 # Add a target that always rebuilds cmake_config_githash.h
229 add_custom_target(GenerateVersion
230         COMMAND ${CMAKE_COMMAND}
231         -D "GENERATE_VERSION_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
232         -D "GENERATE_VERSION_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
233         -D "VERSION_STRING=${VERSION_STRING}"
234         -D "VERSION_EXTRA=${VERSION_EXTRA}"
235         -P "${CMAKE_SOURCE_DIR}/cmake/Modules/GenerateVersion.cmake"
236         WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
237
238 add_subdirectory(jthread)
239 add_subdirectory(script)
240 add_subdirectory(util)
241
242 set(common_SRCS
243         version.cpp
244         rollback_interface.cpp
245         rollback.cpp
246         genericobject.cpp
247         voxelalgorithms.cpp
248         sound.cpp
249         quicktune.cpp
250         subgame.cpp
251         inventorymanager.cpp
252         mods.cpp
253         content_abm.cpp
254         craftdef.cpp
255         nameidmapping.cpp
256         itemdef.cpp
257         nodedef.cpp
258         object_properties.cpp
259         log.cpp
260         content_sao.cpp
261         emerge.cpp
262         mapgen.cpp
263         mapgen_v6.cpp
264         mapgen_v7.cpp
265         mapgen_indev.cpp
266         mapgen_singlenode.cpp
267         mapgen_math.cpp
268         treegen.cpp
269         dungeongen.cpp
270         cavegen.cpp
271         content_nodemeta.cpp
272         content_mapnode.cpp
273         collision.cpp
274         nodemetadata.cpp
275         nodetimer.cpp
276         serverobject.cpp
277         noise.cpp
278         porting.cpp
279         tool.cpp
280         defaultsettings.cpp
281         mapnode.cpp
282         voxel.cpp
283         inventory.cpp
284         debug.cpp
285         serialization.cpp
286         light.cpp
287         filesys.cpp
288         connection.cpp
289         environment.cpp
290         server.cpp
291         socket.cpp
292         mapblock.cpp
293         mapsector.cpp
294         map.cpp
295         database.cpp
296         database-dummy.cpp
297         database-leveldb.cpp
298         database-sqlite3.cpp
299         player.cpp
300         test.cpp
301         sha1.cpp
302         base64.cpp
303         ban.cpp
304         biome.cpp
305         staticobject.cpp
306         serverlist.cpp
307         pathfinder.cpp
308         convert_json.cpp
309         gettext.cpp
310         httpfetch.cpp
311         ${JTHREAD_SRCS}
312         ${common_SCRIPT_SRCS}
313         ${UTIL_SRCS}
314 )
315
316 # This gives us the icon
317 if(WIN32)
318         set(WINRESOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../misc/winresource.rc)
319         if(MINGW)
320                 if(NOT CMAKE_RC_COMPILER)
321                         set(CMAKE_RC_COMPILER "windres.exe")
322                 endif()
323                 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o
324                         COMMAND ${CMAKE_RC_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR}
325                         -i${WINRESOURCE_FILE}
326                         -o ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o
327                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
328                 SET(common_SRCS ${common_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o)
329         else(MINGW) # Probably MSVC
330                 set(common_SRCS ${common_SRCS} ${WINRESOURCE_FILE})
331         endif(MINGW)
332 endif()
333
334 # Client sources
335 set(minetest_SRCS
336         ${common_SRCS}
337         ${sound_SRCS}
338         localplayer.cpp
339         sky.cpp
340         clientmap.cpp
341         content_cso.cpp
342         content_mapblock.cpp
343         content_cao.cpp
344         mesh.cpp
345         mapblock_mesh.cpp
346         keycode.cpp
347         camera.cpp
348         clouds.cpp
349         particles.cpp
350         clientobject.cpp
351         chat.cpp
352         hud.cpp
353         guiKeyChangeMenu.cpp
354         guiMessageMenu.cpp
355         guiTextInputMenu.cpp
356         guiFormSpecMenu.cpp
357         guiPauseMenu.cpp
358         guiPasswordChange.cpp
359         guiVolumeChange.cpp
360         guiDeathScreen.cpp
361         guiChatConsole.cpp
362         client.cpp
363         clientmedia.cpp
364         filecache.cpp
365         tile.cpp
366         shader.cpp
367         game.cpp
368         main.cpp
369         guiEngine.cpp
370         guiFileSelectMenu.cpp
371         convert_json.cpp
372         ${minetest_SCRIPT_SRCS}
373 )
374
375 if(USE_FREETYPE)
376         set(minetest_SRCS
377                 ${minetest_SRCS}
378                 intlGUIEditBox.cpp
379         )
380 endif(USE_FREETYPE)
381
382 list(SORT minetest_SRCS)
383
384 # Server sources
385 set(minetestserver_SRCS
386         ${common_SRCS}
387         main.cpp
388 )
389 list(SORT minetestserver_SRCS)
390
391 include_directories(
392         ${PROJECT_BINARY_DIR}
393         ${PROJECT_SOURCE_DIR}
394         ${IRRLICHT_INCLUDE_DIR}
395         ${ZLIB_INCLUDE_DIR}
396         ${CMAKE_BUILD_TYPE}
397         ${PNG_INCLUDE_DIR}
398         ${GETTEXT_INCLUDE_DIR}
399         ${SOUND_INCLUDE_DIRS}
400         ${SQLITE3_INCLUDE_DIR}
401         ${LUA_INCLUDE_DIR}
402         ${JSON_INCLUDE_DIR}
403         ${PROJECT_SOURCE_DIR}/script
404 )
405
406 if(USE_FREETYPE)
407         include_directories(
408                 ${FREETYPE_INCLUDE_DIRS}
409                 ${CGUITTFONT_INCLUDE_DIR}
410         )
411 endif(USE_FREETYPE)
412
413 if(USE_CURL)
414         include_directories(
415                 ${CURL_INCLUDE_DIR}
416         )
417 endif(USE_CURL)
418
419 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
420
421 if(BUILD_CLIENT)
422         add_executable(${PROJECT_NAME} ${minetest_SRCS})
423         add_dependencies(${PROJECT_NAME} GenerateVersion)
424         target_link_libraries(
425                 ${PROJECT_NAME}
426                 ${ZLIB_LIBRARIES}
427                 ${IRRLICHT_LIBRARY}
428                 ${OPENGL_LIBRARIES}
429                 ${JPEG_LIBRARIES}
430                 ${BZIP2_LIBRARIES}
431                 ${PNG_LIBRARIES}
432                 ${X11_LIBRARIES}
433                 ${GETTEXT_LIBRARY}
434                 ${SOUND_LIBRARIES}
435                 ${SQLITE3_LIBRARY}
436                 ${LUA_LIBRARY}
437                 ${JSON_LIBRARY}
438                 ${OPENGLES2_LIBRARIES}
439                 ${PLATFORM_LIBS}
440                 ${CLIENT_PLATFORM_LIBS}
441         )
442         if(USE_CURL)
443                 target_link_libraries(
444                         ${PROJECT_NAME}
445                         ${CURL_LIBRARY}
446                 )
447         endif(USE_CURL)
448         if(USE_FREETYPE)
449                 target_link_libraries(
450                         ${PROJECT_NAME}
451                         ${FREETYPE_LIBRARY}
452                         ${CGUITTFONT_LIBRARY}
453                 )
454         endif(USE_FREETYPE)
455         if (USE_LEVELDB)
456                 target_link_libraries(${PROJECT_NAME} ${LEVELDB_LIBRARY})
457         endif(USE_LEVELDB)
458 endif(BUILD_CLIENT)
459
460 if(BUILD_SERVER)
461         add_executable(${PROJECT_NAME}server ${minetestserver_SRCS})
462         add_dependencies(${PROJECT_NAME}server GenerateVersion)
463         target_link_libraries(
464                 ${PROJECT_NAME}server
465                 ${ZLIB_LIBRARIES}
466                 ${SQLITE3_LIBRARY}
467                 ${JSON_LIBRARY}
468                 ${GETTEXT_LIBRARY}
469                 ${LUA_LIBRARY}
470                 ${PLATFORM_LIBS}
471         )
472         if (USE_LEVELDB)
473                 target_link_libraries(${PROJECT_NAME}server ${LEVELDB_LIBRARY})
474         endif(USE_LEVELDB)
475         if(USE_CURL)
476                 target_link_libraries(
477                         ${PROJECT_NAME}server
478                         ${CURL_LIBRARY}
479                 )
480         endif(USE_CURL)
481 endif(BUILD_SERVER)
482
483
484 #
485 # Set some optimizations and tweaks
486 #
487
488 include(CheckCXXCompilerFlag)
489
490 if(MSVC)
491         # Visual Studio
492
493         # EHa enables SEH exceptions (used for catching segfaults)
494         set(CMAKE_CXX_FLAGS_RELEASE "/EHa /O2 /Ob2 /Oi /Ot /Oy /GL /FD /MT /GS- /arch:SSE /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP")
495         #set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
496         set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
497
498         # Debug build doesn't catch exceptions by itself
499         # Add some optimizations because otherwise it's VERY slow
500         set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1")
501
502         # Flags for C files (sqlite)
503         # /MT = Link statically with standard library stuff
504         set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT")
505
506         if(BUILD_SERVER)
507                 set_target_properties(${PROJECT_NAME}server PROPERTIES
508                                 COMPILE_DEFINITIONS "SERVER")
509         endif(BUILD_SERVER)
510
511 else()
512         # Probably GCC
513
514         if(WARN_ALL)
515                 set(RELEASE_WARNING_FLAGS "-Wall")
516         else()
517                 set(RELEASE_WARNING_FLAGS "")
518         endif()
519
520         if(NOT APPLE AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
521                 CHECK_CXX_COMPILER_FLAG("-Wno-unused-but-set-variable" HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
522                 if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
523                         set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
524                 endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
525         endif()
526
527         if(MINGW)
528                 set(OTHER_FLAGS "-mthreads -fexceptions")
529         endif()
530
531         if(APPLE)
532                 set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING "do not build for 64-bit" FORCE)
533                 set(ARCH i386)
534         endif()
535
536         set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops")
537         set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}")
538
539         if(USE_GPROF)
540                 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
541         endif()
542
543         if(BUILD_SERVER)
544                 set_target_properties(${PROJECT_NAME}server PROPERTIES
545                                 COMPILE_DEFINITIONS "SERVER")
546         endif(BUILD_SERVER)
547
548 endif()
549
550 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}")
551 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}")
552
553 #
554 # Installation
555 #
556 if(WIN32)
557         if(MINGWM10_DLL)
558                 install(FILES ${MINGWM10_DLL} DESTINATION ${BINDIR})
559         endif()
560         if(DEFINED ZLIB_DLL)
561                 install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
562         endif()
563         if(USE_SOUND)
564                 if(OPENAL_DLL)
565                         install(FILES ${OPENAL_DLL} DESTINATION ${BINDIR})
566                 endif()
567                 if(OGG_DLL)
568                         install(FILES ${OGG_DLL} DESTINATION ${BINDIR})
569                 endif()
570                 if(VORBIS_DLL)
571                         install(FILES ${VORBIS_DLL} DESTINATION ${BINDIR})
572                 endif()
573                 if(VORBISFILE_DLL)
574                         install(FILES ${VORBISFILE_DLL} DESTINATION ${BINDIR})
575                 endif()
576                 if(CURL_DLL)
577                         install(FILES ${CURL_DLL} DESTINATION ${BINDIR})
578                 endif()
579         endif()
580 endif()
581
582 if(BUILD_CLIENT)
583         install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
584
585         if(USE_GETTEXT)
586                 foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
587                         set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
588                         set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
589                         install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH})
590                 endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
591         endif()
592
593         if(WIN32)
594                 if(DEFINED IRRLICHT_DLL)
595                         install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
596                 endif()
597                 if(USE_GETTEXT)
598                         if(DEFINED GETTEXT_DLL)
599                                 install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR})
600                         endif()
601                         if(DEFINED GETTEXT_ICONV_DLL)
602                                 install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR})
603                         endif()
604                 endif(USE_GETTEXT)
605         endif()
606 endif(BUILD_CLIENT)
607
608 if(BUILD_SERVER)
609         install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR})
610 endif(BUILD_SERVER)
611
612 if (USE_GETTEXT)
613         set(MO_FILES)
614
615         foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
616                 set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po")
617                 set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
618                 set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
619
620                 add_custom_command(OUTPUT ${MO_BUILD_PATH}
621                         COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH}
622                         COMMENT "mo-update [${LOCALE}]: Creating locale directory.")
623
624                 add_custom_command(
625                         OUTPUT ${MO_FILE_PATH}
626                         COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH}
627                         DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH}
628                         WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}"
629                         COMMENT "mo-update [${LOCALE}]: Creating mo file."
630                         )
631
632                 set(MO_FILES ${MO_FILES} ${MO_FILE_PATH})
633         endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
634
635         add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES})
636 endif(USE_GETTEXT)
637
638 # Subdirectories
639
640 if (SQLITE3_FOUND)
641 else (SQLITE3_FOUND)
642         add_subdirectory(sqlite)
643 endif (SQLITE3_FOUND)
644
645 if (BUILD_CLIENT AND USE_FREETYPE)
646         add_subdirectory(cguittfont)
647 endif (BUILD_CLIENT AND USE_FREETYPE)
648
649 if (JSON_FOUND)
650 else (JSON_FOUND)
651         add_subdirectory(json)
652 endif (JSON_FOUND)
653
654 #end