2021-03-29 14:58:56 +02:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
|
|
2021-08-27 17:24:24 +02:00
|
|
|
project(minetestmapper
|
|
|
|
VERSION 1.0
|
|
|
|
LANGUAGES CXX
|
|
|
|
)
|
2014-03-29 08:32:56 +01:00
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Stuff & Paths
|
2014-08-02 16:30:52 +02:00
|
|
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2016-10-11 03:34:33 +02:00
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
|
2014-08-02 16:30:52 +02:00
|
|
|
endif()
|
|
|
|
|
2020-03-26 23:07:27 +01:00
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
2021-08-27 17:24:24 +02:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2014-12-20 12:31:39 +01:00
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
if(WIN32)
|
|
|
|
set(SHAREDIR ".")
|
|
|
|
set(BINDIR ".")
|
|
|
|
set(DOCDIR ".")
|
|
|
|
else()
|
2024-11-11 09:50:26 +01:00
|
|
|
set(SHAREDIR "share/luanti") # reuse engine share dir
|
2021-08-27 17:24:24 +02:00
|
|
|
set(BINDIR "bin")
|
|
|
|
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
|
|
|
set(MANDIR "share/man")
|
2016-08-09 17:31:56 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
|
|
|
|
if(NOT CUSTOM_SHAREDIR STREQUAL "")
|
|
|
|
set(SHAREDIR "${CUSTOM_SHAREDIR}")
|
|
|
|
message(STATUS "Using SHAREDIR=${SHAREDIR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
|
|
|
|
if(NOT CUSTOM_BINDIR STREQUAL "")
|
|
|
|
set(BINDIR "${CUSTOM_BINDIR}")
|
|
|
|
message(STATUS "Using BINDIR=${BINDIR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
|
|
|
|
if(NOT CUSTOM_DOCDIR STREQUAL "")
|
|
|
|
set(DOCDIR "${CUSTOM_DOCDIR}")
|
|
|
|
message(STATUS "Using DOCDIR=${DOCDIR}")
|
|
|
|
endif()
|
|
|
|
|
2021-09-01 23:55:32 +02:00
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
2016-08-09 17:31:56 +02:00
|
|
|
|
|
|
|
# Libraries: gd
|
|
|
|
|
2014-03-09 12:18:48 +01:00
|
|
|
find_library(LIBGD_LIBRARY gd)
|
|
|
|
find_path(LIBGD_INCLUDE_DIR gd.h)
|
|
|
|
message (STATUS "libgd library: ${LIBGD_LIBRARY}")
|
|
|
|
message (STATUS "libgd headers: ${LIBGD_INCLUDE_DIR}")
|
|
|
|
if(NOT LIBGD_LIBRARY OR NOT LIBGD_INCLUDE_DIR)
|
|
|
|
message(FATAL_ERROR "libgd not found!")
|
|
|
|
endif(NOT LIBGD_LIBRARY OR NOT LIBGD_INCLUDE_DIR)
|
2012-08-23 12:55:31 +02:00
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Libraries: zlib
|
|
|
|
|
2021-03-29 14:58:56 +02:00
|
|
|
find_package(ZLIB REQUIRED)
|
2014-03-09 12:27:19 +01:00
|
|
|
|
2021-09-01 23:55:32 +02:00
|
|
|
# Libraries: zstd
|
|
|
|
|
|
|
|
find_package(Zstd REQUIRED)
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Libraries: sqlite3
|
|
|
|
|
2014-03-09 12:32:13 +01:00
|
|
|
find_library(SQLITE3_LIBRARY sqlite3)
|
2021-03-29 14:58:56 +02:00
|
|
|
find_path(SQLITE3_INCLUDE_DIR sqlite3.h)
|
2014-03-09 12:32:13 +01:00
|
|
|
message (STATUS "sqlite3 library: ${SQLITE3_LIBRARY}")
|
|
|
|
message (STATUS "sqlite3 headers: ${SQLITE3_INCLUDE_DIR}")
|
|
|
|
if(NOT SQLITE3_LIBRARY OR NOT SQLITE3_INCLUDE_DIR)
|
|
|
|
message(FATAL_ERROR "sqlite3 not found!")
|
|
|
|
endif(NOT SQLITE3_LIBRARY OR NOT SQLITE3_INCLUDE_DIR)
|
2012-09-01 15:51:02 +02:00
|
|
|
|
2017-01-08 23:24:09 +01:00
|
|
|
# Libraries: postgresql
|
|
|
|
|
|
|
|
option(ENABLE_POSTGRESQL "Enable PostgreSQL backend" TRUE)
|
2020-03-27 11:12:24 +01:00
|
|
|
set(USE_POSTGRESQL FALSE)
|
2017-01-08 23:24:09 +01:00
|
|
|
|
|
|
|
if(ENABLE_POSTGRESQL)
|
2021-08-27 17:24:24 +02:00
|
|
|
if(CMAKE_VERSION VERSION_LESS "3.20")
|
|
|
|
find_package(PostgreSQL QUIET)
|
|
|
|
# Before CMake 3.20 FindPostgreSQL.cmake always looked for server includes
|
|
|
|
# but we don't need them, so continue anyway if only those are missing.
|
|
|
|
if(PostgreSQL_INCLUDE_DIR AND PostgreSQL_LIBRARY)
|
|
|
|
set(PostgreSQL_FOUND TRUE)
|
|
|
|
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR})
|
2022-06-19 14:14:09 +02:00
|
|
|
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY})
|
2021-08-27 17:24:24 +02:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
find_package(PostgreSQL)
|
|
|
|
endif()
|
2017-01-08 23:24:09 +01:00
|
|
|
|
2020-03-27 11:12:24 +01:00
|
|
|
if(PostgreSQL_FOUND)
|
|
|
|
set(USE_POSTGRESQL TRUE)
|
2017-01-08 23:24:09 +01:00
|
|
|
message(STATUS "PostgreSQL backend enabled")
|
|
|
|
# This variable is case sensitive, don't try to change it to POSTGRESQL_INCLUDE_DIR
|
2020-03-27 11:12:24 +01:00
|
|
|
message(STATUS "PostgreSQL includes: ${PostgreSQL_INCLUDE_DIRS}")
|
|
|
|
include_directories(${PostgreSQL_INCLUDE_DIRS})
|
2017-01-08 23:24:09 +01:00
|
|
|
else()
|
2020-03-27 11:12:24 +01:00
|
|
|
message(STATUS "PostgreSQL not found!")
|
2020-03-27 16:27:55 +01:00
|
|
|
set(PostgreSQL_LIBRARIES "")
|
2017-01-08 23:24:09 +01:00
|
|
|
endif()
|
|
|
|
endif(ENABLE_POSTGRESQL)
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Libraries: leveldb
|
|
|
|
|
2020-03-27 11:12:24 +01:00
|
|
|
OPTION(ENABLE_LEVELDB "Enable LevelDB backend" TRUE)
|
|
|
|
set(USE_LEVELDB FALSE)
|
2014-03-05 21:41:27 +01:00
|
|
|
|
|
|
|
if(ENABLE_LEVELDB)
|
|
|
|
find_library(LEVELDB_LIBRARY leveldb)
|
2020-03-27 11:12:24 +01:00
|
|
|
find_path(LEVELDB_INCLUDE_DIR leveldb/db.h)
|
2014-03-05 21:41:27 +01:00
|
|
|
message (STATUS "LevelDB library: ${LEVELDB_LIBRARY}")
|
|
|
|
message (STATUS "LevelDB headers: ${LEVELDB_INCLUDE_DIR}")
|
|
|
|
if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
|
2020-03-27 11:12:24 +01:00
|
|
|
set(USE_LEVELDB TRUE)
|
2014-03-05 21:41:27 +01:00
|
|
|
message(STATUS "LevelDB backend enabled")
|
|
|
|
include_directories(${LEVELDB_INCLUDE_DIR})
|
2020-03-27 16:27:55 +01:00
|
|
|
else()
|
2014-03-05 21:41:27 +01:00
|
|
|
message(STATUS "LevelDB not found!")
|
2020-03-27 16:27:55 +01:00
|
|
|
set(LEVELDB_LIBRARY "")
|
|
|
|
endif()
|
2014-03-05 21:41:27 +01:00
|
|
|
endif(ENABLE_LEVELDB)
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Libraries: redis
|
|
|
|
|
2020-03-27 11:12:24 +01:00
|
|
|
OPTION(ENABLE_REDIS "Enable redis backend" TRUE)
|
|
|
|
set(USE_REDIS FALSE)
|
2014-04-26 15:01:35 +02:00
|
|
|
|
|
|
|
if(ENABLE_REDIS)
|
|
|
|
find_library(REDIS_LIBRARY hiredis)
|
2020-03-27 11:12:24 +01:00
|
|
|
find_path(REDIS_INCLUDE_DIR hiredis/hiredis.h)
|
2014-04-26 15:01:35 +02:00
|
|
|
message (STATUS "redis library: ${REDIS_LIBRARY}")
|
|
|
|
message (STATUS "redis headers: ${REDIS_INCLUDE_DIR}")
|
|
|
|
if(REDIS_LIBRARY AND REDIS_INCLUDE_DIR)
|
2020-03-27 11:12:24 +01:00
|
|
|
set(USE_REDIS TRUE)
|
2014-04-26 15:01:35 +02:00
|
|
|
message(STATUS "redis backend enabled")
|
|
|
|
include_directories(${REDIS_INCLUDE_DIR})
|
2020-03-27 16:27:55 +01:00
|
|
|
else()
|
2014-04-26 15:01:35 +02:00
|
|
|
message(STATUS "redis not found!")
|
2020-03-27 16:27:55 +01:00
|
|
|
set(REDIS_LIBRARY "")
|
|
|
|
endif()
|
2014-04-26 15:01:35 +02:00
|
|
|
endif(ENABLE_REDIS)
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Compiling & Linking
|
|
|
|
|
2012-08-22 15:22:01 +02:00
|
|
|
include_directories(
|
|
|
|
"${PROJECT_BINARY_DIR}"
|
2018-03-25 14:12:39 +02:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
2012-08-22 15:22:01 +02:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
2014-03-09 12:32:13 +01:00
|
|
|
${SQLITE3_INCLUDE_DIR}
|
2014-03-09 12:18:48 +01:00
|
|
|
${LIBGD_INCLUDE_DIR}
|
2014-03-09 12:27:19 +01:00
|
|
|
${ZLIB_INCLUDE_DIR}
|
2021-09-01 23:55:32 +02:00
|
|
|
${ZSTD_INCLUDE_DIR}
|
2012-08-22 15:22:01 +02:00
|
|
|
)
|
|
|
|
|
2014-03-05 21:41:27 +01:00
|
|
|
configure_file(
|
2018-03-25 14:12:39 +02:00
|
|
|
"${PROJECT_SOURCE_DIR}/include/cmake_config.h.in"
|
2014-03-05 21:41:27 +01:00
|
|
|
"${PROJECT_BINARY_DIR}/cmake_config.h"
|
2012-08-22 15:22:01 +02:00
|
|
|
)
|
2021-08-27 17:24:24 +02:00
|
|
|
add_definitions(-DUSE_CMAKE_CONFIG_H)
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g2")
|
|
|
|
add_compile_options(-Wall -pipe)
|
|
|
|
endif()
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
|
|
|
add_definitions(-DNDEBUG)
|
|
|
|
endif()
|
2012-08-22 15:22:01 +02:00
|
|
|
|
2021-08-27 17:24:24 +02:00
|
|
|
add_executable(minetestmapper
|
2018-03-25 15:19:48 +02:00
|
|
|
BlockDecoder.cpp
|
2012-08-25 13:19:58 +02:00
|
|
|
PixelAttributes.cpp
|
2012-09-01 16:40:18 +02:00
|
|
|
PlayerAttributes.cpp
|
2012-08-23 12:46:22 +02:00
|
|
|
TileGenerator.cpp
|
2012-09-18 10:43:34 +02:00
|
|
|
ZlibDecompressor.cpp
|
2021-09-01 23:55:32 +02:00
|
|
|
ZstdDecompressor.cpp
|
2016-11-18 23:34:31 +01:00
|
|
|
Image.cpp
|
2012-09-01 16:40:18 +02:00
|
|
|
mapper.cpp
|
2014-07-08 14:54:27 +02:00
|
|
|
util.cpp
|
2014-03-05 21:41:27 +01:00
|
|
|
db-sqlite3.cpp
|
2021-08-27 17:24:24 +02:00
|
|
|
$<$<BOOL:${USE_POSTGRESQL}>:db-postgresql.cpp>
|
|
|
|
$<$<BOOL:${USE_LEVELDB}>:db-leveldb.cpp>
|
|
|
|
$<$<BOOL:${USE_REDIS}>:db-redis.cpp>
|
2012-08-22 15:22:01 +02:00
|
|
|
)
|
2012-08-22 15:31:26 +02:00
|
|
|
|
|
|
|
target_link_libraries(
|
2013-07-29 18:16:08 +02:00
|
|
|
minetestmapper
|
2014-03-09 12:32:13 +01:00
|
|
|
${SQLITE3_LIBRARY}
|
2020-03-27 11:12:24 +01:00
|
|
|
${PostgreSQL_LIBRARIES}
|
2014-03-05 21:41:27 +01:00
|
|
|
${LEVELDB_LIBRARY}
|
2014-04-26 15:01:35 +02:00
|
|
|
${REDIS_LIBRARY}
|
2014-03-09 12:18:48 +01:00
|
|
|
${LIBGD_LIBRARY}
|
2014-03-09 12:27:19 +01:00
|
|
|
${ZLIB_LIBRARY}
|
2021-09-01 23:55:32 +02:00
|
|
|
${ZSTD_LIBRARY}
|
2012-08-22 15:31:26 +02:00
|
|
|
)
|
2014-03-29 08:32:56 +01:00
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Installing & Packaging
|
2014-03-29 08:32:56 +01:00
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
install(TARGETS "${PROJECT_NAME}" DESTINATION "${BINDIR}")
|
|
|
|
install(FILES "AUTHORS" DESTINATION "${DOCDIR}")
|
|
|
|
install(FILES "COPYING" DESTINATION "${DOCDIR}")
|
|
|
|
install(FILES "README.rst" DESTINATION "${DOCDIR}")
|
|
|
|
install(FILES "colors.txt" DESTINATION "${SHAREDIR}")
|
2017-01-17 17:49:15 +01:00
|
|
|
if(UNIX)
|
|
|
|
install(FILES "minetestmapper.6" DESTINATION "${MANDIR}/man6")
|
|
|
|
endif()
|
2014-03-29 08:32:56 +01:00
|
|
|
|
2024-11-11 09:50:26 +01:00
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Overview mapper for Luanti")
|
2014-03-29 08:32:56 +01:00
|
|
|
set(CPACK_PACKAGE_VENDOR "celeron55")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
|
|
|
|
|
|
|
|
if(WIN32)
|
2021-08-27 17:24:24 +02:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-win32")
|
2014-03-29 08:32:56 +01:00
|
|
|
set(CPACK_GENERATOR ZIP)
|
|
|
|
else()
|
2021-08-27 17:24:24 +02:00
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}-linux")
|
2014-03-29 08:32:56 +01:00
|
|
|
set(CPACK_GENERATOR TGZ)
|
|
|
|
set(CPACK_SOURCE_GENERATOR TGZ)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CPack)
|