From 7d1552a63d88564f9b357fcaf14b0b674da7cb21 Mon Sep 17 00:00:00 2001 From: Bradley J Chambers Date: Tue, 23 Oct 2012 14:40:58 -0400 Subject: [PATCH 1/5] testing for LIBXML2_FOUND rather than WITH_LIBXML2 to project against the case of the library just not being found --- apps/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index c75e284595..01d0afa2f7 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -45,12 +45,12 @@ link_directories(${Boost_LIBRARY_DIRS}) # Build pcinfo if(PCINFO) - if(WITH_LIBXML2) + if(LIBXML2_FOUND) list(APPEND PDAL_UTILITIES ${PCINFO}) add_executable(${PCINFO} pcinfo.cpp ${COMMON_APP_SOURCES}) target_link_libraries(${PCINFO} ${PDAL_LIB_NAME} ${Boost_LIBRARIES}) - endif() -endif() + endif(LIBXML2_FOUND) +endif(PCINFO) if(PC2PC) list(APPEND PDAL_UTILITIES ${PC2PC}) From d7f0be28710398ab78fb7da533636c05f0511e8c Mon Sep 17 00:00:00 2001 From: Bradley J Chambers Date: Tue, 23 Oct 2012 14:43:46 -0400 Subject: [PATCH 2/5] fix #104, fix #105 fixes two issues revealed when building on MSVC. toupper and isxdigit are ambiguous- changing to global namespace seems to clear things up. if replaceAll() is used outside of the tests, it shouldn't be buried in Support class. --- include/pdal/Utils.hpp | 15 ++++++++++----- src/Utils.cpp | 18 +++++++++++++++++- test/unit/FileUtilsTest.cpp | 3 ++- test/unit/Support.cpp | 17 ----------------- test/unit/Support.hpp | 4 ---- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/include/pdal/Utils.hpp b/include/pdal/Utils.hpp index 28ca214809..5ba5511457 100644 --- a/include/pdal/Utils.hpp +++ b/include/pdal/Utils.hpp @@ -152,10 +152,10 @@ class PDAL_DLL Utils std::vector retval; for (std::string::const_iterator it = source.begin(); it < source.end(); it += 2) { unsigned char v = 0; - if (std::isxdigit(*it)) - v = nibbles[std::toupper(*it) - '0'] << 4; - if (it + 1 < source.end() && std::isxdigit(*(it + 1))) - v += nibbles[std::toupper(*(it + 1)) - '0']; + if (::isxdigit(*it)) + v = nibbles[::toupper(*it) - '0'] << 4; + if (it + 1 < source.end() && ::isxdigit(*(it + 1))) + v += nibbles[::toupper(*(it + 1)) - '0']; retval.push_back(v); } return retval; @@ -216,7 +216,12 @@ class PDAL_DLL Utils static FILE* portable_popen(const std::string& command, const std::string& mode); static int portable_pclose(FILE* fp); static int run_shell_command(const std::string& cmd, std::string& output); - + + static std::string replaceAll(std::string result, + const std::string& replaceWhat, + const std::string& replaceWithWhat); + + private: template static inline char* as_buffer(T& data) diff --git a/src/Utils.cpp b/src/Utils.cpp index dd5cc53555..cf84230d7a 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -442,7 +442,7 @@ FILE* Utils::portable_popen(const std::string& command, const std::string& mode) FILE* fp = 0; #ifdef PDAL_PLATFORM_WIN32 - const std::string dos_command = Support::replaceAll(command, "/", "\\"); + const std::string dos_command = Utils::replaceAll(command, "/", "\\"); fp = _popen(dos_command.c_str(), mode.c_str()); #else fp = popen(command.c_str(), mode.c_str()); @@ -519,4 +519,20 @@ int Utils::run_shell_command(const std::string& cmd, std::string& output) return stat; } +//#ifdef PDAL_COMPILER_MSVC +// http://www.codepedia.com/1/CppStringReplace +std::string Utils::replaceAll(std::string result, + const std::string& replaceWhat, + const std::string& replaceWithWhat) +{ + while (1) + { + const int pos = result.find(replaceWhat); + if (pos==-1) break; + result.replace(pos,replaceWhat.size(),replaceWithWhat); + } + return result; +} +//#endif + } // namespace pdal diff --git a/test/unit/FileUtilsTest.cpp b/test/unit/FileUtilsTest.cpp index cd86392c9b..73d8ef88de 100644 --- a/test/unit/FileUtilsTest.cpp +++ b/test/unit/FileUtilsTest.cpp @@ -35,6 +35,7 @@ #include #include +#include #include "Support.hpp" using namespace pdal; @@ -114,7 +115,7 @@ static const std::string drive = ""; static std::string normalize(const std::string p) { - return Support::replaceAll(p, "\\", "/"); + return Utils::replaceAll(p, "\\", "/"); } static void compare_paths(const std::string a, const std::string b) diff --git a/test/unit/Support.cpp b/test/unit/Support.cpp index 978bf4b58d..e9e46a49c5 100644 --- a/test/unit/Support.cpp +++ b/test/unit/Support.cpp @@ -450,20 +450,3 @@ void Support::compareBounds(const pdal::Bounds& p, const pdal::Bounds Date: Tue, 23 Oct 2012 22:50:18 -0400 Subject: [PATCH 3/5] fix #106 --- include/pdal/Writer.hpp | 2 +- src/Writer.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/pdal/Writer.hpp b/include/pdal/Writer.hpp index 9b53c8bca9..1d52004be0 100644 --- a/include/pdal/Writer.hpp +++ b/include/pdal/Writer.hpp @@ -78,7 +78,7 @@ class PDAL_DLL Writer : public StageBase virtual boost::property_tree::ptree toPTree() const; virtual PointBuffer const* getPointBuffer() const { return m_buffer; } - static const boost::uint32_t s_defaultChunkSize; + static const boost::uint32_t s_defaultChunkSize = 1048576; protected: // this is called once before the loop with all the writeBuffer calls diff --git a/src/Writer.cpp b/src/Writer.cpp index 494708a225..315ee54c8e 100644 --- a/src/Writer.cpp +++ b/src/Writer.cpp @@ -50,9 +50,6 @@ namespace pdal { -const boost::uint32_t Writer::s_defaultChunkSize = 1048576; // 2^20 - - Writer::Writer(Stage& prevStage, const Options& options) : StageBase(StageBase::makeVector(prevStage), options) , m_chunkSize(options.getValueOrDefault("chunk_size", s_defaultChunkSize)) From 3b1c0a3419f2d2bc7899c95dcce5fe63af1990a2 Mon Sep 17 00:00:00 2001 From: Bradley J Chambers Date: Tue, 23 Oct 2012 23:14:29 -0400 Subject: [PATCH 4/5] fix #103, #106, #107 --- CMakeLists.txt | 31 ++++++++++++++++++------------- apps/CMakeLists.txt | 8 ++++---- include/pdal/pdal_export.hpp | 2 +- include/pdal/pdal_internal.hpp | 2 +- src/CMakeLists.txt | 8 ++++---- src/pdal_config.cpp | 2 +- test/unit/CMakeLists.txt | 7 ++++++- 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4f92f1d03..d5c8b13f98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,13 +288,13 @@ endif() set(WITH_FLANN FALSE CACHE BOOL "Choose if FLANN support should be built") if (WITH_FLANN) -find_package(Flann 1.7) -if (FLANN_FOUND) - mark_as_advanced(CLEAR FLANN_INCLUDE_DIR) - mark_as_advanced(CLEAR FLANN_LIBRARY) - include_directories(${FLANN_INCLUDE_DIR}) - set(PDAL_HAVE_FLANN 1) -endif() + find_package(Flann 1.7) + if (FLANN_FOUND) + mark_as_advanced(CLEAR FLANN_INCLUDE_DIR) + mark_as_advanced(CLEAR FLANN_LIBRARY) + include_directories(${FLANN_INCLUDE_DIR}) + set(PDAL_HAVE_FLANN 1) + endif() endif() if(WITH_GDAL) @@ -376,6 +376,10 @@ if(WITH_LIBXML2) endif() endif() +if(NOT LIBXML2_FOUND) + message(STATUS "libxml2 not selected or not found, pcinfo will not be build") +endif() + # Oracle support - optional, default=OFF set(WITH_ORACLE FALSE CACHE BOOL "Choose if Oracle support should be built") @@ -534,7 +538,14 @@ set(PDAL_DATA_DIR ${PDAL_DATA_SUBDIR}) install(FILES AUTHORS.txt LICENSE.txt DESTINATION ${PDAL_DATA_DIR}/doc) +#------------------------------------------------------------------------------ +# generate the pdal_config.h header +#------------------------------------------------------------------------------ +configure_file( + "${PROJECT_SOURCE_DIR}/pdal_defines.h.in" + "${CMAKE_BINARY_DIR}/pdal_defines.h") +include_directories(${CMAKE_BINARY_DIR}) #------------------------------------------------------------------------------ # subdirectory controls @@ -606,10 +617,4 @@ include(CPack) #add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source) -#------------------------------------------------------------------------------ -# finally, generate the pdal_config.h header -#------------------------------------------------------------------------------ -configure_file( - "${PROJECT_SOURCE_DIR}/pdal_defines.h.in" - "${PROJECT_SOURCE_DIR}/include/pdal/pdal_defines.h") diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 01d0afa2f7..f734520125 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -55,25 +55,25 @@ endif(PCINFO) if(PC2PC) list(APPEND PDAL_UTILITIES ${PC2PC}) add_executable(${PC2PC} pc2pc.cpp ${COMMON_APP_SOURCES}) - target_link_libraries(${PC2PC} ${PDAL_LIB_NAME} ${Boost_LIBRARIES}) + target_link_libraries(${PC2PC} ${PDAL_LIB_NAME} ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}) endif() if(PCPIPELINE) list(APPEND PDAL_UTILITIES ${PCPIPELINE}) add_executable(${PCPIPELINE} pcpipeline.cpp ${COMMON_APP_SOURCES}) - target_link_libraries(${PCPIPELINE} ${PDAL_LIB_NAME} ${Boost_LIBRARIES}) + target_link_libraries(${PCPIPELINE} ${PDAL_LIB_NAME} ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}) endif() if(PCQUERY) list(APPEND PDAL_UTILITIES ${PCQUERY}) add_executable(${PCQUERY} pcquery.cpp ${COMMON_APP_SOURCES}) - target_link_libraries(${PCQUERY} ${PDAL_LIB_NAME} ${Boost_LIBRARIES}) + target_link_libraries(${PCQUERY} ${PDAL_LIB_NAME} ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}) endif() if(PCEQUAL) list(APPEND PDAL_UTILITIES ${PCEQUAL}) add_executable(${PCEQUAL} pcequal.cpp ${COMMON_APP_SOURCES}) - target_link_libraries(${PCEQUAL} ${PDAL_LIB_NAME} ${Boost_LIBRARIES}) + target_link_libraries(${PCEQUAL} ${PDAL_LIB_NAME} ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}) endif() #------------------------------------------------------------------------------ diff --git a/include/pdal/pdal_export.hpp b/include/pdal/pdal_export.hpp index 10b77e58aa..394c2dc72e 100644 --- a/include/pdal/pdal_export.hpp +++ b/include/pdal/pdal_export.hpp @@ -35,7 +35,7 @@ #ifndef EXPORT_HPP_INCLUDED #define EXPORT_HPP_INCLUDED -#include +#include "pdal_defines.h" #ifndef PDAL_DLL #if defined(PDAL_COMPILER_MSVC) && !defined(PDAL_DISABLE_DLL) diff --git a/include/pdal/pdal_internal.hpp b/include/pdal/pdal_internal.hpp index 532d3c469c..fa99240a19 100644 --- a/include/pdal/pdal_internal.hpp +++ b/include/pdal/pdal_internal.hpp @@ -40,7 +40,7 @@ #include #include -#include +#include "pdal_defines.h" #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 43391c718a..988db7ea26 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -503,7 +503,7 @@ set(PDAL_CONFIG_HPP ${PDAL_HEADERS_DIR}/pdal_export.hpp ${PDAL_HEADERS_DIR}/pdal_internal.hpp ${PDAL_HEADERS_DIR}/pdal_config.hpp - ${PDAL_HEADERS_DIR}/pdal_defines.h + ${CMAKE_BINARY_DIR}/pdal_defines.h ) set (PDAL_CONFIG_CPP @@ -616,14 +616,14 @@ message(STATUS "Using boost lib: ${Boost_LIBRARIES}") if (WIN32) if (CMAKE_VERSION VERSION_GREATER 2.8.6) target_link_libraries(${APPS_CPP_DEPENDENCIES} - LINK_PRIVATE general ${Boost_LIBRARIES}) + LINK_PRIVATE general ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}) else() target_link_libraries(${APPS_CPP_DEPENDENCIES} - ${Boost_LIBRARIES}) + ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}) endif() else() target_link_libraries(${APPS_CPP_DEPENDENCIES} - ${Boost_LIBRARIES}) + ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY}) endif(WIN32) diff --git a/src/pdal_config.cpp b/src/pdal_config.cpp index 1a3b2c7c0e..f071a13bc0 100644 --- a/src/pdal_config.cpp +++ b/src/pdal_config.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include "pdal_defines.h" #ifdef PDAL_HAVE_LIBGEOTIFF #include diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index c839b6c0c5..0ee64cb260 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -13,7 +13,6 @@ endif() SET(PDAL_UNITTEST_TEST_SRC apps/pc2pcTest.cpp - apps/pcinfoTest.cpp apps/pcpipelineTest.cpp BoundsTest.cpp drivers/bpf/BPFTest.cpp @@ -64,6 +63,12 @@ SET(PDAL_UNITTEST_TEST_SRC ${PDAL_UNITTEST_XMLSCHEMA_TEST} ) +if(LIBXML2_FOUND) + list(APPEND ${PDAL_UNITTEST_TEST_SRC} + apps/pcinfoTest.cpp + ) +endif(LIBXML2_FOUND) + set(PDAL_PLANG_TEST_SRC plang/PLangTest.cpp plang/PredicateFilterTest.cpp From 6bf99f0718964f82374dab8a8a47e585d43b6e8c Mon Sep 17 00:00:00 2001 From: Bradley J Chambers Date: Wed, 24 Oct 2012 12:03:38 -0400 Subject: [PATCH 5/5] fix #108 now we are installing pdal_defines.h once again --- CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5c8b13f98..8532c097db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -544,8 +544,8 @@ install(FILES AUTHORS.txt LICENSE.txt configure_file( "${PROJECT_SOURCE_DIR}/pdal_defines.h.in" - "${CMAKE_BINARY_DIR}/pdal_defines.h") -include_directories(${CMAKE_BINARY_DIR}) + "${PROJECT_BINARY_DIR}/pdal_defines.h") +include_directories(${PROJECT_BINARY_DIR}) #------------------------------------------------------------------------------ # subdirectory controls diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 988db7ea26..675997a1a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -503,7 +503,7 @@ set(PDAL_CONFIG_HPP ${PDAL_HEADERS_DIR}/pdal_export.hpp ${PDAL_HEADERS_DIR}/pdal_internal.hpp ${PDAL_HEADERS_DIR}/pdal_config.hpp - ${CMAKE_BINARY_DIR}/pdal_defines.h + ${PROJECT_BINARY_DIR}/pdal_defines.h ) set (PDAL_CONFIG_CPP @@ -656,3 +656,6 @@ install(TARGETS ${PDAL_LIB_NAME} ${PDAL_C_LIB_NAME} ${PDAL_CSV_WRITER_NAME} install(DIRECTORY ${PDAL_HEADERS_DIR} DESTINATION ${PDAL_INCLUDE_DIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp") + +install(FILES "${PROJECT_BINARY_DIR}/pdal_defines.h" + DESTINATION "${PDAL_INCLUDE_DIR}/pdal")