Re-add jungles, apple trees
[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 ${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
176 if(USE_FREETYPE)
177         find_package(Freetype REQUIRED)
178         set(CGUITTFONT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cguittfont")
179         set(CGUITTFONT_LIBRARY cguittfont)
180 endif(USE_FREETYPE)
181
182 # Do not use system-wide installation of Lua, because it'll likely be a
183 # different version and/or has different build options.
184 set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src")
185 set(LUA_LIBRARY "lua")
186
187 configure_file(
188         "${PROJECT_SOURCE_DIR}/cmake_config.h.in"
189         "${PROJECT_BINARY_DIR}/cmake_config.h"
190 )
191
192 set(common_SRCS
193         rollback_interface.cpp
194         rollback.cpp
195         genericobject.cpp
196         voxelalgorithms.cpp
197         sound.cpp
198         quicktune.cpp
199         subgame.cpp
200         inventorymanager.cpp
201         mods.cpp
202         content_abm.cpp
203         craftdef.cpp
204         nameidmapping.cpp
205         itemdef.cpp
206         nodedef.cpp
207         object_properties.cpp
208         scriptapi_types.cpp
209         scriptapi_common.cpp
210         scriptapi_content.cpp
211         scriptapi_craft.cpp
212         scriptapi_node.cpp
213         scriptapi_item.cpp
214         scriptapi_env.cpp
215         scriptapi_nodetimer.cpp
216         scriptapi_noise.cpp
217         scriptapi_entity.cpp
218         scriptapi_object.cpp
219         scriptapi_nodemeta.cpp
220         scriptapi_inventory.cpp
221         scriptapi.cpp
222         script.cpp
223         log.cpp
224         content_sao.cpp
225         emerge.cpp
226         mapgen.cpp
227         mapgen_v6.cpp
228         treegen.cpp
229         dungeongen.cpp
230         content_nodemeta.cpp
231         content_mapnode.cpp
232         collision.cpp
233         nodemetadata.cpp
234         nodetimer.cpp
235         serverobject.cpp
236         noise.cpp
237         porting.cpp
238         tool.cpp
239         defaultsettings.cpp
240         mapnode.cpp
241         voxel.cpp
242         inventory.cpp
243         debug.cpp
244         serialization.cpp
245         light.cpp
246         filesys.cpp
247         connection.cpp
248         environment.cpp
249         server.cpp
250         socket.cpp
251         mapblock.cpp
252         mapsector.cpp
253         map.cpp
254         player.cpp
255         test.cpp
256         sha1.cpp
257         base64.cpp
258         ban.cpp
259         biome.cpp
260         clientserver.cpp
261         staticobject.cpp
262         serverlist.cpp
263         util/serialize.cpp
264         util/directiontables.cpp
265         util/numeric.cpp
266         util/pointedthing.cpp
267         util/string.cpp
268         util/timetaker.cpp
269 )
270
271 # This gives us the icon
272 if(WIN32)
273         set(WINRESOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../misc/winresource.rc)
274         if(MINGW)
275                 if(NOT CMAKE_RC_COMPILER)
276                         set(CMAKE_RC_COMPILER "windres.exe")
277                 endif()
278                 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o
279                         COMMAND ${CMAKE_RC_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR}
280                         -i${WINRESOURCE_FILE}
281                         -o ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o
282                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
283                 SET(common_SRCS ${common_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o)
284         else(MINGW) # Probably MSVC
285                 set(common_SRCS ${common_SRCS} ${WINRESOURCE_FILE})
286         endif(MINGW)
287 endif()
288
289 # Client sources
290 set(minetest_SRCS
291         ${common_SRCS}
292         ${sound_SRCS}
293         localplayer.cpp
294         sky.cpp
295         clientmap.cpp
296         content_cso.cpp
297         content_mapblock.cpp
298         content_cao.cpp
299         mesh.cpp
300         mapblock_mesh.cpp
301         farmesh.cpp
302         keycode.cpp
303         camera.cpp
304         clouds.cpp
305         particles.cpp
306         clientobject.cpp
307         chat.cpp
308         guiMainMenu.cpp
309         guiKeyChangeMenu.cpp
310         guiMessageMenu.cpp
311         guiTextInputMenu.cpp
312         guiFormSpecMenu.cpp
313         guiPauseMenu.cpp
314         guiPasswordChange.cpp
315         guiVolumeChange.cpp
316         guiDeathScreen.cpp
317         guiChatConsole.cpp
318         guiCreateWorld.cpp
319         guiConfigureWorld.cpp
320         guiConfirmMenu.cpp
321         client.cpp
322         filecache.cpp
323         tile.cpp
324         shader.cpp
325         game.cpp
326         main.cpp
327 )
328
329 if(USE_FREETYPE)
330         set(minetest_SRCS
331                 ${minetest_SRCS}
332                 intlGUIEditBox.cpp
333         )
334 endif(USE_FREETYPE)
335
336 # Server sources
337 set(minetestserver_SRCS
338         ${common_SRCS}
339         main.cpp
340 )
341
342 include_directories(
343         ${PROJECT_BINARY_DIR}
344         ${IRRLICHT_INCLUDE_DIR}
345         ${ZLIB_INCLUDE_DIR}
346         ${CMAKE_BUILD_TYPE}
347         ${PNG_INCLUDE_DIR}
348         ${GETTEXT_INCLUDE_DIR}
349         ${SOUND_INCLUDE_DIRS}
350         ${JTHREAD_INCLUDE_DIR}
351         ${SQLITE3_INCLUDE_DIR}
352         ${LUA_INCLUDE_DIR}
353         ${JSON_INCLUDE_DIR}
354 )
355
356 if(USE_FREETYPE)
357         include_directories(
358                 ${FREETYPE_INCLUDE_DIRS}
359                 ${CGUITTFONT_INCLUDE_DIR}
360         )
361 endif(USE_FREETYPE)
362
363 if(USE_CURL)
364         include_directories(
365                 ${CURL_INCLUDE_DIR}
366         )
367 endif(USE_CURL)
368
369 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
370
371 if(BUILD_CLIENT)
372         add_executable(${PROJECT_NAME} ${minetest_SRCS})
373         target_link_libraries(
374                 ${PROJECT_NAME}
375                 ${ZLIB_LIBRARIES}
376                 ${IRRLICHT_LIBRARY}
377                 ${OPENGL_LIBRARIES}
378                 ${JPEG_LIBRARIES}
379                 ${BZIP2_LIBRARIES}
380                 ${PNG_LIBRARIES}
381                 ${X11_LIBRARIES}
382                 ${GETTEXT_LIBRARY}
383                 ${SOUND_LIBRARIES}
384                 ${JTHREAD_LIBRARY}
385                 ${SQLITE3_LIBRARY}
386                 ${LUA_LIBRARY}
387                 ${JSON_LIBRARY}
388                 ${PLATFORM_LIBS}
389                 ${CLIENT_PLATFORM_LIBS}
390         )
391         if(USE_CURL)
392                 target_link_libraries(
393                         ${PROJECT_NAME}
394                         ${CURL_LIBRARY}
395                 )
396         endif(USE_CURL)
397         if(USE_FREETYPE)
398                 target_link_libraries(
399                         ${PROJECT_NAME}
400                         ${FREETYPE_LIBRARY}
401                         ${CGUITTFONT_LIBRARY}
402                 )
403         endif(USE_FREETYPE)
404 endif(BUILD_CLIENT)
405
406 if(BUILD_SERVER)
407         add_executable(${PROJECT_NAME}server ${minetestserver_SRCS})
408         target_link_libraries(
409                 ${PROJECT_NAME}server
410                 ${ZLIB_LIBRARIES}
411                 ${JTHREAD_LIBRARY}
412                 ${SQLITE3_LIBRARY}
413                 ${JSON_LIBRARY}
414                 ${GETTEXT_LIBRARY}
415                 ${LUA_LIBRARY}
416                 ${PLATFORM_LIBS}
417         )
418         if(USE_CURL)
419                 target_link_libraries(
420                         ${PROJECT_NAME}server
421                         ${CURL_LIBRARY}
422                 )
423         endif(USE_CURL)
424 endif(BUILD_SERVER)
425
426
427 #
428 # Set some optimizations and tweaks
429 #
430
431 include(CheckCXXCompilerFlag)
432
433 if(MSVC)
434         # Visual Studio
435
436         # EHa enables SEH exceptions (used for catching segfaults)
437         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")
438         #set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
439         set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
440
441         # Debug build doesn't catch exceptions by itself
442         # Add some optimizations because otherwise it's VERY slow
443         set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1")
444
445         # Flags for C files (sqlite)
446         # /MT = Link statically with standard library stuff
447         set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT")
448         
449         if(BUILD_SERVER)
450                 set_target_properties(${PROJECT_NAME}server PROPERTIES
451                                 COMPILE_DEFINITIONS "SERVER")
452         endif(BUILD_SERVER)
453
454 else()
455         # Probably GCC
456         
457         if(WARN_ALL)
458                 set(RELEASE_WARNING_FLAGS "-Wall")
459         else()
460                 set(RELEASE_WARNING_FLAGS "")
461         endif()
462         
463         if(NOT APPLE AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
464                 CHECK_CXX_COMPILER_FLAG("-Wno-unused-but-set-variable" HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
465                 if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
466                         set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
467                 endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
468         endif()
469
470         if(MINGW)
471                 set(OTHER_FLAGS "-mthreads -fexceptions")
472         endif()
473
474         if(APPLE)
475                 set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING "do not build for 64-bit" FORCE)
476                 set(ARCH i386)
477         endif()
478
479         set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops")
480         set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}")
481
482         if(USE_GPROF)
483                 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
484         endif()
485         
486         if(BUILD_SERVER)
487                 set_target_properties(${PROJECT_NAME}server PROPERTIES
488                                 COMPILE_DEFINITIONS "SERVER")
489         endif(BUILD_SERVER)
490
491 endif()
492
493 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}")
494 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}")
495
496 #
497 # Installation
498 #
499 if(WIN32)
500         if(MINGWM10_DLL)
501                 install(FILES ${MINGWM10_DLL} DESTINATION ${BINDIR})
502         endif()
503         if(DEFINED ZLIB_DLL)
504                 install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
505         endif()
506         if(USE_SOUND)
507                 if(OPENAL_DLL)
508                         install(FILES ${OPENAL_DLL} DESTINATION ${BINDIR})
509                 endif()
510                 if(OGG_DLL)
511                         install(FILES ${OGG_DLL} DESTINATION ${BINDIR})
512                 endif()
513                 if(VORBIS_DLL)
514                         install(FILES ${VORBIS_DLL} DESTINATION ${BINDIR})
515                 endif()
516                 if(VORBISFILE_DLL)
517                         install(FILES ${VORBISFILE_DLL} DESTINATION ${BINDIR})
518                 endif()
519                 if(CURL_DLL)
520                         install(FILES ${CURL_DLL} DESTINATION ${BINDIR})
521                 endif()
522         endif()
523 endif()
524
525 if(BUILD_CLIENT)
526         install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
527
528         if(USE_GETTEXT)
529                 foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
530                         set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
531                         set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
532                         install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH})
533                 endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
534         endif()
535
536         if(WIN32)
537                 if(DEFINED IRRLICHT_DLL)
538                         install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
539                 endif()
540                 if(USE_GETTEXT)
541                         if(DEFINED GETTEXT_DLL)
542                                 install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR})
543                         endif()
544                         if(DEFINED GETTEXT_ICONV_DLL)
545                                 install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR})
546                         endif()
547                 endif(USE_GETTEXT)
548         endif()
549 endif(BUILD_CLIENT)
550
551 if(BUILD_SERVER)
552         install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR})
553 endif(BUILD_SERVER)
554
555 if (USE_GETTEXT)
556         set(MO_FILES)
557
558         foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
559                 set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po")
560                 set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
561                 set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
562
563                 add_custom_command(OUTPUT ${MO_BUILD_PATH}
564                         COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH}
565                         COMMENT "mo-update [${LOCALE}]: Creating locale directory.")
566
567                 add_custom_command(
568                         OUTPUT ${MO_FILE_PATH}
569                         COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH}
570                         DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH}
571                         WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}"
572                         COMMENT "mo-update [${LOCALE}]: Creating mo file."
573                         )
574
575                 set(MO_FILES ${MO_FILES} ${MO_FILE_PATH})
576         endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
577
578         add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES})
579 endif(USE_GETTEXT)
580
581 # Subdirectories
582
583 if (JTHREAD_FOUND)
584 else (JTHREAD_FOUND)
585         add_subdirectory(jthread)
586 endif (JTHREAD_FOUND)
587
588 if (SQLITE3_FOUND)
589 else (SQLITE3_FOUND)
590         add_subdirectory(sqlite)
591 endif (SQLITE3_FOUND)
592
593 if (BUILD_CLIENT AND USE_FREETYPE)
594         add_subdirectory(cguittfont)
595 endif (BUILD_CLIENT AND USE_FREETYPE)
596
597 if (LUA_FOUND)
598 else (LUA_FOUND)
599         add_subdirectory(lua)
600 endif (LUA_FOUND)
601
602 if (JSON_FOUND)
603 else (JSON_FOUND)
604         add_subdirectory(json)
605 endif (JSON_FOUND)
606
607 #end