diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bcbc5a..777e763 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( @@ -31,14 +36,19 @@ 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(GDAL_VERSION) + set(SYSTEM_GDAL_VERSION ${GDAL_VERSION}) +else() + 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 + ) +endif() if(SYSTEM_GDAL_VERSION VERSION_LESS "2.2") message(FATAL_ERROR "GDAL version \"${SYSTEM_GDAL_VERSION}\" is too old, at least 2.2 is required") diff --git a/include/tntn/File.h b/include/tntn/File.h index 33151c8..b48a149 100644 --- a/include/tntn/File.h +++ b/include/tntn/File.h @@ -6,6 +6,10 @@ #include #include +#ifdef _MSC_VER +#define ftello ftell +#endif + namespace tntn { class FileLike diff --git a/include/tntn/FileFormat.h b/include/tntn/FileFormat.h index 6253585..3b5eea3 100644 --- a/include/tntn/FileFormat.h +++ b/include/tntn/FileFormat.h @@ -4,6 +4,11 @@ #include #include "tntn/MeshMode.h" +#ifdef _MSC_VER +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#endif + namespace tntn { class FileFormat diff --git a/include/tntn/endianness.h b/include/tntn/endianness.h index ab9c58a..8eadb14 100644 --- a/include/tntn/endianness.h +++ b/include/tntn/endianness.h @@ -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 diff --git a/src/benchmark_workflow.cpp b/src/benchmark_workflow.cpp index ae34870..7a5539f 100644 --- a/src/benchmark_workflow.cpp +++ b/src/benchmark_workflow.cpp @@ -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; } @@ -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; } @@ -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; } @@ -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(); @@ -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; } @@ -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; @@ -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()); @@ -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()); diff --git a/src/dem2tintiles_workflow.cpp b/src/dem2tintiles_workflow.cpp index 4310145..646a213 100644 --- a/src/dem2tintiles_workflow.cpp +++ b/src/dem2tintiles_workflow.cpp @@ -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;