2012-10-14 00:46:26 -07:00
|
|
|
project(MinetestMapper C CXX)
|
2012-08-22 06:22:01 -07:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
cmake_policy(SET CMP0003 NEW)
|
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
|
|
|
|
2014-03-05 07:39:35 -08:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++0x -Wall -DNDEBUG")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -std=c++0x -Wall -Wextra -DDEBUG")
|
2012-08-23 03:55:31 -07:00
|
|
|
|
2014-03-09 04:18:48 -07:00
|
|
|
# Find libgd
|
|
|
|
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 03:55:31 -07:00
|
|
|
|
2014-03-09 04:27:19 -07:00
|
|
|
# Find zlib
|
|
|
|
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 06:31:26 -07:00
|
|
|
find_package(PkgConfig)
|
2012-08-23 05:21:34 -07:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
2014-03-09 04:18:48 -07:00
|
|
|
# Find libsqlite3
|
2014-03-09 04:32:13 -07: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 06:51:02 -07:00
|
|
|
|
2014-03-09 04:18:48 -07:00
|
|
|
# Find leveldb
|
2014-03-05 12:41:27 -08: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)
|
|
|
|
|
2014-03-09 04:18:48 -07:00
|
|
|
# Find xxd
|
2012-09-01 06:51:02 -07:00
|
|
|
find_program(XXD_EXECUTABLE xxd)
|
|
|
|
|
|
|
|
if (XXD_EXECUTABLE)
|
|
|
|
message(STATUS "Found xxd")
|
|
|
|
else (XXD_EXECUTABLE)
|
2014-03-05 07:39:35 -08:00
|
|
|
message(FATAL_ERROR "xxd not found")
|
2012-09-01 06:51:02 -07:00
|
|
|
endif (XXD_EXECUTABLE)
|
|
|
|
|
2014-03-09 04:18:48 -07:00
|
|
|
# Add command to turn colors.txt into a C header file
|
2012-09-01 06:51:02 -07:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT colors.h
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/colors.txt colors.txt
|
|
|
|
COMMAND xxd -i colors.txt colors.h
|
|
|
|
DEPENDS colors.txt
|
|
|
|
)
|
|
|
|
set_property(SOURCE TileGenerator.cpp APPEND PROPERTY OBJECT_DEPENDS colors.h)
|
2012-08-22 06:31:26 -07:00
|
|
|
|
2012-08-22 06:22:01 -07:00
|
|
|
include_directories(
|
|
|
|
"${PROJECT_BINARY_DIR}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
2014-03-09 04:32:13 -07:00
|
|
|
${SQLITE3_INCLUDE_DIR}
|
2014-03-09 04:18:48 -07:00
|
|
|
${LIBGD_INCLUDE_DIR}
|
2014-03-09 04:27:19 -07:00
|
|
|
${ZLIB_INCLUDE_DIR}
|
2012-08-22 06:22:01 -07:00
|
|
|
)
|
|
|
|
|
2014-03-05 12:41:27 -08:00
|
|
|
configure_file(
|
|
|
|
"${PROJECT_SOURCE_DIR}/cmake_config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/cmake_config.h"
|
2012-08-22 06:22:01 -07:00
|
|
|
)
|
2014-03-05 12:41:27 -08:00
|
|
|
add_definitions ( -DUSE_CMAKE_CONFIG_H )
|
2012-08-22 06:22:01 -07:00
|
|
|
|
|
|
|
set(mapper_SRCS
|
2012-08-25 04:19:58 -07:00
|
|
|
PixelAttributes.cpp
|
2012-09-01 07:40:18 -07:00
|
|
|
PlayerAttributes.cpp
|
2012-08-23 03:46:22 -07:00
|
|
|
TileGenerator.cpp
|
2012-09-18 01:43:34 -07:00
|
|
|
ZlibDecompressor.cpp
|
2012-09-01 07:40:18 -07:00
|
|
|
mapper.cpp
|
2014-03-05 12:41:27 -08:00
|
|
|
db-sqlite3.cpp
|
2012-08-22 06:22:01 -07:00
|
|
|
)
|
|
|
|
|
2014-03-05 12:41:27 -08:00
|
|
|
if(USE_LEVELDB)
|
|
|
|
set(mapper_SRCS ${mapper_SRCS} db-leveldb.cpp)
|
|
|
|
endif(USE_LEVELDB)
|
|
|
|
|
2013-07-29 09:16:08 -07:00
|
|
|
add_executable(minetestmapper
|
2012-08-22 06:22:01 -07:00
|
|
|
${mapper_SRCS}
|
|
|
|
)
|
2012-08-22 06:31:26 -07:00
|
|
|
|
|
|
|
target_link_libraries(
|
2013-07-29 09:16:08 -07:00
|
|
|
minetestmapper
|
2014-03-09 04:32:13 -07:00
|
|
|
${SQLITE3_LIBRARY}
|
2014-03-05 12:41:27 -08:00
|
|
|
${LEVELDB_LIBRARY}
|
2014-03-09 04:18:48 -07:00
|
|
|
${LIBGD_LIBRARY}
|
2014-03-09 04:27:19 -07:00
|
|
|
${ZLIB_LIBRARY}
|
2012-08-22 06:31:26 -07:00
|
|
|
)
|