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

Commit

Permalink
Make windows build compatible with VS 2017
Browse files Browse the repository at this point in the history
  • Loading branch information
guischulz committed Apr 28, 2019
1 parent 59b7ac7 commit 9fe4514
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
15 changes: 6 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ option(TNTN_DOWNLOAD_DEPS "download dependencies during cmake configure" ON)

set(CMAKE_CXX_STANDARD 14)

if(MSVC)
if(MSVC_VERSION LESS 1910)
message(FATAL_ERROR "Visual Studio 2017 version 15.0 or higher is required")
endif()
endif()

# get the current working branch
execute_process(
Expand All @@ -31,16 +36,8 @@ find_package(GDAL REQUIRED)
if(NOT GDAL_FOUND)
message(FATAL_ERROR "GDAL not found, cannot proceed")
endif()
if(NOT GDAL_CONFIG)
message(FATAL_ERROR "gdal-config command not found (not in PATH?), cannot proceed")
endif()

execute_process(
COMMAND ${GDAL_CONFIG} --version
OUTPUT_VARIABLE SYSTEM_GDAL_VERSION
)

if(SYSTEM_GDAL_VERSION VERSION_LESS "2.2")
if(GDAL_VERSION VERSION_LESS "2.2")
message(FATAL_ERROR "GDAL version \"${SYSTEM_GDAL_VERSION}\" is too old, at least 2.2 is required")
endif()

Expand Down
4 changes: 4 additions & 0 deletions include/tntn/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <string>
#include <vector>

#ifdef _MSC_VER
#define ftello ftell
#endif

namespace tntn {

class FileLike
Expand Down
5 changes: 5 additions & 0 deletions include/tntn/FileFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include <string.h>
#include "tntn/MeshMode.h"

#ifdef _MSC_VER
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif

namespace tntn {

class FileFormat
Expand Down
2 changes: 1 addition & 1 deletion include/tntn/endianness.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# define TNTN_BIG_ENDIAN
#elif defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || \
defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || \
defined(__MIPSEL) || defined(__MIPSEL__)
defined(__MIPSEL) || defined(__MIPSEL__) || defined(_WIN32)
# define TNTN_LITTLE_ENDIAN
#else
# error unknown architecture
Expand Down
22 changes: 11 additions & 11 deletions src/benchmark_workflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static bool prepare_output_directory(const fs::path& output_dir, const bool resu
if(e)
{
TNTN_LOG_ERROR("unable to create output directory {} with message: {}",
output_dir.c_str(),
output_dir.string().c_str(),
e.message());
return false;
}
Expand All @@ -167,13 +167,13 @@ static bool prepare_output_directory(const fs::path& output_dir, const bool resu
//make sure it is a directory
if(!fs::is_directory(output_dir, e))
{
TNTN_LOG_ERROR("output directory {} is not a directory", output_dir.c_str());
TNTN_LOG_ERROR("output directory {} is not a directory", output_dir.string().c_str());
return false;
}
if(e)
{
TNTN_LOG_ERROR("filesystem error while checking output directory {} with message: {}",
output_dir.c_str(),
output_dir.string().c_str(),
e.message());
return false;
}
Expand All @@ -183,13 +183,13 @@ static bool prepare_output_directory(const fs::path& output_dir, const bool resu
//make sure it is empty
if(!fs::is_empty(output_dir, e))
{
TNTN_LOG_ERROR("output directory {} is not empty", output_dir.c_str());
TNTN_LOG_ERROR("output directory {} is not empty", output_dir.string().c_str());
return false;
}
if(e)
{
TNTN_LOG_ERROR("filesystem error while checking output directory {} with message: {}",
output_dir.c_str(),
output_dir.string().c_str(),
e.message());
return false;
}
Expand Down Expand Up @@ -662,13 +662,13 @@ static bool write_mesh_as_obj_and_off(const fs::path& parametrization_subdir,

bool rc = true;
File f;
if(f.open(obj_filename.c_str(), File::OM_RWC))
if(f.open(obj_filename.string().c_str(), File::OM_RWC))
{
rc = rc && write_mesh_as_obj(f, m);
f.close();
}

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

File f;
if(!f.open(raster_filename.c_str(), File::OM_RWC))
if(!f.open(raster_filename.string().c_str(), File::OM_RWC))
{
return false;
}
Expand Down Expand Up @@ -941,7 +941,7 @@ static bool run_all_dem2tin_method_benchmarks_on_single_file(

//create is_done_file to signal to later resume runs
File f;
f.open(is_done_file.c_str(), File::OM_RWC);
f.open(is_done_file.string().c_str(), File::OM_RWC);
}
}
return true;
Expand Down Expand Up @@ -1006,7 +1006,7 @@ bool run_dem2tin_method_benchmarks(const std::string& output_dir,
const auto benchmark_csv_filename = output_dir_p / "tin_terrain_benchmarks.csv";
if(resume && fs::exists(benchmark_csv_filename))
{
if(!csv_file->open(benchmark_csv_filename.c_str(), File::OM_RW))
if(!csv_file->open(benchmark_csv_filename.string().c_str(), File::OM_RW))
{
TNTN_LOG_ERROR("unable to open CSV output file {} for resume",
benchmark_csv_filename.string());
Expand All @@ -1015,7 +1015,7 @@ bool run_dem2tin_method_benchmarks(const std::string& output_dir,
}
else
{
if(!csv_file->open(benchmark_csv_filename.c_str(), File::OM_RWC))
if(!csv_file->open(benchmark_csv_filename.string().c_str(), File::OM_RWC))
{
TNTN_LOG_ERROR("unable to create CSV output file {} for writing",
benchmark_csv_filename.string());
Expand Down
2 changes: 1 addition & 1 deletion src/dem2tintiles_workflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool create_tiles_for_zoom_level(const RasterDouble& dem,
auto file_path =
tile_dir / (std::to_string(ty) + "." + mesh_writer.file_extension());

if(!tm.dumpTile(tx, ty, zoom, file_path.c_str(), mesh_writer))
if(!tm.dumpTile(tx, ty, zoom, file_path.string().c_str(), mesh_writer))
{
TNTN_LOG_ERROR("error dumping tile z:{} x:{} y:{}", zoom, tx, ty);
return false;
Expand Down

0 comments on commit 9fe4514

Please sign in to comment.