Skip to content

Commit

Permalink
Fixes for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Mar 30, 2018
1 parent e938d5c commit 890eb66
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 53 deletions.
26 changes: 14 additions & 12 deletions CMakeLists.txt
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions apps/pdal.cpp
Expand Up @@ -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;

This comment has been minimized.

Copy link
@hobu

hobu Mar 30, 2018

Member

probably want to kill this?

This comment has been minimized.

Copy link
@abellgithub

abellgithub Mar 30, 2018

Author Contributor

No. It's there for tests.

PluginManager<Stage>::setLog(log);
PluginManager<Kernel>::setLog(log);
#ifndef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion scripts/appveyor/config.cmd
Expand Up @@ -60,6 +60,6 @@ cmake -G "NMake Makefiles" ^
-DBUILD_SQLITE_TESTS=OFF ^
-DCMAKE_BUILD_TYPE=RelWithDebInfo ^
-DBUILD_OCI_TESTS=OFF ^
.
..


12 changes: 0 additions & 12 deletions test/unit/SpatialReferenceTest.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/unit/TestConfig.hpp.in
Expand Up @@ -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 <string>
Expand Down
3 changes: 3 additions & 0 deletions test/unit/apps/TIndexTest.cpp
Expand Up @@ -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"));

Expand Down Expand Up @@ -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
}

2 changes: 1 addition & 1 deletion test/unit/filters/ColorinterpFilterTest.cpp
Expand Up @@ -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;
Expand Down
28 changes: 8 additions & 20 deletions vendor/arbiter/arbiter.cpp
Expand Up @@ -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"))
Expand Down Expand Up @@ -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));
}
}

Expand All @@ -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))
Expand All @@ -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<int>::max())
throw ArbiterError("Can't convert offset time in seconds to tm type.");

tm.tm_sec -= (int)utcOffset;
m_time = std::mktime(&tm);
}

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions vendor/arbiter/arbiter.hpp
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions vendor/pdalboost/libs/filesystem/src/windows_file_codecvt.cpp
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 890eb66

Please sign in to comment.