2 cmake_minimum_required( VERSION 2.6 )
5 add_definitions ( -DRUN_IN_PLACE )
9 set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++")
13 add_definitions ( -DUSE_CMAKE_CONFIG_H )
17 if(MSVC) # MSVC Specifics
18 # Surpress some useless warnings
19 add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
20 else() # Probably MinGW = GCC
21 set(PLATFORM_LIBS ws2_32.lib)
24 set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
25 CACHE PATH "Zlib include directory")
26 set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib"
27 CACHE FILEPATH "Path to zlibwapi.lib")
28 set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll"
29 CACHE FILEPATH "Path to zlibwapi.dll (for installation)")
33 find_package(X11 REQUIRED)
34 find_package(OpenGL REQUIRED)
35 find_package(JPEG REQUIRED)
36 find_package(BZip2 REQUIRED)
37 find_package(PNG REQUIRED)
39 FIND_LIBRARY(CARBON_LIB Carbon)
40 FIND_LIBRARY(COCOA_LIB Cocoa)
41 FIND_LIBRARY(IOKIT_LIB IOKit)
47 SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB})
50 find_package(ZLIB REQUIRED)
51 set(PLATFORM_LIBS -lpthread)
52 #set(CLIENT_PLATFORM_LIBS -lXxf86vm)
53 # This way Xxf86vm is found on OpenBSD too
54 find_library(XXF86VM_LIBRARY Xxf86vm)
55 set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
59 "${PROJECT_SOURCE_DIR}/cmake_config.h.in"
60 "${PROJECT_BINARY_DIR}/cmake_config.h"
115 guiPasswordChange.cpp
123 set(minetestserver_SRCS
129 ${PROJECT_BINARY_DIR}
130 ${IRRLICHT_INCLUDE_DIR}
134 "${PROJECT_SOURCE_DIR}/jthread"
135 "${PROJECT_SOURCE_DIR}/sqlite"
138 set(EXECUTABLE_OUTPUT_PATH ../bin)
141 add_executable(minetest ${minetest_SRCS})
142 target_link_libraries(
152 ${CLIENT_PLATFORM_LIBS}
159 add_executable(minetestserver ${minetestserver_SRCS})
160 target_link_libraries(
170 # Set some optimizations and tweaks
176 # EHa enables SEH exceptions (used for catching segfaults)
177 set(CMAKE_CXX_FLAGS_RELEASE "/EHa /MD /O2 /Ob2 /Oi /Ot /Oy /GL /FD /MT /GS- /arch:SSE /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP")
178 #set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"")
179 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG")
181 # Debug build doesn't catch exceptions by itself
182 # Add some optimizations because otherwise it's VERY slow
183 set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1")
186 set_target_properties(minetestserver PROPERTIES
187 COMPILE_DEFINITIONS "SERVER")
194 set(RELEASE_WARNING_FLAGS "-Wall")
196 set(RELEASE_WARNING_FLAGS "")
200 set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable")
204 set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING "do not build for 64-bit" FORCE)
208 set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops")
209 #set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS}")
210 set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS}")
213 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
217 set_target_properties(minetestserver PROPERTIES
218 COMPILE_DEFINITIONS "SERVER")
223 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}")
224 #MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}")
230 # Example configuration file
231 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../minetest.conf.example" DESTINATION ${EXAMPLE_CONF_DIR})
234 install(TARGETS minetest DESTINATION ${BINDIR})
236 file(GLOB images "${CMAKE_CURRENT_SOURCE_DIR}/../data/*.png")
238 install(FILES ${images} DESTINATION ${DATADIR})
241 if(DEFINED IRRLICHT_DLL)
242 install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
245 install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
251 install(TARGETS minetestserver DESTINATION ${BINDIR})
256 add_subdirectory(jthread)
257 add_subdirectory(sqlite)