Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit 42f2ed9

Browse files
committed
Make windows build compatible with VS 2017
Signed-off-by: Guido Schulz <guido.schulz@mettenmeier.de>
1 parent 59b7ac7 commit 42f2ed9

6 files changed

Lines changed: 28 additions & 22 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ option(TNTN_DOWNLOAD_DEPS "download dependencies during cmake configure" ON)
88

99
set(CMAKE_CXX_STANDARD 14)
1010

11+
if(MSVC)
12+
if(MSVC_VERSION LESS 1910)
13+
message(FATAL_ERROR "Visual Studio 2017 version 15.0 or higher is required")
14+
endif()
15+
endif()
1116

1217
# get the current working branch
1318
execute_process(
@@ -31,16 +36,8 @@ find_package(GDAL REQUIRED)
3136
if(NOT GDAL_FOUND)
3237
message(FATAL_ERROR "GDAL not found, cannot proceed")
3338
endif()
34-
if(NOT GDAL_CONFIG)
35-
message(FATAL_ERROR "gdal-config command not found (not in PATH?), cannot proceed")
36-
endif()
37-
38-
execute_process(
39-
COMMAND ${GDAL_CONFIG} --version
40-
OUTPUT_VARIABLE SYSTEM_GDAL_VERSION
41-
)
4239

43-
if(SYSTEM_GDAL_VERSION VERSION_LESS "2.2")
40+
if(GDAL_VERSION VERSION_LESS "2.2")
4441
message(FATAL_ERROR "GDAL version \"${SYSTEM_GDAL_VERSION}\" is too old, at least 2.2 is required")
4542
endif()
4643

include/tntn/File.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
#include <string>
77
#include <vector>
88

9+
#ifdef _MSC_VER
10+
#define ftello ftell
11+
#endif
12+
913
namespace tntn {
1014

1115
class FileLike

include/tntn/FileFormat.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#include <string.h>
55
#include "tntn/MeshMode.h"
66

7+
#ifdef _MSC_VER
8+
#define strncasecmp _strnicmp
9+
#define strcasecmp _stricmp
10+
#endif
11+
712
namespace tntn {
813

914
class FileFormat

include/tntn/endianness.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# define TNTN_BIG_ENDIAN
99
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || \
1010
defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || \
11-
defined(__MIPSEL) || defined(__MIPSEL__)
11+
defined(__MIPSEL) || defined(__MIPSEL__) || defined(_WIN32)
1212
# define TNTN_LITTLE_ENDIAN
1313
#else
1414
# error unknown architecture

src/benchmark_workflow.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static bool prepare_output_directory(const fs::path& output_dir, const bool resu
158158
if(e)
159159
{
160160
TNTN_LOG_ERROR("unable to create output directory {} with message: {}",
161-
output_dir.c_str(),
161+
output_dir.string().c_str(),
162162
e.message());
163163
return false;
164164
}
@@ -167,13 +167,13 @@ static bool prepare_output_directory(const fs::path& output_dir, const bool resu
167167
//make sure it is a directory
168168
if(!fs::is_directory(output_dir, e))
169169
{
170-
TNTN_LOG_ERROR("output directory {} is not a directory", output_dir.c_str());
170+
TNTN_LOG_ERROR("output directory {} is not a directory", output_dir.string().c_str());
171171
return false;
172172
}
173173
if(e)
174174
{
175175
TNTN_LOG_ERROR("filesystem error while checking output directory {} with message: {}",
176-
output_dir.c_str(),
176+
output_dir.string().c_str(),
177177
e.message());
178178
return false;
179179
}
@@ -183,13 +183,13 @@ static bool prepare_output_directory(const fs::path& output_dir, const bool resu
183183
//make sure it is empty
184184
if(!fs::is_empty(output_dir, e))
185185
{
186-
TNTN_LOG_ERROR("output directory {} is not empty", output_dir.c_str());
186+
TNTN_LOG_ERROR("output directory {} is not empty", output_dir.string().c_str());
187187
return false;
188188
}
189189
if(e)
190190
{
191191
TNTN_LOG_ERROR("filesystem error while checking output directory {} with message: {}",
192-
output_dir.c_str(),
192+
output_dir.string().c_str(),
193193
e.message());
194194
return false;
195195
}
@@ -662,13 +662,13 @@ static bool write_mesh_as_obj_and_off(const fs::path& parametrization_subdir,
662662

663663
bool rc = true;
664664
File f;
665-
if(f.open(obj_filename.c_str(), File::OM_RWC))
665+
if(f.open(obj_filename.string().c_str(), File::OM_RWC))
666666
{
667667
rc = rc && write_mesh_as_obj(f, m);
668668
f.close();
669669
}
670670

671-
if(f.open(off_filename.c_str(), File::OM_RWC))
671+
if(f.open(off_filename.string().c_str(), File::OM_RWC))
672672
{
673673
rc = rc && write_mesh_as_off(f, m);
674674
f.close();
@@ -688,7 +688,7 @@ static bool write_raster_as_asc_with_prefix(const fs::path& parametrization_subd
688688
raster_filename = parametrization_subdir / raster_filename;
689689

690690
File f;
691-
if(!f.open(raster_filename.c_str(), File::OM_RWC))
691+
if(!f.open(raster_filename.string().c_str(), File::OM_RWC))
692692
{
693693
return false;
694694
}
@@ -941,7 +941,7 @@ static bool run_all_dem2tin_method_benchmarks_on_single_file(
941941

942942
//create is_done_file to signal to later resume runs
943943
File f;
944-
f.open(is_done_file.c_str(), File::OM_RWC);
944+
f.open(is_done_file.string().c_str(), File::OM_RWC);
945945
}
946946
}
947947
return true;
@@ -1006,7 +1006,7 @@ bool run_dem2tin_method_benchmarks(const std::string& output_dir,
10061006
const auto benchmark_csv_filename = output_dir_p / "tin_terrain_benchmarks.csv";
10071007
if(resume && fs::exists(benchmark_csv_filename))
10081008
{
1009-
if(!csv_file->open(benchmark_csv_filename.c_str(), File::OM_RW))
1009+
if(!csv_file->open(benchmark_csv_filename.string().c_str(), File::OM_RW))
10101010
{
10111011
TNTN_LOG_ERROR("unable to open CSV output file {} for resume",
10121012
benchmark_csv_filename.string());
@@ -1015,7 +1015,7 @@ bool run_dem2tin_method_benchmarks(const std::string& output_dir,
10151015
}
10161016
else
10171017
{
1018-
if(!csv_file->open(benchmark_csv_filename.c_str(), File::OM_RWC))
1018+
if(!csv_file->open(benchmark_csv_filename.string().c_str(), File::OM_RWC))
10191019
{
10201020
TNTN_LOG_ERROR("unable to create CSV output file {} for writing",
10211021
benchmark_csv_filename.string());

src/dem2tintiles_workflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ bool create_tiles_for_zoom_level(const RasterDouble& dem,
147147
auto file_path =
148148
tile_dir / (std::to_string(ty) + "." + mesh_writer.file_extension());
149149

150-
if(!tm.dumpTile(tx, ty, zoom, file_path.c_str(), mesh_writer))
150+
if(!tm.dumpTile(tx, ty, zoom, file_path.string().c_str(), mesh_writer))
151151
{
152152
TNTN_LOG_ERROR("error dumping tile z:{} x:{} y:{}", zoom, tx, ty);
153153
return false;

0 commit comments

Comments
 (0)