1
0
mirror of https://github.com/ScrelliCopter/tmx2gba.git synced 2025-02-21 03:29:25 +11:00

slightly simplify tmxlite subproject

This commit is contained in:
2024-03-28 21:42:00 +11:00
parent b06ad7cd79
commit 849ff6bcc8
4 changed files with 19 additions and 71 deletions

View File

@@ -1,40 +1,28 @@
project(tmxlite VERSION 1.3.1) project(tmxlite VERSION 1.3.1)
set(USE_RTTI TRUE CACHE BOOL "Use run time type information?")
# includes the list of source files in the src directory # includes the list of source files in the src directory
set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB PROJECT_SRC ${PROJECT_DIR}/*.cpp) file(GLOB PROJECT_SRC ${PROJECT_DIR}/*.cpp)
file(GLOB PROJECT_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp) file(GLOB PROJECT_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/tmxlite/*.hpp)
file(GLOB PROJECT_HEADERS_INL ${CMAKE_CURRENT_SOURCE_DIR}/include/*.inl) file(GLOB PROJECT_HEADERS_INL ${CMAKE_CURRENT_SOURCE_DIR}/include/tmxlite/*.inl)
file(GLOB PROJECT_HEADERS_DETAIL ${CMAKE_CURRENT_SOURCE_DIR}/include/detail/*.hpp) file(GLOB PROJECT_HEADERS_DETAIL ${CMAKE_CURRENT_SOURCE_DIR}/include/tmxlite/detail/*.hpp)
set(PROJECT_SRC ${PROJECT_SRC} ${PROJECT_HEADERS} ${PROJECT_HEADERS_INL} ${PROJECT_HEADERS_DETAIL}) list(APPEND PROJECT_SRC ${PROJECT_HEADERS} ${PROJECT_HEADERS_INL} ${PROJECT_HEADERS_DETAIL})
add_library(tmxlite STATIC ${PROJECT_SRC}) add_library(${PROJECT_NAME} STATIC ${PROJECT_SRC})
set_target_properties(tmxlite PROPERTIES set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 14 CXX_STANDARD 14
CXX_STANDARD_REQUIRED ON) CXX_STANDARD_REQUIRED ON)
target_compile_definitions(tmxlite PRIVATE $<$<CONFIG:Debug>:_DEBUG_> TMXLITE_STATIC) target_include_directories(${PROJECT_NAME} PUBLIC
target_compile_options(tmxlite PRIVATE -Wall) ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (NOT USE_RTTI AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
target_compile_options(tmxlite PRIVATE -fno-rtti)
endif()
# disable msvc warning target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
if (MSVC)
target_compile_definitions(tmxlite PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
target_compile_definitions(tmxlite PRIVATE USE_ZSTD) target_compile_definitions(${PROJECT_NAME} PRIVATE
target_link_libraries(tmxlite base64::base64 pugixml Zstd::Zstd) $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS> # disable msvc warning
$<$<TARGET_EXISTS:ZLIB::ZLIB>:USE_ZLIB>)
if (USE_ZLIB) target_link_libraries(${PROJECT_NAME} base64::base64 pugixml Zstd::Zstd
target_compile_definitions(tmxlite PRIVATE USE_ZLIB) $<$<TARGET_EXISTS:ZLIB::ZLIB>:ZLIB::ZLIB>
target_link_libraries(tmxlite ZLIB::ZLIB) $<$<TARGET_EXISTS:miniz::miniz>:miniz::miniz>)
else()
target_link_libraries(tmxlite miniz::miniz)
endif()
target_include_directories(tmxlite PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

View File

@@ -27,38 +27,5 @@ source distribution.
#pragma once #pragma once
//check which platform we're on and create export macros as necessary
#if !defined(TMXLITE_STATIC)
#if defined(_WIN32)
//windows compilers need specific (and different) keywords for export
#define TMXLITE_EXPORT_API __declspec(dllexport)
//for vc compilers we also need to turn off this annoying C4251 warning
#ifdef _MSC_VER
#pragma warning(disable: 4251)
#endif //_MSC_VER
#else //linux, FreeBSD, Mac OS X
#if __GNUC__ >= 4
//gcc 4 has special keywords for showing/hiding symbols,
//the same keyword is used for both importing and exporting
#define TMXLITE_EXPORT_API __attribute__ ((__visibility__ ("default")))
#else
//gcc < 4 has no mechanism to explicitly hide symbols, everything's exported
#define TMXLITE_EXPORT_API
#endif //__GNUC__
#endif //_WIN32
#else
//static build doesn't need import/export macros //static build doesn't need import/export macros
#define TMXLITE_EXPORT_API #define TMXLITE_EXPORT_API
#endif //TMXLITE_STATIC

View File

@@ -178,13 +178,13 @@ namespace tmx
} }
}; };
} }
#ifndef _DEBUG_ #ifdef NDEBUG
#define LOG(message, type) #define LOG(message, type)
#else #else
#define LOG(message, type) {\ #define LOG(message, type) {\
std::stringstream ss; \ std::stringstream ss; \
ss << message << " (" << __FILE__ << ", " << __LINE__ << ")"; \ ss << message << " (" << __FILE__ << ", " << __LINE__ << ")"; \
tmx::Logger::log(ss.str(), type);} tmx::Logger::log(ss.str(), type);}
#endif //_DEBUG_ #endif //NDEBUG
#endif //TMXLITE_LOGGER_HPP_ #endif //TMXLITE_LOGGER_HPP_

View File

@@ -26,9 +26,7 @@ source distribution.
*********************************************************************/ *********************************************************************/
#include <pugixml.hpp> #include <pugixml.hpp>
#ifdef USE_ZSTD #include <zstd.h>
# include <zstd.h>
#endif
#include "base64.h" #include "base64.h"
#include "tmxlite/FreeFuncs.hpp" #include "tmxlite/FreeFuncs.hpp"
#include "tmxlite/TileLayer.hpp" #include "tmxlite/TileLayer.hpp"
@@ -128,7 +126,6 @@ void TileLayer::parseBase64(const pugi::xml_node& node)
byteData.insert(byteData.end(), dataString.begin(), dataString.end()); byteData.insert(byteData.end(), dataString.begin(), dataString.end());
break; break;
case CompressionType::Zstd: case CompressionType::Zstd:
#if defined USE_ZSTD
{ {
std::size_t dataSize = dataString.length() * sizeof(unsigned char); std::size_t dataSize = dataString.length() * sizeof(unsigned char);
std::size_t result = ZSTD_decompress(byteData.data(), expectedSize, &dataString[0], dataSize); std::size_t result = ZSTD_decompress(byteData.data(), expectedSize, &dataString[0], dataSize);
@@ -140,10 +137,6 @@ void TileLayer::parseBase64(const pugi::xml_node& node)
} }
} }
break; break;
#else
Logger::log("Library must be built with USE_ZSTD for Zstd compression", Logger::Type::Error);
return {};
#endif
case CompressionType::GZip: case CompressionType::GZip:
#ifndef USE_ZLIB #ifndef USE_ZLIB
Logger::log("Library must be built with USE_ZLIB for GZip compression", Logger::Type::Error); Logger::log("Library must be built with USE_ZLIB for GZip compression", Logger::Type::Error);