2014-04-07 04:25:32 +02:00
|
|
|
project(minetestmapper CXX)
|
2012-08-22 15:22:01 +02:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
cmake_policy(SET CMP0003 NEW)
|
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
|
|
|
|
2014-03-29 08:32:56 +01:00
|
|
|
set(VERSION_MAJOR 1)
|
|
|
|
set(VERSION_MINOR 0)
|
|
|
|
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}")
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Stuff & Paths
|
2014-08-02 16:30:52 +02:00
|
|
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.")
|
|
|
|
endif()
|
|
|
|
|
2014-12-20 12:31:39 +01:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g2 -Wall")
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
if(WIN32)
|
|
|
|
set(SHAREDIR ".")
|
|
|
|
set(BINDIR ".")
|
|
|
|
set(DOCDIR ".")
|
|
|
|
else()
|
|
|
|
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/minetest") # an extra dir. for just one file doesn't seem useful
|
|
|
|
set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
|
|
|
|
set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2014-03-09 12:27:19 +01:00
|
|
|
find_library(ZLIB_LIBRARY z)
|
|
|
|
find_path(ZLIB_INCLUDE_DIR zlib.h)
|
|
|
|
message (STATUS "zlib library: ${ZLIB_LIBRARY}")
|
|
|
|
message (STATUS "zlib headers: ${ZLIB_INCLUDE_DIR}")
|
|
|
|
if(NOT ZLIB_LIBRARY OR NOT ZLIB_INCLUDE_DIR)
|
|
|
|
message(FATAL_ERROR "zlib not found!")
|
|
|
|
endif(NOT ZLIB_LIBRARY OR NOT ZLIB_INCLUDE_DIR)
|
|
|
|
|
2012-08-22 15:31:26 +02:00
|
|
|
find_package(PkgConfig)
|
2012-08-23 14:21:34 +02:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Libraries: sqlite3
|
|
|
|
|
2014-03-09 12:32:13 +01:00
|
|
|
find_library(SQLITE3_LIBRARY sqlite3)
|
|
|
|
find_path(SQLITE3_INCLUDE_DIR zlib.h)
|
|
|
|
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
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Libraries: leveldb
|
|
|
|
|
2014-03-05 21:41:27 +01:00
|
|
|
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)
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Libraries: redis
|
|
|
|
|
2014-04-26 15:01:35 +02:00
|
|
|
set(USE_REDIS 0)
|
|
|
|
|
|
|
|
OPTION(ENABLE_REDIS "Enable redis backend")
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2016-08-09 17:31:56 +02:00
|
|
|
# Compiling & Linking
|
|
|
|
|
2012-08-22 15:22:01 +02:00
|
|
|
include_directories(
|
|
|
|
"${PROJECT_BINARY_DIR}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
"${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}
|
2012-08-22 15:22:01 +02:00
|
|
|
)
|
|
|
|
|
2014-03-05 21:41:27 +01:00
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/cmake_config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/cmake_config.h"
|
2012-08-22 15:22:01 +02:00
|
|
|
)
|
2014-03-05 21:41:27 +01:00
|
|
|
add_definitions ( -DUSE_CMAKE_CONFIG_H )
|
2012-08-22 15:22:01 +02:00
|
|
|
|
|
|
|
set(mapper_SRCS
|
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
|
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
|
2012-08-22 15:22:01 +02:00
|
|
|
)
|
|
|
|
|
2014-03-05 21:41:27 +01:00
|
|
|
if(USE_LEVELDB)
|
|
|
|
set(mapper_SRCS ${mapper_SRCS} db-leveldb.cpp)
|
|
|
|
endif(USE_LEVELDB)
|
|
|
|
|
2014-04-26 15:01:35 +02:00
|
|
|
if(USE_REDIS)
|
|
|
|
set(mapper_SRCS ${mapper_SRCS} db-redis.cpp)
|
|
|
|
endif(USE_REDIS)
|
|
|
|
|
2013-07-29 18:16:08 +02:00
|
|
|
add_executable(minetestmapper
|
2012-08-22 15:22:01 +02:00
|
|
|
${mapper_SRCS}
|
|
|
|
)
|
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}
|
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}
|
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}")
|
2014-03-29 08:32:56 +01:00
|
|
|
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Overview mapper for Minetest")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
|
|
|
|
set(CPACK_PACKAGE_VENDOR "celeron55")
|
|
|
|
set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
|
|
|
|
set(CPACK_GENERATOR ZIP)
|
|
|
|
else()
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
|
|
|
|
set(CPACK_GENERATOR TGZ)
|
|
|
|
set(CPACK_SOURCE_GENERATOR TGZ)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(CPack)
|