Skip to content

Commit

Permalink
Simplify E57 build and fix warnings. (#2914)
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Feb 5, 2020
1 parent 0ee0d63 commit cd0b207
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 300 deletions.
64 changes: 32 additions & 32 deletions plugins/e57/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,48 @@
include(FindXercesC)
find_package(XercesC REQUIRED)

add_subdirectory(libE57Format)

PDAL_ADD_PLUGIN(e57plugin_reader reader e57
FILES
io/E57Reader.cpp
io/Scan.cpp
io/Utils.cpp
INCLUDES
${NLOHMANN_INCLUDE_DIR}
${PDAL_VENDOR_DIR}
LINK_WITH
E57Format
${XercesC_LIBRARY}
FILES
io/E57Reader.cpp
io/Scan.cpp
io/Utils.cpp
INCLUDES
${NLOHMANN_INCLUDE_DIR}
${PDAL_VENDOR_DIR}
LINK_WITH
E57Format
INCLUDES
libE57Format/include
)

target_include_directories(${e57plugin_reader} PRIVATE "libE57Format/include")
target_compile_definitions(${e57plugin_reader}
PRIVATE
ARBITER_ZLIB
ARBITER_DLL_IMPORT
)

PDAL_ADD_PLUGIN(e57plugin_writer writer e57
FILES
io/E57Writer.cpp
io/Utils.cpp
io/Uuid.cpp
LINK_WITH
E57Format
${XercesC_LIBRARY}
)

target_include_directories(${e57plugin_writer} PRIVATE "libE57Format/include")
FILES
io/E57Writer.cpp
io/Utils.cpp
io/Uuid.cpp
LINK_WITH
E57Format
INCLUDES
libE57Format/include
)

if (WITH_TESTS)
PDAL_ADD_TEST(pdal_io_e57_read_test
FILES
test/E57ReaderTest.cpp
test/ScanTest.cpp
test/E57UtilsTest.cpp
LINK_WITH
${e57plugin_reader}
FILES
test/E57ReaderTest.cpp
test/E57UtilsTest.cpp
test/ScanTest.cpp
LINK_WITH
${e57plugin_reader}
E57Format
INCLUDES
libE57Format/include
)
target_include_directories(pdal_io_e57_read_test PRIVATE "libE57Format/include")

PDAL_ADD_TEST(pdal_io_e57_write_test
FILES
Expand All @@ -53,6 +51,8 @@ if (WITH_TESTS)
LINK_WITH
${e57plugin_reader}
${e57plugin_writer}
E57Format
INCLUDES
libE57Format/include
)
target_include_directories(pdal_io_e57_write_test PRIVATE "libE57Format/include")
endif()
5 changes: 3 additions & 2 deletions plugins/e57/io/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,15 @@ bool getLimits(const e57::StructureNode& prototype,
// This will give positive bounds to default data type for id.
std::pair<uint64_t, uint64_t> getPdalBounds(pdal::Dimension::Id id)
{
// pdal::Dimension::size() returns number of bytes for the pdal::Dimesion::Type.
// pdal::Dimension::size() returns number of bytes for the
// pdal::Dimesion::Type.
// eg: 1 for uint8, 2 for uint16, 4 for uint32, 8 for double, etc.
// Max range for data type = (2 ^ (8 * no. of bytes)) - 1
auto type = pdal::Dimension::defaultType(id);
auto typeName = pdal::Dimension::interpretationName(type);
if (typeName.find("uint") == 0)
{
auto maxVal = std::pow(2, 8 * pdal::Dimension::size(type)) - 1;
uint64_t maxVal = std::pow(2, 8 * pdal::Dimension::size(type)) - 1;
return {0, maxVal};
}
throw pdal_error("Cannot retrieve bounds for : " + typeName);
Expand Down
92 changes: 21 additions & 71 deletions plugins/e57/libE57Format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,88 +30,20 @@
# If you find any errors or have suggestion to improve the build script:
# patches are most welcome! Please send them to the development mailing list.


cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 11)

# Override flags to enable prepare for linking to static runtime
set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flag_overrides.cmake)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake)

# Set a private module find path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")

project(E57Format)

# developer adjustable version numbers
set(${PROJECT_NAME}_MAJOR_VERSION 2)
set(${PROJECT_NAME}_MINOR_VERSION 0)
set(${PROJECT_NAME}_PATCH_VERSION 1)

include(Tags)

# propose a default installation directory
#if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# string(REGEX REPLACE "/${PROJECT_NAME}" "" CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
# set(T_ ${PROJECT_NAME})
# set(T_ ${T_}-${${PROJECT_NAME}_MAJOR_VERSION})
# set(T_ ${T_}.${${PROJECT_NAME}_MINOR_VERSION})
# set(T_ ${T_}-${${PROJECT_NAME}_BUILD_TAG})
# set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${T_}
# CACHE PATH
# "Install path prefix, prepended onto install directories."
# FORCE
# )
#endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

find_package( Threads REQUIRED )

# Xerces-c
find_package( XercesC )

if ( NOT XercesC_FOUND )
set( XercesC_INCLUDE_DIR "" CACHE PATH "Xerces include directory" )
endif()

if ( WIN32 )
option( USING_STATIC_XERCES "Turn on if you are linking with Xerces as a static lib" OFF )

if ( USING_STATIC_XERCES )
add_definitions( -DXERCES_STATIC_LIBRARY )
endif()
endif()

set( XML_INCLUDE_DIRS ${XercesC_INCLUDE_DIR} )

if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_definitions(-DLINUX)
# find_package(ICU REQUIRED)
# set(XML_INCLUDE_DIRS ${XML_INCLUDE_DIRS} ${ICU_INCLUDE_DIRS})
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_definitions(-DMACOS)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
add_definitions(-DWINDOWS)
endif()

add_definitions(-DREVISION_ID="${PROJECT_NAME}-${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}-${${PROJECT_NAME}_BUILD_TAG}")

include_directories(
${PROJECT_BINARY_DIR}/include
include
src/
${XML_INCLUDE_DIRS}
)

# CRCpp from here: https://github.com/d-bahr/CRCpp
add_definitions( -DCRCPP_USE_CPP11 )
add_definitions( -DCRCPP_BRANCHLESS )
include_directories( contrib/CRCpp/inc )
find_package(XercesC REQUIRED)

#
# The reference implementation
#

add_library( E57Format STATIC
add_library(E57Format STATIC
src/CheckedFile.h
src/CheckedFile.cpp
src/Common.h
Expand Down Expand Up @@ -140,7 +72,25 @@ add_library( E57Format STATIC
include/E57Format.h
contrib/CRCpp/inc/CRC.h
)
pdal_target_compile_settings(E57Format)
target_link_libraries(E57Format
PUBLIC
${XercesC_LIBRARIES}
)

# CRCpp from here: https://github.com/d-bahr/CRCpp
target_include_directories(E57Format
PRIVATE
include
contrib/CRCpp/inc
)

target_compile_definitions(E57Format
PRIVATE
CRCPP_USE_CPP11
CRCPP_BRANCHLESS
)

set_target_properties( E57Format PROPERTIES
DEBUG_POSTFIX "-d"
POSITION_INDEPENDENT_CODE ON
)

This file was deleted.

82 changes: 0 additions & 82 deletions plugins/e57/libE57Format/cmake/Modules/FindICU.cmake

This file was deleted.

41 changes: 0 additions & 41 deletions plugins/e57/libE57Format/cmake/Modules/Tags.cmake

This file was deleted.

0 comments on commit cd0b207

Please sign in to comment.