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

MSVC build fix & buildsystem overhaul

This commit is contained in:
2022-09-07 00:11:11 +10:00
parent aa52d09649
commit 8a5f397f26
28 changed files with 85 additions and 447 deletions

11
.gitignore vendored
View File

@@ -27,7 +27,7 @@
*.out *.out
*.app *.app
# VS rubbish. # VS rubbish
Debug/ Debug/
Release/ Release/
*.opensdf *.opensdf
@@ -35,7 +35,14 @@ Release/
*.v12.suo *.v12.suo
*.vcxproj.user *.vcxproj.user
# Some files I used for testing. # CLion Rubbish
.idea/
# CMake Rubbish
build/
cmake-build-*/
# Some files I used for testing
*.tmx *.tmx
*.raw *.raw
plains.png plains.png

View File

@@ -1,42 +1,29 @@
# tmx2gba - CMakeLists.txt cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
# Copyright (C) 2018 Nicholas Curtis (a dinosaur)
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
cmake_minimum_required(VERSION 3.10)
project(tmx2gba) project(tmx2gba)
# C++11 & C99
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 99)
include_directories(inc) # Enable strong warnings
set(SOURCES if (MSVC)
src/tmx2gba.cpp string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
src/tmxlayer.cpp src/tmxlayer.h string(REPLACE "/W3" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
src/tmxobject.cpp src/tmxobject.h else()
src/tmxreader.cpp src/tmxreader.h add_compile_options(-Wall)
src/tmxtileset.cpp src/tmxtileset.h endif()
src/ultragetopt.c inc/ultragetopt.h # Libraries
src/base64.cpp inc/base64.h add_subdirectory(ext/base64)
inc/miniz.h add_subdirectory(ext/miniz)
add_subdirectory(ext/rapidxml)
add_subdirectory(ext/ultragetopt)
inc/rapidxml/rapidxml.hpp # Main tmx2gba sources
inc/rapidxml/rapidxml_iterators.hpp add_subdirectory(src)
inc/rapidxml/rapidxml_print.hpp
inc/rapidxml/rapidxml_utils.hpp)
add_executable(tmx2gba ${SOURCES}) if (MSVC)
# Default to tmx2gba as startup project when generating Solutions
set_property(DIRECTORY ${CMAKE_SOURCE_DIR}
PROPERTY VS_STARTUP_PROJECT tmx2gba)
endif()

View File

@@ -61,7 +61,7 @@ sudo cp tmx2gba $DEVKITPRO/tools/bin/tmx2gba
[ultragetopt](https://github.com/kevinoid/ultragetopt) is licensed under the MIT license. [ultragetopt](https://github.com/kevinoid/ultragetopt) is licensed under the MIT license.
``` ```
Copyright (C) 2015-2019 Nicholas Curtis (a dinosaur) Copyright (C) 2015-2022 a dinosaur
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -0,0 +1,5 @@
add_library(base64
base64.cpp base64.h)
add_library(External::base64 ALIAS base64)
target_include_directories(base64
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

4
ext/miniz/CMakeLists.txt Normal file
View File

@@ -0,0 +1,4 @@
add_library(miniz INTERFACE)
add_library(External::miniz ALIAS miniz)
target_include_directories(miniz
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@@ -0,0 +1,4 @@
add_library(rapidxml INTERFACE)
add_library(External::rapidxml ALIAS rapidxml)
target_include_directories(rapidxml
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@@ -0,0 +1,22 @@
include(CheckIncludeFile)
include(CheckFunctionExists)
check_include_file(strings.h HAVE_STRINGS_H)
check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(_stricmp HAVE__STRICMP)
check_function_exists(strncasecmp HAVE_STRNCASECMP)
check_function_exists(_strnicmp HAVE__STRNICMP)
add_library(ultragetopt
ultragetopt.c ultragetopt.h)
add_library(External::ultragetopt ALIAS ultragetopt)
target_include_directories(ultragetopt
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(ultragetopt PRIVATE
$<$<BOOL:${HAVE_STRINGS_H}>:HAVE_STRINGS_H=1>
$<$<BOOL:${HAVE_STRCASECMP}>:HAVE_STRCASECMP=1>
$<$<BOOL:${HAVE__STRICMP}>:HAVE__STRICMP=1>
$<$<BOOL:${HAVE_STRNCASECMP}>:HAVE_STRNCASECMP=1>
$<$<BOOL:${HAVE__STRNICMP}>:HAVE__STRNICMP=1>)

11
src/CMakeLists.txt Normal file
View File

@@ -0,0 +1,11 @@
add_executable(tmx2gba
tmx2gba.cpp
tmxlayer.cpp tmxlayer.h
tmxobject.cpp tmxobject.h
tmxreader.cpp tmxreader.h
tmxtileset.cpp tmxtileset.h)
target_link_libraries(tmx2gba
External::base64
External::miniz
External::rapidxml
External::ultragetopt)

View File

@@ -1,212 +0,0 @@
// XGetopt.cpp Version 1.2
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// Description:
// XGetopt.cpp implements getopt(), a function to parse command lines.
//
// History
// Version 1.2 - 2003 May 17
// - Added Unicode support
//
// Version 1.1 - 2002 March 10
// - Added example to XGetopt.cpp module header
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// if you are not using precompiled headers then include these lines:
#include <stdio.h>
#include <string.h>
///////////////////////////////////////////////////////////////////////////////
#include "XGetopt.h"
///////////////////////////////////////////////////////////////////////////////
//
// X G e t o p t . c p p
//
//
// NAME
// getopt -- parse command line options
//
// SYNOPSIS
// int getopt(int argc, char *argv[], char *optstring)
//
// extern char *optarg;
// extern int optind;
//
// DESCRIPTION
// The getopt() function parses the command line arguments. Its
// arguments argc and argv are the argument count and array as
// passed into the application on program invocation. In the case
// of Visual C++ programs, argc and argv are available via the
// variables __argc and __argv (double underscores), respectively.
// getopt returns the next option letter in argv that matches a
// letter in optstring. (Note: Unicode programs should use
// __targv instead of __argv. Also, all character and string
// literals should be enclosed in _T( ) ).
//
// optstring is a string of recognized option letters; if a letter
// is followed by a colon, the option is expected to have an argument
// that may or may not be separated from it by white space. optarg
// is set to point to the start of the option argument on return from
// getopt.
//
// Option letters may be combined, e.g., "-ab" is equivalent to
// "-a -b". Option letters are case sensitive.
//
// getopt places in the external variable optind the argv index
// of the next argument to be processed. optind is initialized
// to 0 before the first call to getopt.
//
// When all options have been processed (i.e., up to the first
// non-option argument), getopt returns EOF, optarg will point
// to the argument, and optind will be set to the argv index of
// the argument. If there are no non-option arguments, optarg
// will be set to nullptr.
//
// The special option "--" may be used to delimit the end of the
// options; EOF will be returned, and "--" (and everything after it)
// will be skipped.
//
// RETURN VALUE
// For option letters contained in the string optstring, getopt
// will return the option letter. getopt returns a question mark (?)
// when it encounters an option letter not included in optstring.
// EOF is returned when processing is finished.
//
// BUGS
// 1) Long options are not supported.
// 2) The GNU double-colon extension is not supported.
// 3) The environment variable POSIXLY_CORRECT is not supported.
// 4) The + syntax is not supported.
// 5) The automatic permutation of arguments is not supported.
// 6) This implementation of getopt() returns EOF if an error is
// encountered, instead of -1 as the latest standard requires.
//
// EXAMPLE
// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[])
// {
// int c;
//
// while ((c = getopt(argc, argv, _T("aBn:"))) != EOF)
// {
// switch (c)
// {
// case _T('a'):
// TRACE(_T("option a\n"));
// //
// // set some flag here
// //
// break;
//
// case _T('B'):
// TRACE( _T("option B\n"));
// //
// // set some other flag here
// //
// break;
//
// case _T('n'):
// TRACE(_T("option n: value=%d\n"), atoi(optarg));
// //
// // do something with value here
// //
// break;
//
// case _T('?'):
// TRACE(_T("ERROR: illegal option %s\n"), argv[optind-1]);
// return FALSE;
// break;
//
// default:
// TRACE(_T("WARNING: no handler for option %c\n"), c);
// return FALSE;
// break;
// }
// }
// //
// // check for non-option args here
// //
// return TRUE;
// }
//
///////////////////////////////////////////////////////////////////////////////
char *optarg; // global argument pointer
char *next;
int optind = 0; // global argv index
int getopt(int argc, char *argv[], char *optstring)
{
if (optind == 0)
next = nullptr;
optarg = nullptr;
if (next == nullptr || *next == '\0')
{
if (optind == 0)
optind++;
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
{
optarg = nullptr;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
if (strcmp(argv[optind], "--") == 0)
{
optind++;
optarg = nullptr;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
next = argv[optind];
next++; // skip past -
optind++;
}
char c = *next++;
char *cp = strchr(optstring, c);
if (cp == nullptr || c == ':')
return '?';
cp++;
if (*cp == ':')
{
if (*next != '\0')
{
optarg = next;
next = nullptr;
}
else if (optind < argc)
{
optarg = argv[optind];
optind++;
}
else
{
return '?';
}
}
return c;
}

View File

@@ -1,6 +1,6 @@
/* tmx2gba.cpp /* tmx2gba.cpp
Copyright (C) 2015-2019 Nicholas Curtis (a dinosaur) Copyright (C) 2015-2022 a dinosaur
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* tmxlayer.cpp /* tmxlayer.cpp
Copyright (C) 2015 Nicholas Curtis Copyright (C) 2015 a dinosaur
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* tmxobject.cpp /* tmxobject.cpp
Copyright (C) 2015 Nicholas Curtis Copyright (C) 2015 a dinosaur
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* tmxreader.cpp /* tmxreader.cpp
Copyright (C) 2015 Nicholas Curtis Copyright (C) 2015 a dinosaur
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -27,7 +27,7 @@
#include <cstdint> #include <cstdint>
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <rapidxml/rapidxml.hpp> #include <rapidxml.hpp>
#include <base64.h> #include <base64.h>
#include <miniz.h> #include <miniz.h>

View File

@@ -5,7 +5,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <cstdint> #include <cstdint>
#include <rapidxml/rapidxml.hpp> #include <rapidxml.hpp>
class CTmxTileset; class CTmxTileset;
class CTmxLayer; class CTmxLayer;

View File

@@ -1,6 +1,6 @@
/* tmxtileset.cpp /* tmxtileset.cpp
Copyright (C) 2015 Nicholas Curtis Copyright (C) 2015 a dinosaur
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,22 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tmx2gba", "tmx2gba.vcxproj", "{F8167A3B-4B77-4449-B730-F19ECB133A08}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F8167A3B-4B77-4449-B730-F19ECB133A08}.Debug|Win32.ActiveCfg = Debug|Win32
{F8167A3B-4B77-4449-B730-F19ECB133A08}.Debug|Win32.Build.0 = Debug|Win32
{F8167A3B-4B77-4449-B730-F19ECB133A08}.Release|Win32.ActiveCfg = Release|Win32
{F8167A3B-4B77-4449-B730-F19ECB133A08}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,93 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F8167A3B-4B77-4449-B730-F19ECB133A08}</ProjectGuid>
<RootNamespace>tmx2gba</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>inc\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>inc\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\base64.cpp" />
<ClCompile Include="src\tmx2gba.cpp" />
<ClCompile Include="src\tmxlayer.cpp" />
<ClCompile Include="src\tmxobject.cpp" />
<ClCompile Include="src\tmxreader.cpp" />
<ClCompile Include="src\XGetopt.cpp" />
<ClCompile Include="src\tmxtileset.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="inc\base64.h" />
<ClInclude Include="inc\miniz.h" />
<ClInclude Include="inc\rapidxml\rapidxml.hpp" />
<ClInclude Include="inc\rapidxml\rapidxml_iterators.hpp" />
<ClInclude Include="inc\rapidxml\rapidxml_print.hpp" />
<ClInclude Include="inc\rapidxml\rapidxml_utils.hpp" />
<ClInclude Include="inc\XGetopt.h" />
<ClInclude Include="src\tmxlayer.h" />
<ClInclude Include="src\tmxobject.h" />
<ClInclude Include="src\tmxreader.h" />
<ClInclude Include="src\tmxtileset.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,75 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\tmx2gba.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\base64.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\XGetopt.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\tmxreader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\tmxlayer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\tmxtileset.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\tmxobject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="inc\base64.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="inc\rapidxml\rapidxml.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="inc\rapidxml\rapidxml_iterators.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="inc\rapidxml\rapidxml_print.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="inc\rapidxml\rapidxml_utils.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="inc\miniz.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="inc\XGetopt.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\tmxreader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\tmxlayer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\tmxtileset.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\tmxobject.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>