2 cmake_minimum_required( VERSION 2.6 )
5 add_definitions ( -DRUN_IN_PLACE )
8 # user-visible option to enable/disable gettext usage
9 OPTION(ENABLE_GETTEXT "Use GetText for internationalization" ON)
11 # this is only set to 1 if gettext is enabled _and_ available
14 find_package(GettextLib)
16 if(GETTEXT_FOUND AND ENABLE_GETTEXT)
17 message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}")
18 message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}")
20 message(STATUS "gettext library: ${GETTEXT_LIBRARY}")
21 message(STATUS "gettext dll: ${GETTEXT_DLL}")
22 message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}")
25 message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}")
26 elseif(GETTEXT_FOUND AND NOT ENABLE_GETTEXT)
27 MESSAGE(STATUS "GetText found but disabled;")
28 else(GETTEXT_FOUND AND ENABLE_GETTEXT)
29 message(STATUS "GetText disabled")
30 endif(GETTEXT_FOUND AND ENABLE_GETTEXT)
33 set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++")
37 add_definitions ( -DUSE_CMAKE_CONFIG_H )
41 if(MSVC) # MSVC Specifics
42 # Surpress some useless warnings
43 add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
44 else() # Probably MinGW = GCC
45 set(PLATFORM_LIBS ws2_32.lib)
48 set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
49 CACHE PATH "Zlib include directory")
50 set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib"
51 CACHE FILEPATH "Path to zlibwapi.lib")
52 set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll"
53 CACHE FILEPATH "Path to zlibwapi.dll (for installation)")
54 set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2"
55 CACHE PATH "irrlicht dir")
59 find_package(X11 REQUIRED)
60 find_package(OpenGL REQUIRED)
61 find_package(JPEG REQUIRED)
62 find_package(BZip2 REQUIRED)
63 find_package(PNG REQUIRED)
65 FIND_LIBRARY(CARBON_LIB Carbon)
66 FIND_LIBRARY(COCOA_LIB Cocoa)
67 FIND_LIBRARY(IOKIT_LIB IOKit)
73 SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB})
76 find_package(ZLIB REQUIRED)
77 set(PLATFORM_LIBS -lpthread ${CMAKE_DL_LIBS})
78 #set(CLIENT_PLATFORM_LIBS -lXxf86vm)
79 # This way Xxf86vm is found on OpenBSD too
80 find_library(XXF86VM_LIBRARY Xxf86vm)
81 set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
84 find_package(Jthread REQUIRED)
85 find_package(Sqlite3 REQUIRED)
87 # TODO: Create proper find script for Lua
88 set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src")
89 set(LUA_LIBRARY "lua")
92 "${PROJECT_SOURCE_DIR}/cmake_config.h.in"
93 "${PROJECT_BINARY_DIR}/cmake_config.h"
99 serverremoteplayer.cpp
144 # This gives us the icon
147 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o
148 COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR}
149 -i${CMAKE_CURRENT_SOURCE_DIR}/winresource.rc
150 -o ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o)
151 SET(common_SRCS ${common_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o)
152 else(MINGW) # Probably MSVC
153 set(common_SRCS ${common_SRCS} winresource.rc)
177 guiPasswordChange.cpp
187 set(minetestserver_SRCS
193 ${PROJECT_BINARY_DIR}
194 ${IRRLICHT_INCLUDE_DIR}
198 ${GETTEXT_INCLUDE_DIR}
199 ${JTHREAD_INCLUDE_DIR}
200 ${SQLITE3_INCLUDE_DIR}
204 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
207 add_executable(${PROJECT_NAME} ${minetest_SRCS})
208 target_link_libraries(
222 ${CLIENT_PLATFORM_LIBS}
227 add_executable(${PROJECT_NAME}server ${minetestserver_SRCS})
228 target_link_libraries(
229 ${PROJECT_NAME}server
239 # Set some optimizations and tweaks
242 include(CheckCXXCompilerFlag)
247 # EHa enables SEH exceptions (used for catching segfaults)
248 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")
249 #set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
250 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
252 # Debug build doesn't catch exceptions by itself
253 # Add some optimizations because otherwise it's VERY slow
254 set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1")
256 # Flags for C files (sqlite)
257 # /MT = Link statically with standard library stuff
258 set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT")
261 set_target_properties(${PROJECT_NAME}server PROPERTIES
262 COMPILE_DEFINITIONS "SERVER")
269 set(RELEASE_WARNING_FLAGS "-Wall")
271 set(RELEASE_WARNING_FLAGS "")
274 if(NOT APPLE AND NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
275 CHECK_CXX_COMPILER_FLAG("-Wno-unused-but-set-variable" HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
276 if(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
277 set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
278 endif(HAS_UNUSED_BUT_SET_VARIABLE_WARNING)
282 set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING "do not build for 64-bit" FORCE)
286 set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops")
287 set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS}")
290 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
294 set_target_properties(${PROJECT_NAME}server PROPERTIES
295 COMPILE_DEFINITIONS "SERVER")
300 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}")
301 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}")
307 # Example configuration file
308 # NOTE: Install is handled elsewhere
309 #install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../minetest.conf.example" DESTINATION ${EXAMPLE_CONF_DIR})
312 install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
314 #file(GLOB images "${CMAKE_CURRENT_SOURCE_DIR}/../data/textures/*.png")
315 #install(FILES ${images} DESTINATION ${DATADIR}/textures)
316 #file(GLOB datasubstuff "${CMAKE_CURRENT_SOURCE_DIR}/../data/*")
317 #install(DIRECTORY "${datasubstuff}" DESTINATION ${DATADIR})
318 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../data/" DESTINATION ${DATADIR})
321 foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
322 set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
323 set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
324 install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH})
325 endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
329 if(DEFINED IRRLICHT_DLL)
330 install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
333 install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
336 if(DEFINED GETTEXT_DLL)
337 install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR})
339 if(DEFINED GETTEXT_ICONV_DLL)
340 install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR})
347 install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR})
353 foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
354 set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po")
355 set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
356 set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
358 add_custom_command(OUTPUT ${MO_BUILD_PATH}
359 COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH}
360 COMMENT "mo-update [${LOCALE}]: Creating locale directory.")
363 OUTPUT ${MO_FILE_PATH}
364 COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH}
365 DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH}
366 WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}"
367 COMMENT "mo-update [${LOCALE}]: Creating mo file."
370 set(MO_FILES ${MO_FILES} ${MO_FILE_PATH})
371 endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
373 add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES})
380 add_subdirectory(jthread)
381 endif (JTHREAD_FOUND)
385 add_subdirectory(sqlite)
386 endif (SQLITE3_FOUND)
390 add_subdirectory(lua)