INCLUDE(CheckLibraryExists)
# Add custom SemiDebug build mode
-set(CMAKE_CXX_FLAGS_SEMIDEBUG "-O1 -g -Wall -Wabi=11" CACHE STRING
+set(CMAKE_CXX_FLAGS_SEMIDEBUG "-O1 -g -Wall -Wabi" CACHE STRING
"Flags used by the C++ compiler during semidebug builds."
FORCE
)
endif()
-option(ENABLE_GLES "Enable OpenGL ES support" FALSE)
+option(ENABLE_GLES "Use OpenGL ES instead of OpenGL" FALSE)
mark_as_advanced(ENABLE_GLES)
-if(ENABLE_GLES)
- find_package(OpenGLES2)
+if(BUILD_CLIENT)
+ if(ENABLE_GLES)
+ find_package(OpenGLES2 REQUIRED)
+ else()
+ # transitive dependency from Irrlicht (see longer explanation below)
+ if(NOT WIN32)
+ set(OPENGL_GL_PREFERENCE "LEGACY" CACHE STRING
+ "See CMake Policy CMP0072 for reference. GLVND is broken on some nvidia setups")
+ set(OpenGL_GL_PREFERENCE ${OPENGL_GL_PREFERENCE})
+
+ find_package(OpenGL REQUIRED)
+ endif()
+ endif()
endif()
set(USE_POSTGRESQL FALSE)
if(ENABLE_POSTGRESQL)
- find_program(POSTGRESQL_CONFIG_EXECUTABLE pg_config DOC "pg_config")
- find_library(POSTGRESQL_LIBRARY pq)
- if(POSTGRESQL_CONFIG_EXECUTABLE)
- execute_process(COMMAND ${POSTGRESQL_CONFIG_EXECUTABLE} --includedir-server
- OUTPUT_VARIABLE POSTGRESQL_SERVER_INCLUDE_DIRS
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process(COMMAND ${POSTGRESQL_CONFIG_EXECUTABLE}
- OUTPUT_VARIABLE POSTGRESQL_CLIENT_INCLUDE_DIRS
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- # This variable is case sensitive for the cmake PostgreSQL module
- set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${POSTGRESQL_SERVER_INCLUDE_DIRS} ${POSTGRESQL_CLIENT_INCLUDE_DIRS})
- endif()
-
find_package("PostgreSQL")
- if(POSTGRESQL_FOUND)
+ if(PostgreSQL_FOUND)
set(USE_POSTGRESQL TRUE)
message(STATUS "PostgreSQL backend enabled")
# This variable is case sensitive, don't try to change it to POSTGRESQL_INCLUDE_DIR
- message(STATUS "PostgreSQL includes: ${PostgreSQL_INCLUDE_DIR}")
- include_directories(${PostgreSQL_INCLUDE_DIR})
+ message(STATUS "PostgreSQL includes: ${PostgreSQL_INCLUDE_DIRS}")
+ include_directories(${PostgreSQL_INCLUDE_DIRS})
else()
message(STATUS "PostgreSQL not found!")
endif()
set(USE_LEVELDB FALSE)
if(ENABLE_LEVELDB)
- find_library(LEVELDB_LIBRARY leveldb)
+ find_library(LEVELDB_LIBRARY NAMES leveldb libleveldb)
find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb)
if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
set(USE_LEVELDB TRUE)
set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib ${PLATFORM_LIBS})
# Zlib stuff
- set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
- CACHE PATH "Zlib include directory")
- set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib"
- CACHE FILEPATH "Path to zlib library (usually zlibwapi.lib)")
- set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll"
- CACHE FILEPATH "Path to zlib DLL (for installation)")
- set(ZLIBWAPI_DLL "" CACHE FILEPATH "Path to zlibwapi DLL")
- set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2"
- CACHE PATH "irrlicht dir")
- if(USE_FREETYPE)
- set(FREETYPE_INCLUDE_DIR_ft2build "${PROJECT_SOURCE_DIR}/../../freetype2/include/"
- CACHE PATH "freetype include dir")
- set(FREETYPE_INCLUDE_DIR_freetype2 "${PROJECT_SOURCE_DIR}/../../freetype2/include/freetype"
- CACHE PATH "freetype include dir")
- set(FREETYPE_LIBRARY "${PROJECT_SOURCE_DIR}/../../freetype2/objs/win32/vc2005/freetype247.lib"
- CACHE FILEPATH "Path to freetype247.lib")
- 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)")
- set(VORBIS_DLL "" CACHE FILEPATH "Path to libvorbis.dll for installation (optional)")
- set(VORBISFILE_DLL "" CACHE FILEPATH "Path to libvorbisfile.dll for installation (optional)")
- endif()
- if(USE_LUAJIT)
- set(LUA_DLL "" CACHE FILEPATH "Path to lua51.dll for installation (optional)")
+ find_path(ZLIB_INCLUDE_DIR "zlib.h" DOC "Zlib include directory")
+ find_library(ZLIB_LIBRARIES "zlib" DOC "Path to zlib library")
+
+ # Dll's are automatically copied to the output directory by vcpkg when VCPKG_APPLOCAL_DEPS=ON
+ if(NOT VCPKG_APPLOCAL_DEPS)
+ find_file(ZLIB_DLL NAMES "zlib.dll" "zlib1.dll" DOC "Path to zlib.dll for installation (optional)")
+ 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)")
+ set(VORBIS_DLL "" CACHE FILEPATH "Path to libvorbis.dll for installation (optional)")
+ set(VORBISFILE_DLL "" CACHE FILEPATH "Path to libvorbisfile.dll for installation (optional)")
+ endif()
+ if(USE_LUAJIT)
+ set(LUA_DLL "" CACHE FILEPATH "Path to luajit-5.1.dll for installation (optional)")
+ endif()
endif()
+
else()
# Unix probably
if(BUILD_CLIENT)
- if(NOT HAIKU)
+ if(NOT HAIKU AND NOT APPLE)
find_package(X11 REQUIRED)
- endif(NOT HAIKU)
-
- set(OPENGL_GL_PREFERENCE "LEGACY" CACHE STRING
- "See CMake Policy CMP0072 for reference. GLVND is broken on some nvidia setups")
- set(OpenGL_GL_PREFERENCE ${OPENGL_GL_PREFERENCE})
+ endif(NOT HAIKU AND NOT APPLE)
+
+ ##
+ # The following dependencies are transitive dependencies from Irrlicht.
+ # Minetest itself does not use them, but we link them so that statically
+ # linking Irrlicht works.
+ if(NOT HAIKU AND NOT APPLE)
+ # 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(NOT HAIKU AND NOT APPLE)
- find_package(OpenGL REQUIRED)
find_package(JPEG REQUIRED)
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 REQUIRED)
+ find_library(COCOA_LIB Cocoa REQUIRED)
+ find_library(IOKIT_LIB IOKit REQUIRED)
mark_as_advanced(
CARBON_LIB
COCOA_LIB
)
SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB})
endif(APPLE)
+ ##
endif(BUILD_CLIENT)
+
find_package(ZLIB REQUIRED)
set(PLATFORM_LIBS -lpthread ${CMAKE_DL_LIBS})
if(APPLE)
endif(HAVE_LIBRT)
endif(APPLE)
- if(NOT HAIKU AND NOT APPLE)
- # 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(NOT HAIKU AND NOT APPLE)
-
# Prefer local iconv if installed
find_library(ICONV_LIBRARY iconv)
mark_as_advanced(ICONV_LIBRARY)
player.cpp
porting.cpp
profiler.cpp
- quicktune.cpp
raycast.cpp
reflowscan.cpp
remoteplayer.cpp
${PROJECT_SOURCE_DIR}
${IRRLICHT_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
- ${CMAKE_BUILD_TYPE}
${PNG_INCLUDE_DIR}
- ${GETTEXT_INCLUDE_DIR}
${SOUND_INCLUDE_DIRS}
${SQLITE3_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/script
)
+if(USE_GETTEXT)
+ include_directories(${GETTEXT_INCLUDE_DIR})
+endif()
if(USE_FREETYPE)
include_directories(${FREETYPE_INCLUDE_DIRS})
${PROJECT_NAME}
${ZLIB_LIBRARIES}
${IRRLICHT_LIBRARY}
- ${OPENGL_LIBRARIES}
${JPEG_LIBRARIES}
${BZIP2_LIBRARIES}
${PNG_LIBRARIES}
${X11_LIBRARIES}
- ${GETTEXT_LIBRARY}
${SOUND_LIBRARIES}
${SQLITE3_LIBRARY}
${LUA_LIBRARY}
${GMP_LIBRARY}
${JSON_LIBRARY}
- ${OPENGLES2_LIBRARIES}
${PLATFORM_LIBS}
${CLIENT_PLATFORM_LIBS}
)
- if(APPLE)
+ target_link_libraries(
+ ${client_LIBS}
+ )
+ if(ENABLE_GLES)
target_link_libraries(
- ${client_LIBS}
- ${ICONV_LIBRARY}
+ ${PROJECT_NAME}
+ ${OPENGLES2_LIBRARIES}
+ ${EGL_LIBRARIES}
)
else()
target_link_libraries(
- ${client_LIBS}
+ ${PROJECT_NAME}
+ ${OPENGL_LIBRARIES}
+ )
+ endif()
+ if(USE_GETTEXT)
+ target_link_libraries(
+ ${PROJECT_NAME}
+ ${GETTEXT_LIBRARY}
)
endif()
if(USE_CURL)
target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES})
endif()
if (USE_POSTGRESQL)
- target_link_libraries(${PROJECT_NAME} ${POSTGRESQL_LIBRARY})
+ target_link_libraries(${PROJECT_NAME} ${PostgreSQL_LIBRARIES})
endif()
if (USE_LEVELDB)
target_link_libraries(${PROJECT_NAME} ${LEVELDB_LIBRARY})
${ZLIB_LIBRARIES}
${SQLITE3_LIBRARY}
${JSON_LIBRARY}
- ${GETTEXT_LIBRARY}
${LUA_LIBRARY}
${GMP_LIBRARY}
${PLATFORM_LIBS}
)
set_target_properties(${PROJECT_NAME}server PROPERTIES
COMPILE_DEFINITIONS "SERVER")
+ if (USE_GETTEXT)
+ target_link_libraries(${PROJECT_NAME}server ${GETTEXT_LIBRARY})
+ endif()
if (USE_CURSES)
target_link_libraries(${PROJECT_NAME}server ${CURSES_LIBRARIES})
endif()
if (USE_POSTGRESQL)
- target_link_libraries(${PROJECT_NAME}server ${POSTGRESQL_LIBRARY})
+ target_link_libraries(${PROJECT_NAME}server ${PostgreSQL_LIBRARIES})
endif()
if (USE_LEVELDB)
target_link_libraries(${PROJECT_NAME}server ${LEVELDB_LIBRARY})
he
ko
ky
- zh_CN
- zh_TW
)
option(APPLY_LOCALE_BLACKLIST "Use a blacklist to avoid broken locales" TRUE)
# /MD = dynamically link to MSVCRxxx.dll
set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MD")
else()
+ # GCC or compatible compilers such as Clang
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- # Probably GCC
- if(APPLE)
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000" )
- endif()
if(WARN_ALL)
set(RELEASE_WARNING_FLAGS "-Wall")
else()
endif()
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")
+ set(WARNING_FLAGS "${WARNING_FLAGS} -Wsign-compare")
endif()
-
- if(WIN32 AND NOT ZLIBWAPI_DLL AND CMAKE_SIZEOF_VOID_P EQUAL 4)
- set(OTHER_FLAGS "${OTHER_FLAGS} -DWIN32_NO_ZLIB_WINAPI")
- message(WARNING "Defaulting to cdecl for zlib on win32 because ZLIBWAPI_DLL"
- " isn't set, ensure that ZLIBWAPI_DLL is set if you want stdcall.")
+ if(APPLE AND USE_LUAJIT)
+ # required per http://luajit.org/install.html
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000")
endif()
if(MINGW)
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops")
- if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
+ if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -ffast-math -fomit-frame-pointer")
- endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
- set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall -Wabi=11 ${WARNING_FLAGS} ${OTHER_FLAGS}")
- set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wabi=11 ${WARNING_FLAGS} ${OTHER_FLAGS}")
+ endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
+ set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS}")
+ set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS}")
if(USE_GPROF)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
# Installation
if(WIN32)
- if(USE_SOUND)
- if(OPENAL_DLL)
- install(FILES ${OPENAL_DLL} DESTINATION ${BINDIR})
+ if(VCPKG_APPLOCAL_DEPS)
+ # Collect the dll's from the output path
+ install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/Release/
+ DESTINATION ${BINDIR}
+ CONFIGURATIONS Release
+ FILES_MATCHING PATTERN "*.dll")
+ install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/Debug/
+ DESTINATION ${BINDIR}
+ CONFIGURATIONS Debug
+ FILES_MATCHING PATTERN "*.dll")
+ install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/RelWithDebInfo/
+ DESTINATION ${BINDIR}
+ CONFIGURATIONS RelWithDebInfo
+ FILES_MATCHING PATTERN "*.dll")
+ install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/MinSizeRel/
+ DESTINATION ${BINDIR}
+ CONFIGURATIONS MinSizeRel
+ FILES_MATCHING PATTERN "*.dll")
+ else()
+ # Use the old-style way to install dll's
+ if(USE_SOUND)
+ if(OPENAL_DLL)
+ install(FILES ${OPENAL_DLL} DESTINATION ${BINDIR})
+ endif()
+ if(OGG_DLL)
+ install(FILES ${OGG_DLL} DESTINATION ${BINDIR})
+ endif()
+ if(VORBIS_DLL)
+ install(FILES ${VORBIS_DLL} DESTINATION ${BINDIR})
+ endif()
+ if(VORBISFILE_DLL)
+ install(FILES ${VORBISFILE_DLL} DESTINATION ${BINDIR})
+ endif()
endif()
- if(OGG_DLL)
- install(FILES ${OGG_DLL} DESTINATION ${BINDIR})
+ if(CURL_DLL)
+ install(FILES ${CURL_DLL} DESTINATION ${BINDIR})
endif()
- if(VORBIS_DLL)
- install(FILES ${VORBIS_DLL} DESTINATION ${BINDIR})
+ if(ZLIB_DLL)
+ install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
endif()
- if(VORBISFILE_DLL)
- install(FILES ${VORBISFILE_DLL} DESTINATION ${BINDIR})
+ if(FREETYPE_DLL)
+ install(FILES ${FREETYPE_DLL} DESTINATION ${BINDIR})
+ endif()
+ if(SQLITE3_DLL)
+ install(FILES ${SQLITE3_DLL} DESTINATION ${BINDIR})
+ endif()
+ if(LEVELDB_DLL)
+ install(FILES ${LEVELDB_DLL} DESTINATION ${BINDIR})
+ endif()
+ if(LUA_DLL)
+ install(FILES ${LUA_DLL} DESTINATION ${BINDIR})
endif()
- endif()
- if(CURL_DLL)
- install(FILES ${CURL_DLL} DESTINATION ${BINDIR})
- endif()
- if(ZLIB_DLL)
- install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
- endif()
- if(ZLIBWAPI_DLL)
- install(FILES ${ZLIBWAPI_DLL} DESTINATION ${BINDIR})
- endif()
- if(FREETYPE_DLL)
- install(FILES ${FREETYPE_DLL} DESTINATION ${BINDIR})
- endif()
- if(SQLITE3_DLL)
- install(FILES ${SQLITE3_DLL} DESTINATION ${BINDIR})
- endif()
- if(LEVELDB_DLL)
- install(FILES ${LEVELDB_DLL} DESTINATION ${BINDIR})
- endif()
- if(LUA_DLL)
- install(FILES ${LUA_DLL} DESTINATION ${BINDIR})
endif()
endif()
endif()
if(WIN32)
- if(DEFINED IRRLICHT_DLL)
- install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
- endif()
- if(USE_GETTEXT)
- if(DEFINED GETTEXT_DLL)
- install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR})
+ if(NOT VCPKG_APPLOCAL_DEPS)
+ if(DEFINED IRRLICHT_DLL)
+ install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
endif()
- if(DEFINED GETTEXT_ICONV_DLL)
- install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR})
+ if(USE_GETTEXT)
+ if(DEFINED GETTEXT_DLL)
+ install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR})
+ endif()
+ if(DEFINED GETTEXT_ICONV_DLL)
+ install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR})
+ endif()
endif()
endif()
endif()