#
# LDASTools frameCPP - A library implementing the LIGO/Virgo frame specification
#
# Copyright (C) 2018 California Institute of Technology
#
# LDASTools frameCPP is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 (GPLv2) of the
# License or at your discretion, any later version.
#
# LDASTools frameCPP is distributed in the hope that it will be useful, but
# without any warranty or even the implied warranty of merchantability
# or fitness for a particular purpose. See the GNU General Public
# License (GPLv2) for more details.
#
# Neither the names of the California Institute of Technology (Caltech),
# The Massachusetts Institute of Technology (M.I.T), The Laser
# Interferometer Gravitational-Wave Observatory (LIGO), nor the names
# of its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# You should have received a copy of the licensing terms for this
# software included in the file LICENSE located in the top-level
# directory of this package. If you did not, you can view a copy at
# http://dcc.ligo.org/M1500244/LICENSE
#

#=========================================================================
#=========================================================================

#------------------------------------------------------------------------
# => 2:0:0 -- 2009.12.03
#   In preperation for 1.18.0 release of ldas
# => 3:0:0 -- 2010.03.02
#   To enable/disable the checking of expansion, needed to modify
#   Verify by adding to the size of the data structure.
# => 4:0:0 -- 2013.08.12 (post ldas-1.19.32)
#   Modified FrameStream.cc
#   FrEndOfFile::Filter() parameters modified
# => 4:1:0 -- 2014.01.16 (ldas-1.19.37)
#   Modified primate class IChecksumOnlyStream to accept streams
#     as well as filenames.
# => 4:2:0 -- 2014.01.28 (ldas-1.19.38)
#   Removed verbose debugging messages from Verify class.
# => 5:0:1
#   Added several new methods to the Verify class
# => 6:0:2
#   Added data_valid_all methods to the Verify class
# 7:0:0 - 2016.03.03
#    Code cleanup
# 7:1:0 - 2016.04.20
#    Addressed infinite recursion warning
# 7:2:0 - 2016.09.09
#    Corrected comparison operator for StreamRef and PTR_STRUCT
#    Added FRAMECPP_VERSION
# 8:0:0 - 2016.10.10
#    Converted to exclusive use of std::unique_ptr in place
#       of std::auto_ptr
# 8:1:0 - 2017.11.06 (ldas-tools-framecpp-2.5.8)
#    Corrections for GCC 7.2.0 and XCode 9.0
# 9:0:0 - 2018.05.11 ( ldas-tools-framecpp-2.6.0 )
#    Removed hand rolled smart pointers in favor of boost smart pointers
# 10:0:1 - ldas-tools-framecpp-2.6.3
#    Added FrEndOfFile::NFrames()
#    Added FrTOC::runs()
#    Added IFrameStream::readFrEndOfFile()
#    Added IFrameStream::readFrTOCHeader()
# 11:0:0 - ldas-tools-framecpp-2.7.0
#    Updated doxygen
# 11:1:0 - ldas-tools-framecpp-2.7.1
#    Compilier updates
# 12:0:0 - ldas-tools-framecpp-2.7.2
#    Removed unnecessary routines
#------------------------------------------------------------------------
# form: <(c)urrent>:<(r)evision>:<(a)ge
#
# 1. Update the version information only immediately before a public
#    release of your software. More frequent updates are unnecessary,
#    and only guarantee that the current interface number gets larger
#    faster.
# 2. If the library source code has changed at all since the last
#    update, then increment revision (c:r:a becomes c:r+1:a).
# 3. If any interfaces [exported functions or data] have been added,
#    removed, or changed since the last update, increment current,
#    and set revision to 0.
# 4. If any interfaces have been added since the last public
#    release, then increment age.
# 5. If any interfaces have been removed since the last public
#    release, then set age to 0.
#------------------------------------------------------------------------
set( libframecppcmn_la_CURRENT 12 )
set( libframecppcmn_la_REVISION 0 )
set( libframecppcmn_la_AGE 0 )

list( APPEND EXTRA_DIST
  FrameSpec.hh.in
  FrTOCPrivate.hh
  )

set( HDR_DIR framecpp/Common )
set( hhdir ${CMAKE_INSTALL_INCLUDEDIR}/${HDR_DIR} )

set( nodist_hh_HEADERS
	FrameSpec.hh
  )

set( hh_HEADERS
	Array.hh
	BaseMemoryBuffer.hh
	BufferSpecialization.hh
	CheckSumFilter.hh
	CheckSum.hh
	Compression.hh
	CompressionException.hh
	CompressionDifferential.hh
	CompressionGZip.hh
	CompressionZeroSuppress.hh
	Container.hh
	CRC.hh
	CRCModel.hh
	Description.hh
	DetectorNames.hh
	Dictionary.hh
	DynamicMemoryBuffer.hh
	FrameBuffer.hh
	FrameBuffer.icc
	FrameBufferInterface.hh
	FrameFilename.hh
	FrameSpec.tcc
	FrameStream.hh
	FrameStream.tcc
	FrameStreamBase.hh
	FrameStreamPlanWrapper.hh
	FrameStreamWrapper.hh
	FrameStructCheckSum.hh
	FrameStructCheckSum.tcc
	FrameH.hh
	FrDataObject.hh
	FrDetector.hh
	FrEndOfFile.hh
	FrHeader.hh
	FrSH.hh
	FrStatData.hh
	FrTOC.hh
	FrVect.hh
	MemoryBuffer.hh
	IOStream.hh
	IOStream.icc
	MD5Sum.hh
	MD5SumFilter.hh
	Promotion.hh
	PTR_STRUCT.hh
	PTR_STRUCT_BASE.hh
	SearchContainer.hh
	SearchContainer.tcc
	StreamFilter.hh
	StreamRef.hh
	StreamRefInterface.hh
	STRING.hh
	StringStream.hh
	TOCInfo.hh
	Verify.hh
  )

set( SRCS
	BaseMemoryBuffer.cc
	CheckSumFilter.cc
	CheckSum.cc
	Compression.cc
	CompressionDifferential.cc
	CompressionGZip.cc
	CompressionZeroSuppress.cc
	CRC.cc
	Description.cc
	DetectorNames.cc
	Dictionary.cc
	DynamicMemoryBuffer.cc
	FrameBuffer.cc
	FrameBufferInterface.cc
	FrameFilename.cc
	FrameSpec.cc
	FrameStream.cc
	FrameStreamBase.cc
	FrameH.cc
	FrEndOfFile.cc
	FrHeader.cc
	FrStatData.cc
	FrTOC.cc
	FrVect.cc
	IOStream.cc
	MD5Sum.cc
	MD5SumFilter.cc
	MemoryBuffer.cc
	PTR_STRUCT.cc
	StdFileBuffer.cc
	StringStream.cc
	StreamFilter.cc
	StreamRef.cc
	StreamRefInterface.cc
	Verify.cc
)

list( APPEND noinst_HEADERS
  CRCTables.cc
  ComparePrivate.hh
  )

##------------------------------------------------------------------------

configure_file(
  ${CMAKE_CURRENT_SOURCE_DIR}/FrameSpec.hh.in
  ${CMAKE_CURRENT_BINARY_DIR}/FrameSpec.hh
  @ONLY
  )
cx_link_headers( ${HDR_DIR} ${hh_HEADERS} )
cx_link_headers( ${HDR_DIR} ${nodist_hh_HEADERS} BUILT_HEADERS )
cx_iterate( REPLACE ".cc" "_cmn.cc" built_srcs ${SRCS} )

cx_msg_debug_variable( built_srcs )

framecpp_create_cc_built_files( "_cmn.cc" ".cc" ${built_srcs} )

set( nodist_libframecppcmn_la_SOURCES ${built_srcs} )
set( libframecppcmn_la_LIBADD
  ${LDASTOOLS_LIBRARIES_FULL_PATH}
  ${LIBMD5}
  ${LIBZ}
  )
cx_target_library(
  TARGET framecppcmn
  CURRENT ${libframecppcmn_la_CURRENT}
  REVISION ${libframecppcmn_la_REVISION}
  AGE ${libframecppcmn_la_AGE}
  STATIC
  SOURCES ${nodist_libframecppcmn_la_SOURCES}
  LIBRARIES ${libframecppcmn_la_LIBADD}
  INCLUDE_DIRECTORIES BEFORE PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_BINARY_DIR}/include
    ${CMAKE_BINARY_DIR}
    ${LDASTOOLS_INCLUDE_DIRS}
  ABI_MESSAGE "FrameCPP Common Library"
  ABI_HEADER_DIR ${HDR_DIR}
  ABI_LOCAL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/${HDR_DIR}
  ABI_HEADERS
  ${hh_HEADERS}
  )

#------------------------------------------------------------------------
set( CRCGenTables_SOURCES CRCGenTables.cc )

cx_target_executable( CRCGenTables
  NOINST
  SOURCES ${CRCGenTables_SOURCES}
  )
#
#CRCTables.cc: CRCGenTables
#	./CRCGenTables CRCTables.cc
#

#------------------------------------------------------------------------

cx_install_header(
  FILES ${hh_HEADERS}
  DESTINATION "${hhdir}"
  )
cx_install_header(
  FILES ${nodist_hh_HEADERS}
  DESTINATION "${hhdir}"
  WORKINGDIR ${CMAKE_CURRENT_BINARY_DIR}
  )
cx_target_pkgconfig(
  framecpp_common
  )
