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

#------------------------------------------------------------------------
# => 2:0:0 -- 2009.12.03
#    In preperation for 1.18.0 release of ldas
# => 2:1:0 -- 2013.08.29 (post 1.19.33)
#    Modifications for static building
# 2:2:0 - 2016.04.20
#    Addressed infinite recursion warning
# 2:3:0 - 2016.09.09
#    Corrected comparison operator
# 3:0:0 - 2016.10.10
#    Converted to exclusive use of std::unique_ptr in place
#       of std::auto_ptr
# 4:0:0 - 2018.05.11 ( ldas-tools-framecpp-2.6.0 )
#    Removed hand rolled smart pointers in favor of boost smart pointers
# 5:0:1 - ldas-tools-framecpp-2.6.3
#    Added FrEndOfFile::NFrames()
# 5:1:1 - ldas-tools-framecpp-2.7.0
#    Added FrTOC::runs()
# 6:0:0 - ldas-tools-framecpp-2.7.2
#    Removed unnecessary routines
#------------------------------------------------------------------------
# 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 6 )
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
	FrEvent.cc
	FrRawData.cc
	FrSerData.cc
	FrSimData.cc
	FrSimEvent.cc
  )

set( support_srcs
	FrameSpec.cc
  )

set( built_hdrs
	Description.hh
	Dimension.hh
	GPSTime.hh
	PTR_STRUCT.hh
	StreamRef.hh
	STRING.hh
	FrAdcData.hh
	FrDetector.hh
	FrEndOfFile.hh
	FrEndOfFrame.hh
	FrHeader.hh
	FrHistory.hh
	FrMsg.hh
	FrProcData.hh
	FrProcDataNPS.hh
	FrProcDataPST.hh
	FrSE.hh
	FrSH.hh
	FrStatData.hh
	FrSummary.hh
	FrTable.hh
	FrTOC.hh
	FrTOCAdcData.hh
	FrTOCData.hh
	FrTOCEvent.hh
	FrTOCProcData.hh
	FrTOCSerData.hh
	FrTOCSimData.hh
	FrTOCSimEvent.hh
	FrTOCStatData.hh
	FrTOCSummary.hh
	FrVect.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( libframecpp${FRAME_SPEC}_la_SOURCES dummy.cc )
set( nodist_libframecpp${FRAME_SPEC}_la_SOURCES ${built_srcs} )

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

set( src_hdrs
  ${frame_struct_hdrs}
  ${support_hdrs}
	FrameStream.hh
	FrameStreamPlan.hh
	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(
  framecpp7
  )
