# $Id: CMakeLists.txt 332 2013-04-03 14:24:08Z roland_schwarz $
# This is the CMake project file for the libe57 reference implementation
#
# Copyright 2010-2012 Roland Schwarz, Riegl LMS GmbH
#
# Permission is hereby granted, free of charge, to any person or organization
# obtaining a copy of the software and accompanying documentation covered by
# this license (the "Software") to use, reproduce, display, distribute,
# execute, and transmit the Software, and to prepare derivative works of the
# Software, and to permit third-parties to whom the Software is furnished to
# do so, all subject to the following:
#
# The copyright notices in the Software and this entire statement, including
# the above license grant, this restriction and the following disclaimer,
# must be included in all copies of the Software, in whole or in part, and
# all derivative works of the Software, unless such copies or derivative
# works are solely in the form of machine-executable object code generated by
# a source language processor.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# Requirements:
#     Xerces library: http://xerces.apache.org/
# 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.

project(E57Format)

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

find_package(XercesC REQUIRED)

#
# The reference implementation
#

add_library(E57Format STATIC
    src/CheckedFile.h
    src/CheckedFile.cpp
    src/Common.h
    src/Decoder.h
    src/Decoder.cpp
    src/Encoder.h
    src/Encoder.cpp
    src/NodeImpl.h
    src/NodeImpl.cpp
    src/Packet.h
    src/Packet.cpp
    src/ImageFileImpl.cpp
    src/ImageFileImpl.h
    src/SourceDestBufferImpl.h
    src/SourceDestBufferImpl.cpp
    src/StructureNodeImpl.h
    src/StructureNodeImpl.cpp
    src/E57Exception.cpp
    src/E57Format.cpp
    src/E57FormatImpl.cpp
    src/E57FormatImpl.h
    src/E57Version.h
    src/E57XmlParser.h
    src/E57XmlParser.cpp
    include/E57Exception.h
    include/E57Format.h
    contrib/CRCpp/inc/CRC.h
)
pdal_target_compile_settings(E57Format)
if (WIN32)
target_compile_options(E57Format PRIVATE
    /wd4244
    )
endif()
target_link_libraries(E57Format
    PRIVATE
        ${XercesC_LIBRARIES}
)

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

target_compile_definitions(E57Format
    PRIVATE
        CRCPP_USE_CPP11
        CRCPP_BRANCHLESS
)

set_target_properties( E57Format PROPERTIES
    POSITION_INDEPENDENT_CODE ON
)
