#
# 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
#

set( FRAME_SPEC 8 )

#==========================================================================
# Libraries
#==========================================================================

#------------------------------------------------------------------------
# 2:0:0 -- 2009.12.03
#   In preperation for 1.18.0 release of ldas
#........................................................................
# 3:0:0 -- 2012.02.12 -- RELEASED 1.19.24
#   In preperation for 1.19.21 release of ldas
#........................................................................
# 4:0:1 -- 2012.06.07
#    Added FrameLibraryName() to IFrameStreamWrapper< DECL_PARAMS>
#........................................................................
# 5:0:0 -- 2013.07.01
#    Many changes
# 5:1:0 -- 2013.08.29 (post 1.19.33)
#    Modifications for static building
# 6:0:0 -- 2015.05.08
#    Changes to lower level libraries
# 7:0:0 - 2016.10.10
#    Changes to lower level libraries
# 8:0:0 - 2017.02.13
#    Changed for FrEvent reading
# 9:0:0 - 2017.08.25
#    Extended FrameH interface
# 10:0:0 - 2018.05.11 ( ldas-tools-framecpp-2.6.0 )
#    Removed hand rolled smart pointers in favor of boost smart pointers
# 11:0:1 - ldas-tools-framecpp-2.6.3
#    Added FrEndOfFile::NFrames()
#    Added FrTOC::runs()
# 12:0:0 - ldas-tools-framecpp-2.6.5
#    Change signature of IFrameStream::GetTOC()
# 12:1:0 - ldas-tools-framecpp-2.7.0
#    Updated doxygen
# 13:0:0 - ldas-tools-framecpp-2.7.2
#    Updated because of libframecpp8 changes
#------------------------------------------------------------------------
# form: <(c)urrent>:<(r)elease>:<(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 release (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 release 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( libframecpp_la_CURRENT 13 )
set( libframecpp_la_REVISION 0 )
set( libframecpp_la_AGE 0 )

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

#=========================================================================
# General files
#=========================================================================

#=========================================================================
# Generic interface
#=========================================================================

set( Dimension_BRIEF "Dimension information for a Vect." )
set( FrameH_BRIEF "Frame Header Structure" )
set( FrVect_BRIEF "Container for single and multiple dimension data sets." )

set( built_hdrs
	Dimension.hh
	GPSTime.hh
	STRING.hh
	FrameStream.hh
	FrameH.hh
	FrAdcData.hh
	FrDetector.hh
	FrEvent.hh
	FrEndOfFileBase.hh
	FrHistory.hh
	FrMsg.hh
	FrProcData.hh
	FrRawData.hh
	FrSerData.hh
	FrSimData.hh
	FrSimEvent.hh
	FrStatData.hh
	FrSummary.hh
	FrTable.hh
	FrTOC.hh
	FrVect.hh
 )

set( INTERFACE_HDRS
	FrameCPP.hh
	Detectors.hh
	IFrameStream.hh
	IFrameStreamPlan.hh
	OFrameStream.hh
	Time.hh
	Types.hh
  )

set( INTERFACE_SRCS
	Detectors.cc
	FrameCPP.cc
  )

set( non_built_hdrs
	${INTERFACE_HDRS}
  )

list( APPEND libframecpp_la_SOURCES  ${INTERFACE_SRCS} )
list( APPEND hh_HEADERS  ${INTERFACE_HDRS} )
set( nodist_hh_HEADERS ${built_hdrs} )


#==========================================================================
# Documentation
#==========================================================================

list( APPEND EXTRA_DIST 
	CPlusPlusInterface.txt
  )

#=========================================================================
# Generic Rules
#=========================================================================
#=========================================================================
# Build the library
#=========================================================================

set( libframecpp_la_LIBADD 
	framecpp8
#	${LDASTOOLSAL_LDFAGS}
  )

#if HAVE_LIBZ
#libframecpp_la_LIBADD += -lz
#endif

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

cx_link_headers( ${HDR_DIR} ${hh_HEADERS} )
cx_link_headers( ${HDR_DIR} ${nodist_hh_HEADERS} BUILT_HEADERS )

framecpp_interface_hdr_builder(
  VERSION ${FRAME_SPEC}
  HEADERS ${built_hdrs}
  )

cx_target_library(
  TARGET framecpp
  CURRENT ${libframecpp_la_CURRENT}
  REVISION ${libframecpp_la_REVISION}
  AGE ${libframecpp_la_AGE}
  STATIC
  SOURCES ${libframecpp_la_SOURCES}
  LIBRARIES ${libframecpp_la_LIBADD}
  INCLUDE_DIRECTORIES BEFORE PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_SOURCE_DIR}/src
    ${CMAKE_BINARY_DIR}/include
    ${CMAKE_BINARY_DIR}
    ${LDASTOOLS_INCLUDE_DIRS}
  ABI_MESSAGE "FrameCPP C++ Library"
  ABI_HEADER_DIR ${HDR_DIR}
  ABI_LOCAL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/${HDR_DIR}
  ABI_HEADERS
  ${hh_HEADERS}
  )

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

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
  )
