Skip to content

Commit

Permalink
Config (#1796)
Browse files Browse the repository at this point in the history
Eliminate some conditional compilation and make build more build-system agnostic.
  • Loading branch information
abellgithub committed Jan 29, 2018
1 parent d4a8f7c commit d76922b
Show file tree
Hide file tree
Showing 78 changed files with 1,838 additions and 1,218 deletions.
49 changes: 37 additions & 12 deletions CMakeLists.txt
Expand Up @@ -128,7 +128,7 @@ include(${PDAL_CMAKE_DIR}/python.cmake)
include(${PDAL_CMAKE_DIR}/arbiter.cmake)

#------------------------------------------------------------------------------
# generate the pdal_defines.h header
# generate the pdal_features.hpp header
#------------------------------------------------------------------------------

# from http://stackoverflow.com/questions/1435953/how-can-i-pass-git-sha1-to-compiler-as-definition-using-cmake
Expand All @@ -139,19 +139,18 @@ configure_file(
"${PROJECT_SOURCE_DIR}/gitsha.cpp.in"
"${PROJECT_SOURCE_DIR}/pdal/gitsha.cpp")

# needs to come before configuration of pdal_defines
# needs to come before configuration of pdal_features
if(APPLE)
option(PDAL_BUNDLE "Create PDAL as Application Bundle on OSX" FALSE)
if (PDAL_BUNDLE)
set(PDAL_APP_BUNDLE 1)
endif()
endif()

set(pdal_defines_h_in "${CMAKE_CURRENT_SOURCE_DIR}/pdal_defines.h.in")
set(pdal_defines_h "${CMAKE_CURRENT_BINARY_DIR}/include/pdal/pdal_defines.h")
include(CheckIncludeFiles)
check_include_files(execinfo.h PDAL_HAVE_EXECINFO_H)
configure_file(${pdal_defines_h_in} ${pdal_defines_h})
set(pdal_features_hpp_in "${CMAKE_CURRENT_SOURCE_DIR}/pdal_features.hpp.in")
set(pdal_features_hpp
"${CMAKE_CURRENT_BINARY_DIR}/include/pdal/pdal_features.hpp")
configure_file(${pdal_features_hpp_in} ${pdal_features_hpp})

#------------------------------------------------------------------------------
# subdirectory controls
Expand Down Expand Up @@ -198,22 +197,48 @@ file(GLOB BASE_SRCS
${PDAL_FILTERS_DIR}/*.cpp
${PDAL_IO_DIR}/*.cpp
${PDAL_KERNELS_DIR}/*.cpp
${PDAL_SRC_DIR}/*.cpp)
${PDAL_SRC_DIR}/*.cpp
${PDAL_SRC_DIR}/compression/*.cpp)
file(GLOB_RECURSE PRIVATE_SRCS
${PDAL_FILTERS_DIR}/private/*.cpp
${PDAL_IO_DIR}/private/*.cpp
${PDAL_KERNELS_DIR}/private/*.cpp
${PDAL_SRC_DIR}/private/*.cpp)
list(APPEND SRCS ${BASE_SRCS} ${PRIVATE_SRCS})

#
# Remove stuff we don't want to build.
#
if (NOT PDAL_HAVE_LIBXML2)
file(GLOB XML_SRCS
io/Ilvis2MetadataReader.cpp
io/Ilvis2Metadata.cpp
pdal/DbWriter.cpp
pdal/DbReader.cpp
pdal/XMLSchema.cpp)
${PDAL_SRC_DIR}/DbWriter.cpp
${PDAL_SRC_DIR}/DbReader.cpp
${PDAL_SRC_DIR}/XMLSchema.cpp)
list(REMOVE_ITEM SRCS ${XML_SRCS})
endif()
if (NOT PDAL_HAVE_ZSTD)
file(GLOB ZSTD_SRCS
${PDAL_SRC_DIR}/compression/ZstdCompression.cpp)
list(REMOVE_ITEM SRCS ${ZSTD_SRCS})
endif()
if (NOT PDAL_HAVE_ZLIB)
file(GLOB ZLIB_SRCS
${PDAL_SRC_DIR}/compression/DeflateCompression.cpp)
list(REMOVE_ITEM SRCS ${ZLIB_SRCS})
endif()
if (NOT PDAL_HAVE_LZMA)
file(GLOB LZMA_SRCS
${PDAL_SRC_DIR}/compression/LzmaCompression.cpp)
list(REMOVE_ITEM SRCS ${LZMA_SRCS})
endif()
if (NOT PDAL_HAVE_LAZPERF)
file(GLOB LAZPERF_SRCS
${PDAL_SRC_DIR}/compression/LazPerfCompression.cpp
${PDAL_SRC_DIR}/compression/LazPerfVlrCompression.cpp)
list(REMOVE_ITEM SRCS ${LAZPERF_SRCS})
endif()
PDAL_ADD_LIBRARY(${PDAL_BASE_LIB_NAME} ${SRCS} ${RPLY_SRCS})

#
Expand Down Expand Up @@ -307,7 +332,7 @@ install(DIRECTORY ${PDAL_FILTERS_DIR}
PATTERN "private" EXCLUDE
)

install(FILES ${DIMENSION_OUTFILE} ${pdal_defines_h}
install(FILES ${DIMENSION_OUTFILE} ${pdal_features_h}
DESTINATION include/pdal
)

Expand Down
6 changes: 4 additions & 2 deletions apps/pdal.cpp
Expand Up @@ -93,7 +93,7 @@ class App
void App::outputVersion()
{
m_out << headline << std::endl;
m_out << "pdal " << GetFullVersionString() << std::endl;
m_out << "pdal " << Config::fullVersionString() << std::endl;
m_out << headline << std::endl;
m_out << std::endl;
}
Expand Down Expand Up @@ -354,7 +354,8 @@ int App::execute(StringList& cmdArgs, LogPtr& log)
else if (m_debug)
log->setLevel(LogLevel::Debug);
PluginManager::setLog(log);
#ifdef PDAL_HAVE_EXECINFO_H
#ifndef _WIN32
#if __has_include(<execinfo.h>)
if (m_debug)
{
signal(SIGSEGV, [](int sig)
Expand All @@ -367,6 +368,7 @@ int App::execute(StringList& cmdArgs, LogPtr& log)
exit(1);
});
}
#endif
#endif

m_command = Utils::tolower(m_command);
Expand Down
15 changes: 0 additions & 15 deletions cmake/win32_compiler_options.cmake
@@ -1,18 +1,3 @@
if (MSVC)
set(PDAL_COMPILER_MSVC 1)
if (MSVC12)
set(PDAL_COMPILER_VC12 1)
elseif (MSVC11)
set(PDAL_COMPILER_VC11 1)
elseif (MSVC10)
set(PDAL_COMPILER_VC10 1)
elseif (MSVC9)
set(PDAL_COMPILER_VC9 1)
elseif (MSVC8)
set(PDAL_COMPILER_VC8 1)
endif()
endif()

function(PDAL_TARGET_COMPILE_SETTINGS target)
target_compile_definitions(${target} PUBLIC -DWIN32_LEAN_AND_MEAN)
if (MSVC)
Expand Down
4 changes: 2 additions & 2 deletions filters/private/pnp/GridPnp.hpp
Expand Up @@ -278,8 +278,8 @@ class GridPnp
double scalex = ((m_xMax - m_xMin) * yAvgLen) /
((m_yMax - m_yMin) * xAvgLen);
double scaley = 1 / scalex;
double mx = std::sqrt(m * scalex);
double my = std::sqrt(m * scaley);
size_t mx = (size_t)std::sqrt(m * scalex);
size_t my = (size_t)std::sqrt(m * scaley);

// We always round up, because why not.
return XYIndex(mx + 1, my + 1);
Expand Down
2 changes: 1 addition & 1 deletion io/GDALGrid.cpp
Expand Up @@ -421,7 +421,7 @@ void GDALGrid::windowFill(size_t dstI, size_t dstJ)
continue;
// The ternaries just avoid underflow UB. We're just trying to
// find the distance from j to dstJ or i to dstI.
double distance = std::max(j > dstJ ? j - dstJ : dstJ - j,
double distance = (double)std::max(j > dstJ ? j - dstJ : dstJ - j,
i > dstI ? i - dstI : dstI - i);
windowFillCell(srcIdx, dstIdx, distance);
distSum += (1 / distance);
Expand Down
4 changes: 2 additions & 2 deletions io/GDALGrid.hpp
Expand Up @@ -113,11 +113,11 @@ class GDALGrid

// Convert an absolute X position to a horizontal cell index.
int horizontalIndex(double x)
{ return x / m_edgeLength; }
{ return (int)(x / m_edgeLength); }

// Convert an absolute Y position to a vertical cell index.
int verticalIndex(double y)
{ return m_height - (y / m_edgeLength) - 1; }
{ return (int)(m_height - (y / m_edgeLength) - 1); }

// Return the absolute horizontal position of the center of a cell given
// the cell i index.
Expand Down
1 change: 1 addition & 0 deletions io/Ilvis2Reader.cpp
Expand Up @@ -33,6 +33,7 @@
****************************************************************************/

#include "Ilvis2Reader.hpp"
#include "Ilvis2MetadataReader.hpp"
#include <pdal/util/FileUtils.hpp>
#include <pdal/pdal_macros.hpp>
#include <pdal/util/ProgramArgs.hpp>
Expand Down
1 change: 1 addition & 0 deletions io/Ilvis2Reader.hpp
Expand Up @@ -32,6 +32,7 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <pdal/pdal_features.hpp> // For PDAL_HAVE_LIBXML2
#include <pdal/PointView.hpp>
#include <pdal/Reader.hpp>
#include <pdal/util/IStream.hpp>
Expand Down
6 changes: 2 additions & 4 deletions io/LasHeader.cpp
Expand Up @@ -55,12 +55,10 @@ const size_t LasHeader::RETURN_COUNT;

std::string GetDefaultSoftwareId()
{
std::string ver(PDAL_VERSION_STRING);
std::string ver(Config::versionString());
std::stringstream oss;
std::ostringstream revs;
revs << GetSHA1();


revs << Config::sha1();
oss << "PDAL " << ver << " (" << revs.str().substr(0, 6) <<")";
return oss.str();
}
Expand Down
19 changes: 17 additions & 2 deletions io/LasReader.cpp
Expand Up @@ -32,6 +32,8 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <pdal/compression/LazPerfVlrCompression.hpp>

#include "LasReader.hpp"

#include <sstream>
Expand Down Expand Up @@ -63,6 +65,18 @@ struct invalid_stream : public std::runtime_error

} // unnamed namespace

LasReader::LasReader() : m_decompressor(nullptr), m_index(0)
{}


LasReader::~LasReader()
{
#ifdef PDAL_HAVE_LAZPERF
delete m_decompressor;
#endif
}


void LasReader::addArgs(ProgramArgs& args)
{
addSpatialReferenceArg(args);
Expand Down Expand Up @@ -245,8 +259,9 @@ void LasReader::ready(PointTableRef table)
{
const LasVLR *vlr = m_header.findVlr(LASZIP_USER_ID,
LASZIP_RECORD_ID);
m_decompressor.reset(new LazPerfVlrDecompressor(*stream,
vlr->data(), m_header.pointOffset()));
delete m_decompressor;
m_decompressor = new LazPerfVlrDecompressor(*stream,
vlr->data(), m_header.pointOffset());
m_decompressorBuf.resize(m_decompressor->pointSize());
}
#endif
Expand Down
9 changes: 5 additions & 4 deletions io/LasReader.hpp
Expand Up @@ -38,7 +38,6 @@
#include <pdal/plugin.hpp>
#include <pdal/PDALUtils.hpp>
#include <pdal/Reader.hpp>
#include <pdal/compression/LazPerfCompression.hpp>

#ifdef PDAL_HAVE_LASZIP
#include <laszip/laszip_api.h>
Expand All @@ -62,6 +61,7 @@ class NitfReader;
class LasHeader;
class LeExtractor;
class PointDimensions;
class LazPerfVlrDecompressor;

class PDAL_DLL LasReader : public pdal::Reader
{
Expand All @@ -87,8 +87,8 @@ class PDAL_DLL LasReader : public pdal::Reader

friend class NitfReader;
public:
LasReader() : pdal::Reader(), m_index(0)
{}
LasReader();
~LasReader();

static void * create();
static int32_t destroy(void *);
Expand Down Expand Up @@ -122,7 +122,8 @@ class PDAL_DLL LasReader : public pdal::Reader
LasHeader m_header;
laszip_POINTER m_laszip;
laszip_point_struct *m_laszipPoint;
std::unique_ptr<LazPerfVlrDecompressor> m_decompressor;

LazPerfVlrDecompressor *m_decompressor;
std::vector<char> m_decompressorBuf;
point_count_t m_index;
StringList m_extraDimSpec;
Expand Down
19 changes: 15 additions & 4 deletions io/LasWriter.cpp
Expand Up @@ -32,6 +32,8 @@
* OF SUCH DAMAGE.
****************************************************************************/

#include <pdal/compression/LazPerfVlrCompression.hpp>

#include "LasWriter.hpp"

#include <climits>
Expand Down Expand Up @@ -65,11 +67,19 @@ CREATE_STATIC_PLUGIN(1, 0, LasWriter, Writer, s_info)

std::string LasWriter::getName() const { return s_info.name; }

LasWriter::LasWriter() : m_ostream(NULL), m_compression(LasCompression::None),
m_srsCnt(0)
LasWriter::LasWriter() : m_compressor(nullptr), m_ostream(NULL),
m_compression(LasCompression::None), m_srsCnt(0)
{}


LasWriter::~LasWriter()
{
#ifdef PDAL_HAVE_LAZPERF
delete m_compressor;
#endif
}


void LasWriter::addArgs(ProgramArgs& args)
{
std::time_t now;
Expand Down Expand Up @@ -704,8 +714,9 @@ void LasWriter::readyLazPerfCompression()
zipvlr.extract((char *)data.data());
addVlr(LASZIP_USER_ID, LASZIP_RECORD_ID, "http://laszip.org", data);

m_compressor.reset(new LazPerfVlrCompressor(*m_ostream, schema,
zipvlr.chunk_size));
delete m_compressor;
m_compressor = new LazPerfVlrCompressor(*m_ostream, schema,
zipvlr.chunk_size);
#endif
}

Expand Down
5 changes: 3 additions & 2 deletions io/LasWriter.hpp
Expand Up @@ -37,7 +37,6 @@
#include <pdal/plugin.hpp>

#include <pdal/FlexWriter.hpp>
#include <pdal/compression/LazPerfCompression.hpp>

#include "HeaderVal.hpp"
#include "LasError.hpp"
Expand All @@ -62,6 +61,7 @@ class LeInserter;
class LasTester;
class NitfWriter;
class GeotiffSupport;
class LazPerfVlrCompressor;

struct VlrOptionInfo
{
Expand All @@ -82,6 +82,7 @@ class PDAL_DLL LasWriter : public FlexWriter
std::string getName() const;

LasWriter();
~LasWriter();

protected:
void prepOutput(std::ostream *out, const SpatialReference& srs);
Expand All @@ -91,7 +92,7 @@ class PDAL_DLL LasWriter : public FlexWriter
LasHeader m_lasHeader;
std::unique_ptr<LasSummaryData> m_summaryData;
laszip_POINTER m_laszip;
std::unique_ptr<LazPerfVlrCompressor> m_compressor;
LazPerfVlrCompressor *m_compressor;
bool m_discardHighReturnNumbers;
std::map<std::string, std::string> m_headerVals;
std::vector<VlrOptionInfo> m_optionInfos;
Expand Down
2 changes: 0 additions & 2 deletions io/PlyReader.cpp
Expand Up @@ -301,8 +301,6 @@ void PlyReader::initialize()

void PlyReader::addDimensions(PointLayoutPtr layout)
{
SimpleProperty *prop;

// Override XYZ to doubles.
layout->registerDim(Dimension::Id::X);
layout->registerDim(Dimension::Id::Y);
Expand Down
5 changes: 1 addition & 4 deletions io/QfitReader.cpp
Expand Up @@ -175,10 +175,7 @@ Word # Content
#include <algorithm>
#include <map>

#ifdef PDAL_COMPILER_MSVC
# pragma warning(disable: 4127) // conditional expression is constant
#endif

#pragma warning(disable: 4127) // conditional expression is constant

namespace pdal
{
Expand Down
2 changes: 1 addition & 1 deletion kernels/HausdorffKernel.cpp
Expand Up @@ -90,7 +90,7 @@ int HausdorffKernel::execute()
root.add("filenames", m_sourceFile);
root.add("filenames", m_candidateFile);
root.add("hausdorff", hausdorff);
root.add("pdal_version", pdal::GetFullVersionString());
root.add("pdal_version", Config::fullVersionString());
Utils::toJSON(root, std::cout);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion kernels/InfoKernel.cpp
Expand Up @@ -347,7 +347,7 @@ MetadataNode InfoKernel::run(const std::string& filename)
m_manager.prepare();
dump(root);
}
root.add("pdal_version", pdal::GetFullVersionString());
root.add("pdal_version", Config::fullVersionString());
return root;
}

Expand Down

0 comments on commit d76922b

Please sign in to comment.