mirror of
https://github.com/ScrelliCopter/tmx2gba.git
synced 2025-02-21 03:29:25 +11:00
first crack at making bundled dependencies optional
This commit is contained in:
8
.github/workflows/cmake.yml
vendored
8
.github/workflows/cmake.yml
vendored
@@ -3,6 +3,7 @@ name: CMake
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
|
- ".github/workflows/cmake.yml"
|
||||||
- "src/**"
|
- "src/**"
|
||||||
- "ext/**"
|
- "ext/**"
|
||||||
- "CMakeLists.txt"
|
- "CMakeLists.txt"
|
||||||
@@ -22,7 +23,7 @@ jobs:
|
|||||||
- { name: "Windows MSVC x86", os: windows-latest, artifact: windows-x86, arch: x86 }
|
- { name: "Windows MSVC x86", os: windows-latest, artifact: windows-x86, arch: x86 }
|
||||||
- { name: "Windows MSVC x64", os: windows-latest, artifact: windows-x64 }
|
- { name: "Windows MSVC x64", os: windows-latest, artifact: windows-x64 }
|
||||||
- { name: "Windows MSVC ARM64", os: windows-latest, artifact: windows-arm64, arch: amd64_arm64 }
|
- { name: "Windows MSVC ARM64", os: windows-latest, artifact: windows-arm64, arch: amd64_arm64 }
|
||||||
- { name: "Ubuntu", artifact: "linux", os: ubuntu-latest }
|
- { name: "Ubuntu", artifact: "linux", os: ubuntu-latest, extra: "-DUSE_BUNDLED_ZSTD:BOOL=OFF" }
|
||||||
runs-on: ${{matrix.config.os}}
|
runs-on: ${{matrix.config.os}}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -34,6 +35,11 @@ jobs:
|
|||||||
if: ${{startsWith(matrix.config.os, 'windows')}}
|
if: ${{startsWith(matrix.config.os, 'windows')}}
|
||||||
with:
|
with:
|
||||||
arch: ${{matrix.config.arch && matrix.config.arch || 'x64'}}
|
arch: ${{matrix.config.arch && matrix.config.arch || 'x64'}}
|
||||||
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
if: ${{matrix.config.artifact == 'linux'}}
|
||||||
|
with:
|
||||||
|
packages: libzstd-dev
|
||||||
|
version: 1.0
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: >-
|
run: >-
|
||||||
|
|||||||
@@ -5,7 +5,13 @@ project(tmx2gba
|
|||||||
HOMEPAGE_URL "https://github.com/ScrelliCopter/tmx2gba")
|
HOMEPAGE_URL "https://github.com/ScrelliCopter/tmx2gba")
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
option(USE_ZLIB "Use zlib instead of bundled miniz" "${UNIX}")
|
||||||
|
option(USE_BUNDLED_PUGIXML "Use bundled PUGIXML" ON)
|
||||||
|
option(USE_BUNDLED_ZSTD "Use bundled libzstd" ON)
|
||||||
|
option(USE_BUNDLED_TMXLITE "Use bundled tmxlite" ON)
|
||||||
|
|
||||||
option(TMX2GBA_DKP_INSTALL "Install into DEVKITPRO prefix" OFF)
|
option(TMX2GBA_DKP_INSTALL "Install into DEVKITPRO prefix" OFF)
|
||||||
|
|
||||||
option(ENABLE_ASAN "Enable address sanitiser" OFF)
|
option(ENABLE_ASAN "Enable address sanitiser" OFF)
|
||||||
|
|
||||||
if (ENABLE_ASAN)
|
if (ENABLE_ASAN)
|
||||||
@@ -13,12 +19,32 @@ if (ENABLE_ASAN)
|
|||||||
add_link_options(-fsanitize=address -shared-libasan)
|
add_link_options(-fsanitize=address -shared-libasan)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
|
||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
set(USE_ZSTD ON)
|
if (USE_BUNDLED_PUGIXML)
|
||||||
add_subdirectory(ext/miniz)
|
|
||||||
add_subdirectory(ext/pugixml)
|
add_subdirectory(ext/pugixml)
|
||||||
|
else()
|
||||||
|
find_package(PUGIXML REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (USE_ZLIB)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
else()
|
||||||
|
add_subdirectory(ext/miniz)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (USE_BUNDLED_ZSTD)
|
||||||
add_subdirectory(ext/zstd)
|
add_subdirectory(ext/zstd)
|
||||||
|
else()
|
||||||
|
find_package(ZSTD REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (USE_BUNDLED_TMXLITE)
|
||||||
add_subdirectory(ext/tmxlite)
|
add_subdirectory(ext/tmxlite)
|
||||||
|
else()
|
||||||
|
find_package(TMXLITE REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Main tmx2gba sources
|
# Main tmx2gba sources
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|||||||
@@ -17,35 +17,31 @@ set(PUGIXML_PUBLIC_DEFINITIONS
|
|||||||
$<$<BOOL:${PUGIXML_NO_STL}>:PUGIXML_NO_STL>
|
$<$<BOOL:${PUGIXML_NO_STL}>:PUGIXML_NO_STL>
|
||||||
$<$<BOOL:${PUGIXML_NO_EXCEPTIONS}>:PUGIXML_NO_EXCEPTIONS>)
|
$<$<BOOL:${PUGIXML_NO_EXCEPTIONS}>:PUGIXML_NO_EXCEPTIONS>)
|
||||||
|
|
||||||
add_library(pugixml-static STATIC
|
add_library(pugixml STATIC
|
||||||
${PROJECT_SOURCE_DIR}/src/pugixml.cpp)
|
src/pugiconfig.hpp
|
||||||
add_library(pugixml::static ALIAS pugixml-static)
|
src/pugixml.hpp
|
||||||
|
src/pugixml.cpp)
|
||||||
|
add_library(pugixml::static ALIAS pugixml)
|
||||||
|
|
||||||
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
|
set_target_properties(pugixml PROPERTIES
|
||||||
set_property(TARGET pugixml-static PROPERTY CXX_STANDARD_REQUIRED ON)
|
CXX_STANDARD_REQUIRED ON
|
||||||
endif()
|
CXX_STANDARD 11)
|
||||||
|
|
||||||
if (NOT DEFINED CMAKE_CXX_STANDARD)
|
set_property(TARGET pugixml PROPERTY EXPORT_NAME static)
|
||||||
set_property(TARGET pugixml-static PROPERTY CXX_STANDARD 11)
|
target_include_directories(pugixml PUBLIC
|
||||||
endif()
|
|
||||||
|
|
||||||
set_property(TARGET pugixml-static PROPERTY EXPORT_NAME static)
|
|
||||||
target_include_directories(pugixml-static PUBLIC
|
|
||||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
|
||||||
target_compile_definitions(pugixml-static PUBLIC
|
target_compile_definitions(pugixml PUBLIC
|
||||||
${PUGIXML_BUILD_DEFINES}
|
${PUGIXML_BUILD_DEFINES}
|
||||||
${PUGIXML_PUBLIC_DEFINITIONS})
|
${PUGIXML_PUBLIC_DEFINITIONS})
|
||||||
|
|
||||||
add_library(pugixml INTERFACE)
|
|
||||||
target_link_libraries(pugixml INTERFACE pugixml-static)
|
|
||||||
add_library(pugixml::pugixml ALIAS pugixml)
|
add_library(pugixml::pugixml ALIAS pugixml)
|
||||||
|
|
||||||
set_target_properties(pugixml-static PROPERTIES
|
set_target_properties(pugixml PROPERTIES
|
||||||
EXCLUDE_FROM_ALL ON
|
EXCLUDE_FROM_ALL ON
|
||||||
POSITION_INDEPENDENT_CODE ON
|
POSITION_INDEPENDENT_CODE ON
|
||||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
OUTPUT_NAME pugixml)
|
OUTPUT_NAME pugixml)
|
||||||
|
|
||||||
set_target_properties(pugixml-static PROPERTIES
|
set_target_properties(pugixml PROPERTIES
|
||||||
EXCLUDE_FROM_ALL OFF)
|
EXCLUDE_FROM_ALL OFF)
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
project(tmxlite VERSION 1.3.1)
|
project(tmxlite VERSION 1.3.1)
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
|
|
||||||
|
|
||||||
set(USE_RTTI TRUE CACHE BOOL "Use run time type information?")
|
set(USE_RTTI TRUE CACHE BOOL "Use run time type information?")
|
||||||
|
|
||||||
set(USE_EXTLIBS FALSE CACHE BOOL "Use external zlib, zstd and pugixml libraries instead of the included source?")
|
|
||||||
set(USE_ZSTD FALSE CACHE BOOL "Enable zstd compression? (Already set to true if USE_EXTLIBS is true)")
|
|
||||||
|
|
||||||
# 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_INL ${CMAKE_CURRENT_SOURCE_DIR}/include/*.inl)
|
||||||
|
file(GLOB PROJECT_HEADERS_DETAIL ${CMAKE_CURRENT_SOURCE_DIR}/include/detail/*.hpp)
|
||||||
|
set(PROJECT_SRC ${PROJECT_SRC} ${PROJECT_HEADERS} ${PROJECT_HEADERS_INL} ${PROJECT_HEADERS_DETAIL})
|
||||||
|
|
||||||
add_library(tmxlite STATIC ${PROJECT_SRC})
|
add_library(tmxlite STATIC ${PROJECT_SRC})
|
||||||
|
|
||||||
@@ -28,23 +27,26 @@ if (MSVC)
|
|||||||
target_compile_definitions(tmxlite PRIVATE _CRT_SECURE_NO_WARNINGS)
|
target_compile_definitions(tmxlite PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# if we want external zip and xml libs find them and tell the compiler
|
if (USE_BUNDLED_PUGIXML)
|
||||||
if (USE_EXTLIBS)
|
target_link_libraries(tmxlite pugixml::static)
|
||||||
find_package(ZLIB REQUIRED)
|
|
||||||
find_package(PUGIXML REQUIRED)
|
|
||||||
find_package(Zstd REQUIRED)
|
|
||||||
|
|
||||||
target_compile_definitions(tmxlite PRIVATE USE_EXTLIBS USE_ZSTD)
|
|
||||||
target_include_directories(tmxlite PRIVATE ${ZLIB_INCLUDE_DIRS} ${PUGIXML_INCLUDE_DIR} ${ZSTD_INCLUDE_DIR})
|
|
||||||
target_link_libraries(tmxlite ${ZLIB_LIBRARIES} ${PUGIXML_LIBRARY} ${ZSTD_LIBRARY})
|
|
||||||
else()
|
else()
|
||||||
# add miniz and pugixml from source
|
target_include_directories(tmxlite PRIVATE ${PUGIXML_INCLUDE_DIR})
|
||||||
target_link_libraries(tmxlite pugixml::static miniz::miniz)
|
target_link_libraries(tmxlite ZLIB::ZLIB ${PUGIXML_LIBRARY})
|
||||||
|
|
||||||
if (USE_ZSTD)
|
|
||||||
target_compile_definitions(tmxlite PRIVATE USE_ZSTD)
|
|
||||||
target_link_libraries(tmxlite zstd::static)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (USE_ZLIB)
|
||||||
|
target_compile_definitions(tmxlite PRIVATE USE_ZLIB)
|
||||||
|
target_link_libraries(tmxlite ZLIB::ZLIB)
|
||||||
|
else()
|
||||||
|
target_link_libraries(tmxlite miniz::miniz)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_definitions(tmxlite PRIVATE USE_ZSTD)
|
||||||
|
if (USE_BUNDLED_ZSTD)
|
||||||
|
target_link_libraries(tmxlite zstd::static)
|
||||||
|
else()
|
||||||
|
target_include_directories(tmxlite PRIVATE ${ZSTD_INCLUDE_DIR})
|
||||||
|
target_link_libraries(tmxlite ZLIB::ZLIB ${ZSTD_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(tmxlite PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
target_include_directories(tmxlite PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifndef USE_EXTLIBS
|
#ifndef USE_ZLIB
|
||||||
#include "miniz.h"
|
#include "miniz.h"
|
||||||
#else
|
#else
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
@@ -63,7 +63,7 @@ bool tmx::decompress(const char* source, std::vector<unsigned char>& dest, std::
|
|||||||
//to be incorrect in miniz. This is fine for zlib
|
//to be incorrect in miniz. This is fine for zlib
|
||||||
//compressed data, but gzip compressed streams
|
//compressed data, but gzip compressed streams
|
||||||
//will fail to inflate.
|
//will fail to inflate.
|
||||||
#ifdef USE_EXTLIBS
|
#ifdef USE_ZLIB
|
||||||
if (inflateInit2(&stream, 15 + 32) != Z_OK)
|
if (inflateInit2(&stream, 15 + 32) != Z_OK)
|
||||||
#else
|
#else
|
||||||
if (inflateInit(&stream) != Z_OK)
|
if (inflateInit(&stream) != Z_OK)
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/ImageLayer.hpp>
|
#include <tmxlite/ImageLayer.hpp>
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
#include <tmxlite/detail/Log.hpp>
|
#include <tmxlite/detail/Log.hpp>
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/LayerGroup.hpp>
|
#include <tmxlite/LayerGroup.hpp>
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
#include <tmxlite/ObjectGroup.hpp>
|
#include <tmxlite/ObjectGroup.hpp>
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/Map.hpp>
|
#include <tmxlite/Map.hpp>
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
#include <tmxlite/ObjectGroup.hpp>
|
#include <tmxlite/ObjectGroup.hpp>
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/Object.hpp>
|
#include <tmxlite/Object.hpp>
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
#include <tmxlite/Map.hpp>
|
#include <tmxlite/Map.hpp>
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
#include <tmxlite/ObjectGroup.hpp>
|
#include <tmxlite/ObjectGroup.hpp>
|
||||||
#include <tmxlite/detail/Log.hpp>
|
#include <tmxlite/detail/Log.hpp>
|
||||||
|
|||||||
@@ -24,11 +24,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
#include <tmxlite/ObjectTypes.hpp>
|
#include <tmxlite/ObjectTypes.hpp>
|
||||||
#include <tmxlite/detail/Log.hpp>
|
#include <tmxlite/detail/Log.hpp>
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/Property.hpp>
|
#include <tmxlite/Property.hpp>
|
||||||
#include <tmxlite/detail/Log.hpp>
|
#include <tmxlite/detail/Log.hpp>
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
|
|||||||
@@ -25,12 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#include <zstd.h>
|
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_ZSTD
|
#ifdef USE_ZSTD
|
||||||
#include <zstd.h>
|
#include <zstd.h>
|
||||||
@@ -135,7 +130,7 @@ 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 || defined USE_EXTLIBS
|
#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);
|
||||||
@@ -148,12 +143,12 @@ void TileLayer::parseBase64(const pugi::xml_node& node)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
Logger::log("Library must be built with USE_EXTLIBS or USE_ZSTD for Zstd compression", Logger::Type::Error);
|
Logger::log("Library must be built with USE_ZSTD for Zstd compression", Logger::Type::Error);
|
||||||
return {};
|
return {};
|
||||||
#endif
|
#endif
|
||||||
case CompressionType::GZip:
|
case CompressionType::GZip:
|
||||||
#ifndef USE_EXTLIBS
|
#ifndef USE_ZLIB
|
||||||
Logger::log("Library must be built with USE_EXTLIBS for GZip compression", Logger::Type::Error);
|
Logger::log("Library must be built with USE_ZLIB for GZip compression", Logger::Type::Error);
|
||||||
return {};
|
return {};
|
||||||
#endif
|
#endif
|
||||||
//[[fallthrough]];
|
//[[fallthrough]];
|
||||||
|
|||||||
@@ -25,11 +25,7 @@ and must not be misrepresented as being the original software.
|
|||||||
source distribution.
|
source distribution.
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
#ifdef USE_EXTLIBS
|
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#else
|
|
||||||
#include "detail/pugixml.hpp"
|
|
||||||
#endif
|
|
||||||
#include <tmxlite/Tileset.hpp>
|
#include <tmxlite/Tileset.hpp>
|
||||||
#include <tmxlite/FreeFuncs.hpp>
|
#include <tmxlite/FreeFuncs.hpp>
|
||||||
#include <tmxlite/detail/Log.hpp>
|
#include <tmxlite/detail/Log.hpp>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
#include <pugixml.hpp>
|
|
||||||
@@ -40,10 +40,6 @@ function (add_zstd_compilation_flags _target)
|
|||||||
target_link_options(${_target} PRIVATE -z noexecstack) # LDFLAGS
|
target_link_options(${_target} PRIVATE -z noexecstack) # LDFLAGS
|
||||||
target_compile_options(${_target} PRIVATE -Wunused-parameter -Wa,--noexecstack) # CFLAGS & CXXFLAGS
|
target_compile_options(${_target} PRIVATE -Wunused-parameter -Wa,--noexecstack) # CFLAGS & CXXFLAGS
|
||||||
elseif (MSVC)
|
elseif (MSVC)
|
||||||
set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)")
|
|
||||||
if (CMAKE_GENERATOR MATCHES "Visual Studio" AND ACTIVATE_MULTITHREADED_COMPILATION)
|
|
||||||
target_compile_options(${_target} PRIVATE "/MP")
|
|
||||||
endif ()
|
|
||||||
# UNICODE SUPPORT
|
# UNICODE SUPPORT
|
||||||
target_compile_definitions(${_target} PRIVATE _UNICODE UNICODE)
|
target_compile_definitions(${_target} PRIVATE _UNICODE UNICODE)
|
||||||
# Enable asserts in Debug mode
|
# Enable asserts in Debug mode
|
||||||
@@ -97,26 +93,12 @@ set(Headers
|
|||||||
${DictBuilderHeaders})
|
${DictBuilderHeaders})
|
||||||
|
|
||||||
if (ZSTD_LEGACY_SUPPORT)
|
if (ZSTD_LEGACY_SUPPORT)
|
||||||
set(LIBRARY_LEGACY_DIR ${LIBRARY_DIR}/legacy)
|
foreach (SOURCE zstd_v01.c zstd_v02.c zstd_v03.c zstd_v04.c zstd_v05.c zstd_v06.c zstd_v07.c)
|
||||||
|
list(APPEND Sources ${LIBRARY_DIR}/legacy/${SOURCE})
|
||||||
set(Sources ${Sources}
|
endforeach()
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v01.c
|
foreach (HEADER zstd_legacy.h zstd_v01.h zstd_v02.h zstd_v03.h zstd_v04.h zstd_v05.h zstd_v06.h zstd_v07.h)
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v02.c
|
list(APPEND Headers ${LIBRARY_DIR}/legacy/${HEADER})
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v03.c
|
endforeach()
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v04.c
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v05.c
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v06.c
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v07.c)
|
|
||||||
|
|
||||||
set(Headers ${Headers}
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_legacy.h
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v01.h
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v02.h
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v03.h
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v04.h
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v05.h
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v06.h
|
|
||||||
${LIBRARY_LEGACY_DIR}/zstd_v07.h)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Explicitly set the language to C for all files, including ASM files.
|
# Explicitly set the language to C for all files, including ASM files.
|
||||||
@@ -125,28 +107,28 @@ endif()
|
|||||||
# macros.
|
# macros.
|
||||||
set_source_files_properties(${Sources} PROPERTIES LANGUAGE C)
|
set_source_files_properties(${Sources} PROPERTIES LANGUAGE C)
|
||||||
|
|
||||||
add_library(libzstd_static STATIC ${Sources} ${Headers})
|
add_library(zstd STATIC ${Sources} ${Headers})
|
||||||
add_library(zstd::static ALIAS libzstd_static)
|
add_library(zstd::static ALIAS zstd)
|
||||||
|
|
||||||
add_zstd_compilation_flags(libzstd_static)
|
add_zstd_compilation_flags(zstd)
|
||||||
|
|
||||||
# Define library directory, where sources and header files are located
|
# Define library directory, where sources and header files are located
|
||||||
target_include_directories(libzstd_static PUBLIC ${LIBRARY_DIR})
|
target_include_directories(zstd PUBLIC ${LIBRARY_DIR})
|
||||||
target_include_directories(libzstd_static PRIVATE ${LIBRARY_DIR}/common)
|
target_include_directories(zstd PRIVATE ${LIBRARY_DIR}/common)
|
||||||
|
|
||||||
if (ZSTD_LEGACY_SUPPORT)
|
if (ZSTD_LEGACY_SUPPORT)
|
||||||
include_directories(${LIBRARY_LEGACY_DIR})
|
target_include_directories(zstd PRIVATE ${LIBRARY_DIR}/legacy)
|
||||||
target_compile_definitions(libzstd_static PRIVATE ZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_LEVEL})
|
target_compile_definitions(zstd PRIVATE ZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_LEVEL})
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(libzstd_static PRIVATE ZSTD_LEGACY_SUPPORT=0)
|
target_compile_definitions(zstd PRIVATE ZSTD_LEGACY_SUPPORT=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ZSTD_MULTITHREAD_SUPPORT)
|
if (ZSTD_MULTITHREAD_SUPPORT)
|
||||||
target_compile_definitions(libzstd_static PRIVATE ZSTD_MULTITHREAD)
|
target_compile_definitions(zstd PRIVATE ZSTD_MULTITHREAD)
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(libzstd_static Threads::Threads)
|
target_link_libraries(zstd Threads::Threads)
|
||||||
if (NOT CMAKE_USE_PTHREADS_INIT)
|
if (NOT CMAKE_USE_PTHREADS_INIT)
|
||||||
message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
|
message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
|
||||||
endif()
|
endif()
|
||||||
@@ -155,16 +137,8 @@ endif()
|
|||||||
|
|
||||||
# Add specific compile definitions for MSVC project
|
# Add specific compile definitions for MSVC project
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set(COMMON_DEFINITIONS ZSTD_DISABLE_ASM _CRT_SECURE_NO_WARNINGS)
|
target_compile_definitions(zstd PRIVATE ZSTD_HEAPMODE=0 ZSTD_DISABLE_ASM _CRT_SECURE_NO_WARNINGS)
|
||||||
target_compile_definitions(libzstd_static PRIVATE ZSTD_HEAPMODE=0 ${COMMON_DEFINITIONS})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Define static library names
|
# Define static library names
|
||||||
set_property(TARGET libzstd_static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
set_property(TARGET zstd PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
# With MSVC static library needs to be renamed to avoid conflict with import library
|
|
||||||
if (MSVC OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT MINGW))
|
|
||||||
set_property(TARGET libzstd_static PROPERTY OUTPUT_NAME zstd_static)
|
|
||||||
else()
|
|
||||||
set_property(TARGET libzstd_static PROPERTY OUTPUT_NAME zstd)
|
|
||||||
endif()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user