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