diff options
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 510 |
1 files changed, 236 insertions, 274 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93083f369..614e81908 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ +cmake_minimum_required(VERSION 2.6) + project(minetest) -cmake_minimum_required( VERSION 2.6 ) -INCLUDE(CheckCSourceRuns) INCLUDE(CheckIncludeFiles) # Add custom SemiDebug build mode @@ -22,83 +22,69 @@ set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING FORCE ) + # Set some random things default to not being visible in the GUI mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) -option(ENABLE_CURL "Enable cURL support for fetching media" 1) -if (NOT ENABLE_CURL) - mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR) -endif(NOT ENABLE_CURL) +option(ENABLE_CURL "Enable cURL support for fetching media" TRUE) +set(USE_CURL FALSE) -if( ENABLE_CURL ) +if(ENABLE_CURL) find_package(CURL) -endif( ENABLE_CURL ) -set(USE_CURL 0) -if (CURL_FOUND AND ENABLE_CURL) - message(STATUS "cURL support enabled") - set(USE_CURL 1) -endif(CURL_FOUND AND ENABLE_CURL) + if (CURL_FOUND) + message(STATUS "cURL support enabled.") + set(USE_CURL TRUE) + endif() +else() + mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR) +endif() -# user-visible option to enable/disable gettext usage -OPTION(ENABLE_GETTEXT "Use GetText for internationalization" 0) -# this is only set to 1 if gettext is enabled _and_ available -set(USE_GETTEXT 0) +option(ENABLE_GETTEXT "Use GetText for internationalization" FALSE) +set(USE_GETTEXT FALSE) if(ENABLE_GETTEXT) find_package(GettextLib) + if(GETTEXT_FOUND) + if(WIN32) + message(STATUS "GetText library: ${GETTEXT_LIBRARY}") + message(STATUS "GetText DLL: ${GETTEXT_DLL}") + message(STATUS "GetText iconv DLL: ${GETTEXT_ICONV_DLL}") + endif() + set(USE_GETTEXT TRUE) + message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") + endif(GETTEXT_FOUND) else() - MARK_AS_ADVANCED(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT) + mark_as_advanced(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT) + message(STATUS "GetText disabled.") endif() -if(GETTEXT_FOUND AND ENABLE_GETTEXT) - message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}") - message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}") - if(WIN32) - message(STATUS "gettext library: ${GETTEXT_LIBRARY}") - message(STATUS "gettext dll: ${GETTEXT_DLL}") - message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}") - endif() - set(USE_GETTEXT 1) - message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") -elseif(GETTEXT_FOUND AND NOT ENABLE_GETTEXT) - MESSAGE(STATUS "GetText found but disabled;") -else(GETTEXT_FOUND AND ENABLE_GETTEXT) - message(STATUS "GetText disabled") -endif(GETTEXT_FOUND AND ENABLE_GETTEXT) - -# user visible option to enable/disable sound -OPTION(ENABLE_SOUND "Enable sound" ON) - -# this is only set to 1 if sound is enabled _and_ available -set(USE_SOUND 0) -set(SOUND_PROBLEM 0) - -if(ENABLE_SOUND AND BUILD_CLIENT) + +option(ENABLE_SOUND "Enable sound" TRUE) +set(USE_SOUND FALSE) + +if(BUILD_CLIENT AND ENABLE_SOUND) # Sound libraries find_package(OpenAL) find_package(Vorbis) if(NOT OPENAL_FOUND) message(STATUS "Sound enabled, but OpenAL not found!") - set(SOUND_PROBLEM 1) - MARK_AS_ADVANCED(CLEAR OPENAL_LIBRARY OPENAL_INCLUDE_DIR) + mark_as_advanced(CLEAR OPENAL_LIBRARY OPENAL_INCLUDE_DIR) endif() if(NOT VORBIS_FOUND) message(STATUS "Sound enabled, but Vorbis libraries not found!") - set(SOUND_PROBLEM 1) - MARK_AS_ADVANCED(CLEAR OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) + mark_as_advanced(CLEAR OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) endif() if(OPENAL_FOUND AND VORBIS_FOUND) - set(USE_SOUND 1) - message(STATUS "Sound enabled") + set(USE_SOUND TRUE) + message(STATUS "Sound enabled.") + else() + message(FATAL_ERROR "Sound enabled, but cannot be used.\n" + "To continue, either fill in the required paths or disable sound. (-DENABLE_SOUND=0)") endif() -endif(ENABLE_SOUND AND BUILD_CLIENT) - -if(SOUND_PROBLEM) - message(FATAL_ERROR "Sound enabled, but cannot be used.\n" - "To continue, either fill in the required paths or disable sound. (-DENABLE_SOUND=0)") endif() + if(USE_SOUND) set(sound_SRCS sound_openal.cpp) set(SOUND_INCLUDE_DIRS @@ -112,18 +98,110 @@ if(USE_SOUND) ) endif() -option(ENABLE_FREETYPE "Enable freetype2 (truetype fonts and basic unicode support)" OFF) -set(USE_FREETYPE 0) + +option(ENABLE_GLES "Enable OpenGL ES support" FALSE) +mark_as_advanced(ENABLE_GLES) +if(ENABLE_GLES) + find_package(OpenGLES2) +endif() + + +option(ENABLE_FREETYPE "Enable FreeType2 (TrueType fonts and basic unicode support)" TRUE) +set(USE_FREETYPE FALSE) + if(ENABLE_FREETYPE) - set(USE_FREETYPE 1) +## +## Note: FindFreetype.cmake seems to have been fixed in recent versions of +## CMake. If issues persist, re-enable this workaround specificially for the +## failing platforms. +## +# if(UNIX) +# include(FindPkgConfig) +# if(PKG_CONFIG_FOUND) +# pkg_check_modules(FREETYPE QUIET freetype2) +# if(FREETYPE_FOUND) +# SET(FREETYPE_PKGCONFIG_FOUND TRUE) +# SET(FREETYPE_LIBRARY ${FREETYPE_LIBRARIES}) +# # Because CMake is idiotic +# string(REPLACE ";" " " FREETYPE_CFLAGS_STR ${FREETYPE_CFLAGS}) +# string(REPLACE ";" " " FREETYPE_LDFLAGS_STR ${FREETYPE_LDFLAGS}) +# endif(FREETYPE_FOUND) +# endif(PKG_CONFIG_FOUND) +# endif(UNIX) +# if(NOT FREETYPE_FOUND) +# find_package(Freetype) +# endif() + find_package(Freetype) + if(FREETYPE_FOUND) + message(STATUS "Freetype enabled.") + set(USE_FREETYPE TRUE) + set(CGUITTFONT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cguittfont") + set(CGUITTFONT_LIBRARY cguittfont) + endif() endif(ENABLE_FREETYPE) + +find_package(Lua REQUIRED) + +find_package(GMP REQUIRED) + +option(ENABLE_LEVELDB "Enable LevelDB backend" TRUE) +set(USE_LEVELDB FALSE) + +if(ENABLE_LEVELDB) + find_library(LEVELDB_LIBRARY leveldb) + find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb) + if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) + set(USE_LEVELDB TRUE) + message(STATUS "LevelDB backend enabled.") + include_directories(${LEVELDB_INCLUDE_DIR}) + else() + message(STATUS "LevelDB not found!") + endif() +endif(ENABLE_LEVELDB) + + +OPTION(ENABLE_REDIS "Enable Redis backend" TRUE) +set(USE_REDIS FALSE) + +if(ENABLE_REDIS) + find_library(REDIS_LIBRARY hiredis) + find_path(REDIS_INCLUDE_DIR hiredis.h PATH_SUFFIXES hiredis) + if(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) + set(USE_REDIS TRUE) + message(STATUS "Redis backend enabled.") + include_directories(${REDIS_INCLUDE_DIR}) + else(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) + message(STATUS "Redis not found!") + endif(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) +endif(ENABLE_REDIS) + + +find_package(SQLite3 REQUIRED) +find_package(Json REQUIRED) + +OPTION(ENABLE_SPATIAL "Enable SpatialIndex AreaStore backend" TRUE) +set(USE_SPATIAL FALSE) + +if(ENABLE_SPATIAL) + find_library(SPATIAL_LIBRARY spatialindex) + find_path(SPATIAL_INCLUDE_DIR spatialindex/SpatialIndex.h) + if(SPATIAL_LIBRARY AND SPATIAL_INCLUDE_DIR) + set(USE_SPATIAL TRUE) + message(STATUS "SpatialIndex AreaStore backend enabled.") + include_directories(${SPATIAL_INCLUDE_DIR}) + else(SPATIAL_LIBRARY AND SPATIAL_INCLUDE_DIR) + message(STATUS "SpatialIndex not found!") + endif(SPATIAL_LIBRARY AND SPATIAL_INCLUDE_DIR) +endif(ENABLE_SPATIAL) + + if(NOT MSVC) - set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++") + set(USE_GPROF FALSE CACHE BOOL "Use -pg flag for g++") endif() # Use cmake_config.h -add_definitions ( -DUSE_CMAKE_CONFIG_H ) +add_definitions(-DUSE_CMAKE_CONFIG_H) if(WIN32) # Windows @@ -132,8 +210,10 @@ if(WIN32) # Surpress some useless warnings add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 ) else() # Probably MinGW = GCC - set(PLATFORM_LIBS ws2_32.lib) + set(PLATFORM_LIBS "") endif() + set(PLATFORM_LIBS ws2_32.lib shlwapi.lib ${PLATFORM_LIBS}) + # Zlib stuff set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5" CACHE PATH "Zlib include directory") @@ -150,7 +230,7 @@ if(WIN32) CACHE PATH "freetype include dir") set(FREETYPE_LIBRARY "${PROJECT_SOURCE_DIR}/../../freetype2/objs/win32/vc2005/freetype247.lib" CACHE FILEPATH "Path to freetype247.lib") - endif(USE_FREETYPE) + endif() if(ENABLE_SOUND) set(OPENAL_DLL "" CACHE FILEPATH "Path to OpenAL32.dll for installation (optional)") set(OGG_DLL "" CACHE FILEPATH "Path to libogg.dll for installation (optional)") @@ -166,9 +246,9 @@ else() find_package(BZip2 REQUIRED) find_package(PNG REQUIRED) if(APPLE) - FIND_LIBRARY(CARBON_LIB Carbon) - FIND_LIBRARY(COCOA_LIB Cocoa) - FIND_LIBRARY(IOKIT_LIB IOKit) + find_library(CARBON_LIB Carbon) + find_library(COCOA_LIB Cocoa) + find_library(IOKIT_LIB IOKit) mark_as_advanced( CARBON_LIB COCOA_LIB @@ -184,184 +264,51 @@ else() else() set(PLATFORM_LIBS -lrt ${PLATFORM_LIBS}) endif(APPLE) - #set(CLIENT_PLATFORM_LIBS -lXxf86vm) + # This way Xxf86vm is found on OpenBSD too find_library(XXF86VM_LIBRARY Xxf86vm) mark_as_advanced(XXF86VM_LIBRARY) set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY}) -endif() - -find_package(SQLite3 REQUIRED) -find_package(Json REQUIRED) - -option(ENABLE_GLES "Enable OpenGL ES support" 0) -mark_as_advanced(ENABLE_GLES) -if(ENABLE_GLES) - find_package(OpenGLES2) -endif(ENABLE_GLES) - -if(USE_FREETYPE) - if(UNIX) - include(FindPkgConfig) - if(PKG_CONFIG_FOUND) - pkg_check_modules(FREETYPE QUIET freetype2) - if(FREETYPE_FOUND) - SET(FREETYPE_PKGCONFIG_FOUND TRUE) - SET(FREETYPE_LIBRARY ${FREETYPE_LIBRARIES}) - # because cmake is idiotic - string(REPLACE ";" " " FREETYPE_CFLAGS_STR ${FREETYPE_CFLAGS}) - string(REPLACE ";" " " FREETYPE_LDFLAGS_STR ${FREETYPE_LDFLAGS}) - endif(FREETYPE_FOUND) - endif(PKG_CONFIG_FOUND) - endif(UNIX) - if(NOT FREETYPE_FOUND) - find_package(Freetype REQUIRED) - endif(NOT FREETYPE_FOUND) - set(CGUITTFONT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cguittfont") - set(CGUITTFONT_LIBRARY cguittfont) -endif(USE_FREETYPE) - -if (NOT DISABLE_LUAJIT) - find_library(LUA_LIBRARY luajit - NAMES luajit-5.1) - find_path(LUA_INCLUDE_DIR luajit.h - NAMES luajit.h - PATH_SUFFIXES luajit-2.0) - message (STATUS "LuaJIT library: ${LUA_LIBRARY}") - message (STATUS "LuaJIT headers: ${LUA_INCLUDE_DIR}") -else (NOT ${DISABLE_LUAJIT} MATCHES "1") - message (STATUS "LuaJIT detection disabled! (DISABLE_LUAJIT=1)") - set(LUA_LIBRARY "") - set(LUA_INCLUDE_DIR "") -endif (NOT DISABLE_LUAJIT) - -set(USE_LUAJIT 0) -if(LUA_LIBRARY AND LUA_INCLUDE_DIR) - message (STATUS "LuaJIT found, checking for broken versions...") - if(CMAKE_CROSSCOMPILING) - message(WARNING "Cross-compiling enabled, assuming LuaJIT is not broken") - set(VALID_LUAJIT_VERSION 1) - else(CMAKE_CROSSCOMPILING) - set(BACKUP_REQUIRED_INCS CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${LUA_INCLUDE_DIR}") - CHECK_C_SOURCE_RUNS(" - #include <luajit.h> - #include <stdio.h> - #include <string.h> - - #define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0])) - - static char *broken_luajit_versions[] = { - \"LuaJIT 2.0.0-beta7\", - \"LuaJIT 2.0.0-beta6\", - \"LuaJIT 2.0.0-beta5\", - \"LuaJIT 2.0.0-beta4\", - \"LuaJIT 2.0.0-beta3\", - \"LuaJIT 2.0.0-beta2\", - \"LuaJIT 2.0.0-beta1\" - }; - - int main(int argc, char *argv[]) { - unsigned int i; - for (i = 0; i < ARRAYSIZE(broken_luajit_versions); i++) { - if (strcmp(LUAJIT_VERSION, broken_luajit_versions[i]) == 0) { - return 1; - } - } - return 0; - } - " - VALID_LUAJIT_VERSION) - set(CMAKE_REQUIRED_INCLUDES BACKUP_REQUIRED_INCS) - endif(CMAKE_CROSSCOMPILING) - if (VALID_LUAJIT_VERSION) - message (STATUS "LuaJIT version ok") - set(USE_LUAJIT 1) - else (VALID_LUAJIT_VERSION) - message (STATUS "LuaJIT versions till 2.0.0beta7 known to be broken, update to at least beta8") - set(USE_LUAJIT 0) - endif (VALID_LUAJIT_VERSION) -endif (LUA_LIBRARY AND LUA_INCLUDE_DIR) - -if(NOT USE_LUAJIT) - message (STATUS "LuaJIT not found, using bundled Lua.") - set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src") - set(LUA_LIBRARY "lua") - add_subdirectory(lua) -endif(NOT USE_LUAJIT) - -mark_as_advanced(LUA_LIBRARY) -mark_as_advanced(LUA_INCLUDE_DIR) - -set(USE_LEVELDB 0) - -OPTION(ENABLE_LEVELDB "Enable LevelDB backend") - -if(ENABLE_LEVELDB) - find_library(LEVELDB_LIBRARY leveldb) - find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb) - message (STATUS "LevelDB library: ${LEVELDB_LIBRARY}") - message (STATUS "LevelDB headers: ${LEVELDB_INCLUDE_DIR}") - if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) - set(USE_LEVELDB 1) - message(STATUS "LevelDB backend enabled") - include_directories(${LEVELDB_INCLUDE_DIR}) - else(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) - set(USE_LEVELDB 0) - message(STATUS "LevelDB not found!") - endif(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) -endif(ENABLE_LEVELDB) -set(USE_REDIS 0) - -OPTION(ENABLE_REDIS "Enable redis backend" 0) - -if(ENABLE_REDIS) - find_library(REDIS_LIBRARY hiredis) - find_path(REDIS_INCLUDE_DIR hiredis.h PATH_SUFFIXES hiredis) - message(STATUS "redis library: ${REDIS_LIBRARY}") - message(STATUS "redis headers: ${REDIS_INCLUDE_DIR}") - if(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) - set(USE_REDIS 1) - message(STATUS "redis backend enabled") - include_directories(${REDIS_INCLUDE_DIR}) - else(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) - set(USE_REDIS 0) - message(STATUS "redis not found!") - endif(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) -endif(ENABLE_REDIS) + # Prefer local iconv if installed + find_library(ICONV_LIBRARY iconv) + mark_as_advanced(ICONV_LIBRARY) + if (ICONV_LIBRARY) + set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY}) + endif() +endif() -CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H) -if(NOT HAVE_ENDIAN_H) - set(HAVE_ENDIAN_H 0) -endif(NOT HAVE_ENDIAN_H) +check_include_files(endian.h HAVE_ENDIAN_H) configure_file( "${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_BINARY_DIR}/cmake_config.h" ) + # Add a target that always rebuilds cmake_config_githash.h add_custom_target(GenerateVersion COMMAND ${CMAKE_COMMAND} -D "GENERATE_VERSION_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" -D "GENERATE_VERSION_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" -D "VERSION_STRING=${VERSION_STRING}" - -D "VERSION_EXTRA=${VERSION_EXTRA}" + -D "DEVELOPMENT_BUILD=${DEVELOPMENT_BUILD}" -P "${CMAKE_SOURCE_DIR}/cmake/Modules/GenerateVersion.cmake" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + add_subdirectory(jthread) +add_subdirectory(network) add_subdirectory(script) +add_subdirectory(unittest) add_subdirectory(util) set(common_SRCS + areastore.cpp ban.cpp - base64.cpp cavegen.cpp clientiface.cpp collision.cpp - connection.cpp content_abm.cpp content_mapnode.cpp content_nodemeta.cpp @@ -406,10 +353,12 @@ set(common_SRCS nodemetadata.cpp nodetimer.cpp noise.cpp + objdef.cpp object_properties.cpp pathfinder.cpp player.cpp porting.cpp + profiler.cpp quicktune.cpp rollback.cpp rollback_interface.cpp @@ -418,25 +367,26 @@ set(common_SRCS serverlist.cpp serverobject.cpp settings.cpp - sha1.cpp socket.cpp sound.cpp staticobject.cpp subgame.cpp - test.cpp tool.cpp treegen.cpp version.cpp voxel.cpp voxelalgorithms.cpp + ${common_network_SRCS} ${JTHREAD_SRCS} ${common_SCRIPT_SRCS} ${UTIL_SRCS} + ${UNITTEST_SRCS} ) + # This gives us the icon and file version information if(WIN32) - set(WINRESOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../misc/winresource.rc) + set(WINRESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../misc/winresource.rc") if(MINGW) if(NOT CMAKE_RC_COMPILER) set(CMAKE_RC_COMPILER "windres.exe") @@ -453,10 +403,17 @@ if(WIN32) endif(MINGW) endif() + # Client sources -set(minetest_SRCS +if (BUILD_CLIENT) + add_subdirectory(client) +endif(BUILD_CLIENT) + +set(client_SRCS + ${client_SRCS} ${common_SRCS} ${sound_SRCS} + ${client_network_SRCS} camera.cpp chat.cpp client.cpp @@ -478,29 +435,32 @@ set(minetest_SRCS guiFormSpecMenu.cpp guiKeyChangeMenu.cpp guiPasswordChange.cpp + guiscalingfilter.cpp guiTable.cpp guiVolumeChange.cpp hud.cpp + imagefilters.cpp + intlGUIEditBox.cpp keycode.cpp localplayer.cpp main.cpp mapblock_mesh.cpp mesh.cpp + minimap.cpp particles.cpp shader.cpp sky.cpp - tile.cpp wieldmesh.cpp - ${minetest_SCRIPT_SRCS} + ${client_SCRIPT_SRCS} ) -list(SORT minetest_SRCS) +list(SORT client_SRCS) # Server sources -set(minetestserver_SRCS +set(server_SRCS ${common_SRCS} main.cpp ) -list(SORT minetestserver_SRCS) +list(SORT server_SRCS) include_directories( ${PROJECT_BINARY_DIR} @@ -513,29 +473,28 @@ include_directories( ${SOUND_INCLUDE_DIRS} ${SQLITE3_INCLUDE_DIR} ${LUA_INCLUDE_DIR} + ${GMP_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/script ) + if(USE_FREETYPE) - include_directories( - ${FREETYPE_INCLUDE_DIRS} - ${CGUITTFONT_INCLUDE_DIR} - ) -endif(USE_FREETYPE) + include_directories(${FREETYPE_INCLUDE_DIRS} ${CGUITTFONT_INCLUDE_DIR}) +endif() if(USE_CURL) - include_directories( - ${CURL_INCLUDE_DIR} - ) -endif(USE_CURL) + include_directories(${CURL_INCLUDE_DIR}) +endif() + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin") + if(BUILD_CLIENT) - add_executable(${PROJECT_NAME} ${minetest_SRCS}) + add_executable(${PROJECT_NAME} ${client_SRCS}) add_dependencies(${PROJECT_NAME} GenerateVersion) - set(minetest_LIBS + set(client_LIBS ${PROJECT_NAME} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} @@ -548,6 +507,7 @@ if(BUILD_CLIENT) ${SOUND_LIBRARIES} ${SQLITE3_LIBRARY} ${LUA_LIBRARY} + ${GMP_LIBRARY} ${JSON_LIBRARY} ${OPENGLES2_LIBRARIES} ${PLATFORM_LIBS} @@ -555,12 +515,12 @@ if(BUILD_CLIENT) ) if(APPLE) target_link_libraries( - ${minetest_LIBS} + ${client_LIBS} ${ICONV_LIBRARY} ) else() target_link_libraries( - ${minetest_LIBS} + ${client_LIBS} ) endif() if(USE_CURL) @@ -568,30 +528,34 @@ if(BUILD_CLIENT) ${PROJECT_NAME} ${CURL_LIBRARY} ) - endif(USE_CURL) + endif() if(USE_FREETYPE) if(FREETYPE_PKGCONFIG_FOUND) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${FREETYPE_CFLAGS_STR}" ) - endif(FREETYPE_PKGCONFIG_FOUND) + endif() target_link_libraries( ${PROJECT_NAME} ${FREETYPE_LIBRARY} ${CGUITTFONT_LIBRARY} ) - endif(USE_FREETYPE) + endif() if (USE_LEVELDB) target_link_libraries(${PROJECT_NAME} ${LEVELDB_LIBRARY}) - endif(USE_LEVELDB) + endif() if (USE_REDIS) target_link_libraries(${PROJECT_NAME} ${REDIS_LIBRARY}) - endif(USE_REDIS) + endif() + if (USE_SPATIAL) + target_link_libraries(${PROJECT_NAME} ${SPATIAL_LIBRARY}) + endif() endif(BUILD_CLIENT) + if(BUILD_SERVER) - add_executable(${PROJECT_NAME}server ${minetestserver_SRCS}) + add_executable(${PROJECT_NAME}server ${server_SRCS}) add_dependencies(${PROJECT_NAME}server GenerateVersion) target_link_libraries( ${PROJECT_NAME}server @@ -600,26 +564,30 @@ if(BUILD_SERVER) ${JSON_LIBRARY} ${GETTEXT_LIBRARY} ${LUA_LIBRARY} + ${GMP_LIBRARY} ${PLATFORM_LIBS} ) + set_target_properties(${PROJECT_NAME}server PROPERTIES + COMPILE_DEFINITIONS "SERVER") if (USE_LEVELDB) target_link_libraries(${PROJECT_NAME}server ${LEVELDB_LIBRARY}) - endif(USE_LEVELDB) + endif() if (USE_REDIS) target_link_libraries(${PROJECT_NAME}server ${REDIS_LIBRARY}) - endif(USE_REDIS) + endif() + if (USE_SPATIAL) + target_link_libraries(${PROJECT_NAME}server ${SPATIAL_LIBRARY}) + endif() if(USE_CURL) target_link_libraries( ${PROJECT_NAME}server ${CURL_LIBRARY} ) - endif(USE_CURL) + endif() endif(BUILD_SERVER) -# # Set some optimizations and tweaks -# include(CheckCXXCompilerFlag) @@ -640,12 +608,6 @@ if(MSVC) # Flags for C files (sqlite) # /MT = Link statically with standard library stuff set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT") - - if(BUILD_SERVER) - set_target_properties(${PROJECT_NAME}server PROPERTIES - COMPILE_DEFINITIONS "SERVER") - endif(BUILD_SERVER) - else() # Probably GCC if(APPLE) @@ -660,6 +622,7 @@ else() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # clang does not understand __extern_always_inline but libc headers use it set(OTHER_FLAGS "${OTHER_FLAGS} \"-D__extern_always_inline=extern __always_inline\"") + set(OTHER_FLAGS "${OTHER_FLAGS} -Wsign-compare") endif() if(MINGW) @@ -678,20 +641,11 @@ else() if(USE_GPROF) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") endif() - - if(BUILD_SERVER) - set_target_properties(${PROJECT_NAME}server PROPERTIES - COMPILE_DEFINITIONS "SERVER") - endif(BUILD_SERVER) - endif() -#MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}") -#MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}") -# # Installation -# + if(WIN32) if(USE_SOUND) if(OPENAL_DLL) @@ -728,14 +682,27 @@ if(WIN32) endif() if(BUILD_CLIENT) - install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) + install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${BINDIR} + LIBRARY DESTINATION ${BINDIR} + ARCHIVE DESTINATION ${BINDIR} + BUNDLE DESTINATION . + ) + + if(APPLE) + install(CODE " + set(BU_CHMOD_BUNDLE_ITEMS ON) + include(BundleUtilities) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${BUNDLE_PATH}\" \"\" \"\${CMAKE_INSTALL_PREFIX}/${BINDIR}\") + " COMPONENT Runtime) + endif() if(USE_GETTEXT) foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH}) - endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) + endforeach() endif() if(WIN32) @@ -749,19 +716,19 @@ if(BUILD_CLIENT) if(DEFINED GETTEXT_ICONV_DLL) install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR}) endif() - endif(USE_GETTEXT) + endif() endif() endif(BUILD_CLIENT) if(BUILD_SERVER) install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR}) -endif(BUILD_SERVER) +endif() if (USE_GETTEXT) set(MO_FILES) foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) - set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po") + set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/${PROJECT_NAME}.po") set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") @@ -778,20 +745,15 @@ if (USE_GETTEXT) ) set(MO_FILES ${MO_FILES} ${MO_FILE_PATH}) - endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) + endforeach() add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES}) -endif(USE_GETTEXT) +endif() + # Subdirectories if (BUILD_CLIENT AND USE_FREETYPE) add_subdirectory(cguittfont) -endif (BUILD_CLIENT AND USE_FREETYPE) - -if (JSON_FOUND) -else (JSON_FOUND) - add_subdirectory(json) -endif (JSON_FOUND) +endif() -#end |