From 890eb6610d16949c8949c4656af425b167a6005b Mon Sep 17 00:00:00 2001 From: Andrew Bell Date: Fri, 30 Mar 2018 15:28:08 +0000 Subject: [PATCH] Fixes for windows --- CMakeLists.txt | 26 +++++++++-------- apps/pdal.cpp | 1 + scripts/appveyor/config.cmd | 2 +- test/unit/SpatialReferenceTest.cpp | 12 -------- test/unit/TestConfig.hpp.in | 2 +- test/unit/apps/TIndexTest.cpp | 3 ++ test/unit/filters/ColorinterpFilterTest.cpp | 2 +- vendor/arbiter/arbiter.cpp | 28 ++++++------------- vendor/arbiter/arbiter.hpp | 1 + .../filesystem/src/windows_file_codecvt.cpp | 12 ++++---- 10 files changed, 36 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6169750b20..be68e167ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,20 +81,22 @@ set_directory_properties(PROPERTY ADDITIONAL_MAKE_CLEAN_FILES if(WIN32) add_definitions("-DPDAL_DLL_EXPORT=1") - foreach(config ${CMAKE_CONFIGURATION_TYPES}) - string(TOUPPER ${config} CONFIG) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG} "${PDAL_OUTPUT_LIB_DIR}") - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} "${PDAL_OUTPUT_BIN_DIR}") - # ---[ Windows requires DLLs (shared libraries) to be installed in - # ---[ the same directory as executables - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG} "${PDAL_OUTPUT_BIN_DIR}") - endforeach(config) -else(WIN32) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PDAL_OUTPUT_LIB_DIR}") - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PDAL_OUTPUT_BIN_DIR}") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PDAL_OUTPUT_LIB_DIR}") + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${PDAL_OUTPUT_LIB_DIR}") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${PDAL_OUTPUT_BIN_DIR}") + # ---[ Windows requires DLLs (shared libraries) to be installed in + # ---[ the same directory as executables + message("*** CONFIG RUNTIME OUTPUT = ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE}} ***") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE} "${PDAL_OUTPUT_BIN_DIR}") endif(WIN32) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PDAL_OUTPUT_LIB_DIR}") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PDAL_OUTPUT_BIN_DIR}") +if(WIN32) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PDAL_OUTPUT_BIN_DIR}") +else() + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PDAL_OUTPUT_LIB_DIR}") +endif() + # Choose package components include(${PDAL_CMAKE_DIR}/options.cmake) diff --git a/apps/pdal.cpp b/apps/pdal.cpp index 3352213bf7..e247f68542 100644 --- a/apps/pdal.cpp +++ b/apps/pdal.cpp @@ -350,6 +350,7 @@ int App::execute(StringList& cmdArgs, LogPtr& log) log->setLevel(m_logLevel); else if (m_debug) log->setLevel(LogLevel::Debug); + log->get(LogLevel::Debug) << "Debugging..." << std::endl; PluginManager::setLog(log); PluginManager::setLog(log); #ifndef _WIN32 diff --git a/scripts/appveyor/config.cmd b/scripts/appveyor/config.cmd index 2a207ac556..9855afe6ff 100644 --- a/scripts/appveyor/config.cmd +++ b/scripts/appveyor/config.cmd @@ -60,6 +60,6 @@ cmake -G "NMake Makefiles" ^ -DBUILD_SQLITE_TESTS=OFF ^ -DCMAKE_BUILD_TYPE=RelWithDebInfo ^ -DBUILD_OCI_TESTS=OFF ^ - . + .. diff --git a/test/unit/SpatialReferenceTest.cpp b/test/unit/SpatialReferenceTest.cpp index 2ea9cc1283..ad37fc925e 100644 --- a/test/unit/SpatialReferenceTest.cpp +++ b/test/unit/SpatialReferenceTest.cpp @@ -48,18 +48,6 @@ using namespace pdal; -TEST(SpatialReferenceTest, test_env_vars) -{ - -#ifdef _MSC_VER - const char* gdal_data = getenv("GDAL_DATA"); - const char* proj_lib = getenv("PROJ_LIB"); - - EXPECT_TRUE(FileUtils::fileExists(gdal_data)); - EXPECT_TRUE(FileUtils::fileExists(proj_lib)); -#endif -} - TEST(SpatialReferenceTest, test_ctor) { SpatialReference srs; diff --git a/test/unit/TestConfig.hpp.in b/test/unit/TestConfig.hpp.in index 5ffaf6721c..6c584c3bc1 100644 --- a/test/unit/TestConfig.hpp.in +++ b/test/unit/TestConfig.hpp.in @@ -37,7 +37,7 @@ #define UNITTEST_TESTCONFIG_DATA_PATH "@CMAKE_SOURCE_DIR@/test/data/" #define UNITTEST_TESTCONFIG_CONFIGURED_PATH "@CMAKE_BINARY_DIR@/test/data/" -#define UNITTEST_TESTCONFIG_BINARY_PATH "@CMAKE_BINARY_DIR@/bin/" +#define UNITTEST_TESTCONFIG_BINARY_PATH "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/" #define UNITTEST_TESTCONFIG_OCI_CONNECTION "@OCI_CONNECTION@" #include diff --git a/test/unit/apps/TIndexTest.cpp b/test/unit/apps/TIndexTest.cpp index 438755120b..c74333d1cf 100644 --- a/test/unit/apps/TIndexTest.cpp +++ b/test/unit/apps/TIndexTest.cpp @@ -106,6 +106,8 @@ TEST(TIndex, test2) // Indentical to test1, but filespec input comes from find command. TEST(TIndex, test3) { +// No find on Windows. +#ifndef WIN32 std::string outSpec(Support::temppath("tindex.out")); std::string outPoints(Support::temppath("points.txt")); @@ -142,5 +144,6 @@ TEST(TIndex, test3) Utils::run_shell_command(cmd, output); pos = output.find("Merge filecount: 1"); EXPECT_NE(pos, std::string::npos); +#endif } diff --git a/test/unit/filters/ColorinterpFilterTest.cpp b/test/unit/filters/ColorinterpFilterTest.cpp index aa966ad7c4..0dc9ac8cf0 100644 --- a/test/unit/filters/ColorinterpFilterTest.cpp +++ b/test/unit/filters/ColorinterpFilterTest.cpp @@ -51,7 +51,7 @@ std::string makeColor() static uint8_t rgb[12] = { 1, 2, 3, 4 }; std::string ptr = Utils::toString(&rgb); - if (ptr[0] != '0' && ptr[1] != 'x') + if (ptr[0] != '0' || ptr[1] != 'x') ptr = "0x" + ptr; std::ostringstream ss; ss << "MEM:::PIXELS=4,LINES=1,BANDS=3,DATAPOINTER=" << ptr; diff --git a/vendor/arbiter/arbiter.cpp b/vendor/arbiter/arbiter.cpp index b28a4a6905..8eb37494f8 100644 --- a/vendor/arbiter/arbiter.cpp +++ b/vendor/arbiter/arbiter.cpp @@ -3237,7 +3237,7 @@ Curl::Curl(const Json::Value& json) { if (h.isMember("timeout")) { - m_timeout = h["timeout"].asUInt64(); + m_timeout = long(h["timeout"].asUInt64()); } if (h.isMember("followRedirect")) @@ -4462,22 +4462,7 @@ namespace std::time_t now(std::time(nullptr)); std::tm utc(*std::gmtime(&now)); std::tm loc(*std::localtime(&now)); - return std::difftime(std::mktime(&utc), std::mktime(&loc)); - } - - std::tm getTm() - { - std::tm tm; - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - tm.tm_mday = 0; - tm.tm_mon = 0; - tm.tm_year = 0; - tm.tm_wday = 0; - tm.tm_yday = 0; - tm.tm_isdst = 0; - return tm; + return (int64_t)std::difftime(std::mktime(&utc), std::mktime(&loc)); } } @@ -4494,7 +4479,7 @@ Time::Time(const std::string& s, const std::string& format) { static const int64_t utcOffset(utcOffsetSeconds()); - auto tm(getTm()); + std::tm tm {}; #ifndef ARBITER_WINDOWS // We'd prefer to use get_time, but it has poor compiler support. if (!strptime(s.c_str(), format.c_str(), &tm)) @@ -4509,7 +4494,10 @@ Time::Time(const std::string& s, const std::string& format) throw ArbiterError("Failed to parse " + s + " as time: " + format); } #endif - tm.tm_sec -= utcOffset; + if (utcOffset > std::numeric_limits::max()) + throw ArbiterError("Can't convert offset time in seconds to tm type."); + + tm.tm_sec -= (int)utcOffset; m_time = std::mktime(&tm); } @@ -4534,7 +4522,7 @@ std::string Time::str(const std::string& format) const int64_t Time::operator-(const Time& other) const { - return std::difftime(m_time, other.m_time); + return (int64_t)std::difftime(m_time, other.m_time); } int64_t Time::asUnix() const diff --git a/vendor/arbiter/arbiter.hpp b/vendor/arbiter/arbiter.hpp index cc2f59d1f6..2455458bc1 100644 --- a/vendor/arbiter/arbiter.hpp +++ b/vendor/arbiter/arbiter.hpp @@ -42,6 +42,7 @@ SOFTWARE. #pragma once +#pragma warning(disable:4251) // DLL export warnings /// If defined, indicates that the source file is amalgamated /// to prevent private header inclusion. #define ARBITER_IS_AMALGAMATION diff --git a/vendor/pdalboost/libs/filesystem/src/windows_file_codecvt.cpp b/vendor/pdalboost/libs/filesystem/src/windows_file_codecvt.cpp index 998db60221..090f4c71b3 100644 --- a/vendor/pdalboost/libs/filesystem/src/windows_file_codecvt.cpp +++ b/vendor/pdalboost/libs/filesystem/src/windows_file_codecvt.cpp @@ -38,9 +38,9 @@ { UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; - int count; - if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from, - from_end - from, to, to_end - to)) == 0) + auto count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from, + int(from_end - from), to, int(to_end - to)); + if (count == 0) { return error; // conversion failed } @@ -58,9 +58,9 @@ { UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; - int count; - if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from, - from_end - from, to, to_end - to, 0, 0)) == 0) + auto count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from, + int(from_end - from), to, int(to_end - to), 0, 0); + if (count == 0) { return error; // conversion failed }