#
# 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 )
set( FRAME_SPEC_PREVIOUS 7 )

add_subdirectory( impl )

#------------------------------------------------------------------------
# 2:1:0 - 2010.03.03 - Checking of expandability is governed by Verifier
#  2:0:0 -- 2009.12.03
#    In preperation for 1.18.0 release of ldas
# 3:0:0 - 2013.08.22 (post ldas-1.19.32)
#    FrEndOfFile::Filter() parameters modified
#  3:1:0 -- 2013.08.29 (post 1.19.33)
#    Modifications for static building
#  4:0:0 - 2015.05.08
#    Modified TOC handling code.
# 5:0:0 - 2016.03.03
#    Code cleanup
# 5:1:0 - 2016.04.20
#    Addressed infinite recursion warning
# 5:2:0 - 2016.09.09
#    Corrected comparison operator
# 6:0:0 - 2016.10.10
#    Converted to exclusive use of std::unique_ptr in place
#       of std::auto_ptr
# 6:1:0 - 2017.11.06 (ldas-tools-framecpp-2.5.8)
#    Corrections for GCC 7.2.0 and XCode 9.0
# 7:0:0 - 2018.05.11 ( ldas-tools-framecpp-2.6.0 )
#    Removed hand rolled smart pointers in favor of boost smart pointers
# 8:0:1 - ldas-tools-framecpp-2.6.3
#    Added FrEndOfFile::NFrames()
#    Added FrTOC::runs()
# 8:1:1 - ldas-tools-framecpp-2.7.0
#    Updated doxygen
# 8:2:1 - ldas-tools-framecpp-2.7.1
#    Compiler updates
#    Serialization
# 9:0:0 - ldas-tools-framecpp-2.7.2
#------------------------------------------------------------------------
# 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 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( libframecpp${FRAME_SPEC}_la_CURRENT 9 )
set( libframecpp${FRAME_SPEC}_la_REVISION 0 )
set( libframecpp${FRAME_SPEC}_la_AGE 0 )

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

#=========================================================================
# Frame Source and Headers
#=========================================================================

set( frame_struct_srcs
	FrameH.cc
	FrAdcData.cc
	FrDetector.cc
	FrEndOfFile.cc
	FrEndOfFrame.cc
	FrEvent.cc
	FrHeader.cc
	FrHistory.cc
	FrMsg.cc
	FrProcData.cc
	FrRawData.cc
	FrSE.cc
	FrSerData.cc
	FrSH.cc
	FrSimData.cc
	FrSimEvent.cc
	FrStatData.cc
	FrSummary.cc
	FrTable.cc
	FrTOC.cc
	FrVect.cc
  )

set( support_srcs
	Dimension.cc
	FrameSpec.cc
	StreamRef.cc
  )

set( built_hdrs
	GPSTime.hh
	STRING.hh
	PTR_STRUCT.hh
	FrProcDataNPS.hh
	FrProcDataPST.hh
  )


cx_iterate( REPLACE ".cc" ".hh" frame_struct_hdrs ${frame_struct_srcs} )
cx_iterate( REPLACE ".cc" ".hh" support_hdrs ${support_srcs} )
set( SRCS ${frame_struct_srcs} ${support_srcs} )
cx_iterate( REPLACE ".cc" "${FRAME_SPEC}.cc" built_srcs ${SRCS} )

set( libframecpp8_la_SOURCES dummy.cc )
set( nodist_libframecpp${FRAME_SPEC}_la_SOURCES ${built_srcs} )

set( libframecpp${FRAME_SPEC}_la_LIBADD
	framecpp${FRAME_SPEC_PREVIOUS}
  )

set( noinst_HEADER
	TypeInstantiation.tcc
  )

set( src_hdrs
  ${frame_struct_hdrs}
  ${support_hdrs}
	FrameStream.hh
	FrameStreamPlan.hh
	FrTOCTypes.hh
	FrVect.tcc
	Types.hh
  )

set( hh_HEADERS ${src_hdrs} )
set( nodist_hh_HEADERS ${built_hdrs} )


set( EXTRA_DIST ${SRCS} )

framecpp_hdr_builder(
  VERSION ${FRAME_SPEC}
  HEADERS ${built_hdrs}
  )
framecpp_create_cc_built_files( "${FRAME_SPEC}.cc" ".cc" ${built_srcs} )

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

cx_target_library(
  TARGET framecpp${FRAME_SPEC}
  CURRENT ${libframecpp${FRAME_SPEC}_la_CURRENT}
  REVISION ${libframecpp${FRAME_SPEC}_la_REVISION}
  AGE ${libframecpp${FRAME_SPEC}_la_AGE}
  STATIC
  SOURCES ${nodist_libframecpp${FRAME_SPEC}_la_SOURCES}
  LIBRARIES ${libframecpp${FRAME_SPEC}_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 Library for Version ${FRAME_SPEC}"
  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(
  framecpp8
  )
