diff --git a/.gitignore b/.gitignore index 4c8c9f3..5098a54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ *~ -minetestmapper -minetestmapper.exe -colors.txt +/minetestmapper +/minetestmapper.exe +/colors.txt CMakeCache.txt CMakeFiles/ @@ -12,3 +12,4 @@ install_manifest.txt Makefile cmake_install.cmake cmake_config.h +compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index fc4b4bc..87f819d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ if(NOT CUSTOM_DOCDIR STREQUAL "") message(STATUS "Using DOCDIR=${DOCDIR}") endif() -set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # Libraries: gd @@ -146,19 +146,9 @@ endif(ENABLE_REDIS) # Compiling & Linking -include_directories( - "${PROJECT_BINARY_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/include" - "${CMAKE_CURRENT_BINARY_DIR}" - ${SQLITE3_INCLUDE_DIR} - ${LIBGD_INCLUDE_DIR} - ${ZLIB_INCLUDE_DIR} - ${ZSTD_INCLUDE_DIR} -) - configure_file( - "${PROJECT_SOURCE_DIR}/include/cmake_config.h.in" - "${PROJECT_BINARY_DIR}/cmake_config.h" + "${CMAKE_CURRENT_SOURCE_DIR}/src/cmake_config.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_config.h" ) add_definitions(-DUSE_CMAKE_CONFIG_H) @@ -166,29 +156,46 @@ 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) +elseif(MSVC) + add_compile_options(/GR- /Zl) endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") add_definitions(-DNDEBUG) endif() -add_executable(minetestmapper - BlockDecoder.cpp - PixelAttributes.cpp - PlayerAttributes.cpp - TileGenerator.cpp - ZlibDecompressor.cpp - ZstdDecompressor.cpp - Image.cpp - mapper.cpp - util.cpp - db-sqlite3.cpp - $<$:db-postgresql.cpp> - $<$:db-leveldb.cpp> - $<$:db-redis.cpp> +add_executable(minetestmapper) + +target_include_directories(minetestmapper PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_BINARY_DIR}" ) -target_link_libraries( - minetestmapper +target_sources(minetestmapper PRIVATE + src/BlockDecoder.cpp + src/PixelAttributes.cpp + src/PlayerAttributes.cpp + src/TileGenerator.cpp + src/ZlibDecompressor.cpp + src/ZstdDecompressor.cpp + src/Image.cpp + src/mapper.cpp + src/util.cpp + src/db-sqlite3.cpp + $<$:src/db-postgresql.cpp> + $<$:src/db-leveldb.cpp> + $<$:src/db-redis.cpp> +) + +target_include_directories(minetestmapper PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/src" + "${CMAKE_CURRENT_BINARY_DIR}" + ${SQLITE3_INCLUDE_DIR} + ${LIBGD_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIR} + ${ZSTD_INCLUDE_DIR} +) + +target_link_libraries(minetestmapper ${SQLITE3_LIBRARY} ${PostgreSQL_LIBRARIES} ${LEVELDB_LIBRARY} diff --git a/BlockDecoder.cpp b/src/BlockDecoder.cpp similarity index 100% rename from BlockDecoder.cpp rename to src/BlockDecoder.cpp diff --git a/include/BlockDecoder.h b/src/BlockDecoder.h similarity index 100% rename from include/BlockDecoder.h rename to src/BlockDecoder.h diff --git a/Image.cpp b/src/Image.cpp similarity index 100% rename from Image.cpp rename to src/Image.cpp diff --git a/include/Image.h b/src/Image.h similarity index 100% rename from include/Image.h rename to src/Image.h diff --git a/PixelAttributes.cpp b/src/PixelAttributes.cpp similarity index 100% rename from PixelAttributes.cpp rename to src/PixelAttributes.cpp diff --git a/include/PixelAttributes.h b/src/PixelAttributes.h similarity index 100% rename from include/PixelAttributes.h rename to src/PixelAttributes.h diff --git a/PlayerAttributes.cpp b/src/PlayerAttributes.cpp similarity index 100% rename from PlayerAttributes.cpp rename to src/PlayerAttributes.cpp diff --git a/include/PlayerAttributes.h b/src/PlayerAttributes.h similarity index 100% rename from include/PlayerAttributes.h rename to src/PlayerAttributes.h diff --git a/TileGenerator.cpp b/src/TileGenerator.cpp similarity index 100% rename from TileGenerator.cpp rename to src/TileGenerator.cpp diff --git a/include/TileGenerator.h b/src/TileGenerator.h similarity index 100% rename from include/TileGenerator.h rename to src/TileGenerator.h diff --git a/ZlibDecompressor.cpp b/src/ZlibDecompressor.cpp similarity index 100% rename from ZlibDecompressor.cpp rename to src/ZlibDecompressor.cpp diff --git a/include/ZlibDecompressor.h b/src/ZlibDecompressor.h similarity index 100% rename from include/ZlibDecompressor.h rename to src/ZlibDecompressor.h diff --git a/ZstdDecompressor.cpp b/src/ZstdDecompressor.cpp similarity index 100% rename from ZstdDecompressor.cpp rename to src/ZstdDecompressor.cpp diff --git a/include/ZstdDecompressor.h b/src/ZstdDecompressor.h similarity index 100% rename from include/ZstdDecompressor.h rename to src/ZstdDecompressor.h diff --git a/include/cmake_config.h.in b/src/cmake_config.h.in similarity index 100% rename from include/cmake_config.h.in rename to src/cmake_config.h.in diff --git a/include/config.h b/src/config.h similarity index 100% rename from include/config.h rename to src/config.h diff --git a/db-leveldb.cpp b/src/db-leveldb.cpp similarity index 100% rename from db-leveldb.cpp rename to src/db-leveldb.cpp diff --git a/include/db-leveldb.h b/src/db-leveldb.h similarity index 100% rename from include/db-leveldb.h rename to src/db-leveldb.h diff --git a/db-postgresql.cpp b/src/db-postgresql.cpp similarity index 100% rename from db-postgresql.cpp rename to src/db-postgresql.cpp diff --git a/include/db-postgresql.h b/src/db-postgresql.h similarity index 100% rename from include/db-postgresql.h rename to src/db-postgresql.h diff --git a/db-redis.cpp b/src/db-redis.cpp similarity index 100% rename from db-redis.cpp rename to src/db-redis.cpp diff --git a/include/db-redis.h b/src/db-redis.h similarity index 100% rename from include/db-redis.h rename to src/db-redis.h diff --git a/db-sqlite3.cpp b/src/db-sqlite3.cpp similarity index 100% rename from db-sqlite3.cpp rename to src/db-sqlite3.cpp diff --git a/include/db-sqlite3.h b/src/db-sqlite3.h similarity index 100% rename from include/db-sqlite3.h rename to src/db-sqlite3.h diff --git a/include/db.h b/src/db.h similarity index 100% rename from include/db.h rename to src/db.h diff --git a/mapper.cpp b/src/mapper.cpp similarity index 100% rename from mapper.cpp rename to src/mapper.cpp diff --git a/include/types.h b/src/types.h similarity index 100% rename from include/types.h rename to src/types.h diff --git a/util.cpp b/src/util.cpp similarity index 100% rename from util.cpp rename to src/util.cpp diff --git a/include/util.h b/src/util.h similarity index 100% rename from include/util.h rename to src/util.h