Skip to content

Commit 43da43e

Browse files
authored
Merge pull request #183 from durkisneer1/master
Fix up build system and version numbering
2 parents 8f58c71 + 65a7799 commit 43da43e

5 files changed

Lines changed: 77 additions & 72 deletions

File tree

meson.build

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
11
project('tmxlite', 'cpp', 'c',
2-
version: '1.4.4',
3-
meson_version: '>=0.49.2',
2+
version: '1.4.5',
3+
meson_version: '>=1.0.0', # Earliest modern release that supports oldest supported Python (3.11)
44
default_options: [
5-
'buildtype=release',
6-
'cpp_std=c++14',
7-
'warning_level=3',
8-
'b_ndebug=if-release'
5+
'buildtype=release',
6+
# 'cpp_std=c++14',
7+
# 'c_std=c11',
8+
'warning_level=3',
9+
'b_ndebug=if-release',
910
]
1011
)
1112

1213
cpp = meson.get_compiler('cpp')
14+
if cpp.get_argument_syntax() != 'msvc' # msvc is being a dufus
15+
add_project_arguments('-std=c++14', language: ['cpp'])
16+
endif
17+
1318
if get_option('use_rtti')
1419
if cpp.get_argument_syntax() == 'gcc'
15-
if get_option('project_static_runtime')
16-
add_project_arguments('-static', language: ['cpp', 'c'])
17-
endif
20+
if get_option('project_static_runtime')
21+
add_project_arguments('-static', language: ['cpp', 'c'])
22+
endif
1823
endif
1924
else
2025
if cpp.get_argument_syntax() == 'gcc'
21-
if get_option('project_static_runtime')
22-
add_project_arguments('-fno-rtti', '-static', language: ['cpp', 'c'])
23-
else
24-
add_project_arguments('-fno-rtti', language: ['cpp', 'c'])
25-
endif
26+
if get_option('project_static_runtime')
27+
add_project_arguments('-fno-rtti', '-static', language: ['cpp', 'c'])
28+
else
29+
add_project_arguments('-fno-rtti', language: ['cpp', 'c'])
30+
endif
2631
endif
2732
endif
2833

2934
binary_postfix = ''
3035
if get_option('default_library') == 'static'
3136
if get_option('debug')
32-
add_project_arguments('-D_DEBUG_', '-DTMXLITE_STATIC', language: ['cpp', 'c'])
33-
binary_postfix = '-s-d'
37+
add_project_arguments('-D_DEBUG_', '-DTMXLITE_STATIC', language: ['cpp', 'c'])
38+
binary_postfix = '-s-d'
3439
else
35-
add_project_arguments('-O3', '-DTMXLITE_STATIC', language: ['cpp', 'c'])
36-
binary_postfix = '-s'
40+
add_project_arguments('-Doptimization=3', '-DTMXLITE_STATIC', language: ['cpp', 'c'])
41+
binary_postfix = '-s'
3742
endif
3843
elif get_option('default_library') == 'shared'
3944
if get_option('debug')
40-
add_project_arguments('-D_DEBUG_', language: ['cpp', 'c'])
41-
binary_postfix = '-d'
45+
add_project_arguments('-D_DEBUG_', language: ['cpp', 'c'])
46+
binary_postfix = '-d'
4247
else
43-
add_project_arguments('-O3', language: ['cpp', 'c'])
48+
add_project_arguments('-Doptimization=3', language: ['cpp', 'c'])
4449
endif
4550
else
4651
error('Unsupported option \'' + get_option('default_library') + '\' for project ' + meson.project_name())
@@ -67,6 +72,6 @@ if get_option('build_examples')
6772
subdir('OpenGLExample')
6873
subdir('SFMLExample')
6974
endif
70-
if get_option('build_tests')
71-
subdir('ParseTest')
75+
if get_option('build_tests')
76+
subdir('ParseTest')
7277
endif

tmxlite/CMakeLists.txt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
cmake_minimum_required(VERSION 3.5)
2-
project(tmxlite VERSION 1.4.4)
1+
cmake_minimum_required(VERSION 3.10)
2+
project(tmxlite VERSION 1.4.5)
33
SET(PROJECT_NAME tmxlite)
44

55
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
@@ -52,7 +52,7 @@ endif()
5252

5353
#disable msvc warning
5454
if(MSVC)
55-
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
55+
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
5656
endif()
5757

5858
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
@@ -64,37 +64,37 @@ include(${PROJECT_DIR}/CMakeLists.txt)
6464

6565
#if we want external zip and xml libs find them and tell the compiler
6666
if(USE_EXTLIBS)
67-
add_definitions(-DUSE_EXTLIBS)
67+
add_definitions(-DUSE_EXTLIBS)
68+
add_definitions(-DUSE_ZSTD)
69+
70+
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
71+
72+
find_package(ZLIB REQUIRED)
73+
find_package(PUGIXML REQUIRED)
74+
find_package(Zstd REQUIRED)
75+
76+
include_directories(${ZLIB_INCLUDE_DIRS} ${PUGIXML_INCLUDE_DIR} ${ZSTD_INCLUDE_DIR})
77+
78+
else()
79+
# add miniz and pugixml from source
80+
SET(PROJECT_SRC ${PROJECT_SRC} ${LIB_SRC})
81+
82+
if(USE_ZSTD)
6883
add_definitions(-DUSE_ZSTD)
69-
84+
7085
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
71-
72-
find_package(ZLIB REQUIRED)
73-
find_package(PUGIXML REQUIRED)
7486
find_package(Zstd REQUIRED)
75-
76-
include_directories(${ZLIB_INCLUDE_DIRS} ${PUGIXML_INCLUDE_DIR} ${ZSTD_INCLUDE_DIR})
77-
78-
else()
79-
#add miniz and pugixml from source
80-
SET(PROJECT_SRC ${PROJECT_SRC} ${LIB_SRC})
81-
82-
if(USE_ZSTD)
83-
add_definitions(-DUSE_ZSTD)
84-
85-
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
86-
find_package(Zstd REQUIRED)
87-
include_directories(${ZSTD_INCLUDE_DIR})
88-
endif()
89-
87+
include_directories(${ZSTD_INCLUDE_DIR})
88+
endif()
89+
9090
endif()
9191

9292
if(WIN32)
9393
if(TMXLITE_STATIC_LIB)
9494
add_library(${PROJECT_NAME} STATIC ${PROJECT_SRC})
9595
else()
9696
add_library(${PROJECT_NAME} SHARED ${PROJECT_SRC})
97-
endif()
97+
endif()
9898
else()
9999
if(TMXLITE_STATIC_LIB)
100100
add_library(${PROJECT_NAME} STATIC ${PROJECT_SRC})
@@ -104,11 +104,11 @@ else()
104104
endif()
105105

106106
if(USE_EXTLIBS)
107-
target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES} ${PUGIXML_LIBRARY} ${ZSTD_LIBRARY})
107+
target_link_libraries(${PROJECT_NAME} ${ZLIB_LIBRARIES} ${PUGIXML_LIBRARY} ${ZSTD_LIBRARY})
108108
else()
109-
if(USE_ZSTD)
110-
target_link_libraries(${PROJECT_NAME} ${ZSTD_LIBRARY})
111-
endif()
109+
if(USE_ZSTD)
110+
target_link_libraries(${PROJECT_NAME} ${ZSTD_LIBRARY})
111+
endif()
112112
endif()
113113

114114
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tmxlite.pc.in ${CMAKE_CURRENT_BINARY_DIR}/tmxlite.pc
@@ -121,7 +121,7 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/tmxlite DESTINATION ${CMAK
121121
if(TMXLITE_STATIC_LIB)
122122
install(TARGETS ${PROJECT_NAME} EXPORT tmxlite-targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
123123
else()
124-
install(TARGETS ${PROJECT_NAME} EXPORT tmxlite-targets
124+
install(TARGETS ${PROJECT_NAME} EXPORT tmxlite-targets
125125
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
126126
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
127127
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

tmxlite/include/tmxlite/Tileset.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ namespace tmx
109109
Vector2u imagePosition;
110110
std::string className;
111111
};
112-
112+
113113
/*!
114114
\brief Terrain information with which one
115115
or more tiles may be associated.
116116
*/
117117
struct Terrain final
118118
{
119119
std::string name;
120-
std::uint32_t tileID = -1;
120+
uint32_t tileID = static_cast<uint32_t>(-1);
121121
std::vector<Property> properties;
122122
};
123123

@@ -277,7 +277,7 @@ namespace tmx
277277
/*!
278278
\brief Checks if a tiled ID is in the range of the first ID and the last ID
279279
\param id Tile ID
280-
\return
280+
\return
281281
*/
282282
bool hasTile(std::uint32_t id) const { return id >= m_firstGID && id <= getLastGID(); };
283283

tmxlite/src/Map.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ bool Map::parseMapNode(const pugi::xml_node& mapNode)
113113
return reset();
114114
}
115115

116-
m_version.upper = STOI(attribString.substr(0, pointPos));
117-
m_version.lower = STOI(attribString.substr(pointPos + 1));
116+
m_version.upper = static_cast<uint16_t>(STOI(attribString.substr(0, pointPos)));
117+
m_version.lower = static_cast<uint16_t>(STOI(attribString.substr(pointPos + 1)));
118118

119119
m_class = mapNode.attribute("class").as_string();
120120

tmxlite/src/Tileset.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,49 +182,49 @@ bool Tileset::parse(pugi::xml_node node, Map* map)
182182
}
183183

184184
const auto& children = node.children();
185-
for (const auto& node : children)
185+
for (const auto& childNode : children)
186186
{
187-
std::string name = node.name();
187+
std::string name = childNode.name();
188188
if (name == "image")
189189
{
190190
//TODO this currently doesn't cover embedded images
191191
//mostly because I can't figure out how to export them
192192
//from the Tiled editor... but also resource handling
193193
//should be handled by the renderer, not the parser.
194-
attribString = node.attribute("source").as_string();
194+
attribString = childNode.attribute("source").as_string();
195195
if (attribString.empty())
196196
{
197197
Logger::log("Tileset image node has missing source property, tile set not loaded", Logger::Type::Error);
198198
return reset();
199199
}
200200
m_imagePath = resolveFilePath(attribString, m_workingDir);
201-
if (node.attribute("trans"))
201+
if (childNode.attribute("trans"))
202202
{
203-
attribString = node.attribute("trans").as_string();
203+
attribString = childNode.attribute("trans").as_string();
204204
m_transparencyColour = colourFromString(attribString);
205205
m_hasTransparency = true;
206206
}
207-
if (node.attribute("width") && node.attribute("height"))
207+
if (childNode.attribute("width") && childNode.attribute("height"))
208208
{
209-
m_imageSize.x = node.attribute("width").as_int();
210-
m_imageSize.y = node.attribute("height").as_int();
209+
m_imageSize.x = childNode.attribute("width").as_int();
210+
m_imageSize.y = childNode.attribute("height").as_int();
211211
}
212212
}
213213
else if (name == "tileoffset")
214214
{
215-
parseOffsetNode(node);
215+
parseOffsetNode(childNode);
216216
}
217217
else if (name == "properties")
218218
{
219-
parsePropertyNode(node);
219+
parsePropertyNode(childNode);
220220
}
221221
else if (name == "terraintypes")
222222
{
223-
parseTerrainNode(node);
223+
parseTerrainNode(childNode);
224224
}
225225
else if (name == "tile")
226226
{
227-
parseTileNode(node, map);
227+
parseTileNode(childNode, map);
228228
}
229229
}
230230

@@ -252,7 +252,7 @@ const Tileset::Tile* Tileset::getTile(std::uint32_t id) const
252252
{
253253
return nullptr;
254254
}
255-
255+
256256
//corrects the ID. Indices and IDs are different.
257257
id -= m_firstGID;
258258
id = m_tileIndex[id];
@@ -382,12 +382,12 @@ void Tileset::parseTileNode(const pugi::xml_node& node, Map* map)
382382
{
383383
tile.className = node.attribute("class").as_string();
384384
}
385-
385+
386386
//by default we set the tile's values as in an Image tileset
387387
tile.imagePath = m_imagePath;
388388
tile.imageSize = m_tileSize;
389389

390-
if (m_columnCount != 0)
390+
if (m_columnCount != 0)
391391
{
392392
std::uint32_t rowIndex = tile.ID % m_columnCount;
393393
std::uint32_t columnIndex = tile.ID / m_columnCount;

0 commit comments

Comments
 (0)