#
# LDASTools frameCPP - A library implementing the LIGO/Virgo frame specification
#
# Copyright (C) 2025 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
#

#------------------------------------------------------------------------
# Version Registry - Consolidated version-specific frame specifications
#
# This directory contains all version-specific FrameSpec implementations
# (v3-v9) that register frame object types with the FrameSpec system.
# After the Universal namespace migration, this is the only location
# for version-specific code.
#------------------------------------------------------------------------

# Version Registry sources - these will be added to framecppu in parent CMakeLists.txt
set( version_registry_srcs
  VersionRegistry/VersionRegistry.cc
  VersionRegistry/Version3/FrameSpec.cc
  VersionRegistry/Version4/FrameSpec.cc
  VersionRegistry/Version5/FrameSpec.cc
  VersionRegistry/Version6/FrameSpec.cc
  VersionRegistry/Version7/FrameSpec.cc
  VersionRegistry/Version8/FrameSpec.cc
  VersionRegistry/Version9/FrameSpec.cc
  PARENT_SCOPE
)

# Version Registry headers for installation
# Headers are linked/installed to framecpp/Version3/, framecpp/Version4/, etc.
# for backward compatibility (not framecpp/Universal/VersionRegistry/...)

# Main VersionRegistry header
set( version_registry_hdrs
  VersionRegistry.hh
)

set( version3_hdrs
  Version3/FrameSpec.hh
)

set( version4_hdrs
  Version4/FrameSpec.hh
)

set( version5_hdrs
  Version5/FrameSpec.hh
  Version5/FrameStream.hh
  Version5/FrameStreamPlan.hh
)

set( version6_hdrs
  Version6/FrameSpec.hh
  Version6/FrameStream.hh
  Version6/FrameStreamPlan.hh
)

set( version7_hdrs
  Version7/FrameSpec.hh
  Version7/FrameStream.hh
  Version7/FrameStreamPlan.hh
)

set( version8_hdrs
  Version8/FrameSpec.hh
  Version8/FrameStream.hh
  Version8/FrameStreamPlan.hh
)

set( version8_impl_hdrs
  Version8/impl/FrameSpecVersion.hh
  Version8/impl/FrObjectMetaData.hh
)

set( version9_hdrs
  Version9/FrameSpec.hh
  Version9/FrameStream.hh
  Version9/FrameStreamPlan.hh
)

set( version9_impl_hdrs
  Version9/impl/FrameSpecVersion.hh
)

# Link headers for build
# VersionRegistry.hh goes to framecpp/Universal/
cx_link_headers( framecpp/Universal ${version_registry_hdrs} )

# Version-specific headers: Link to backward-compatible paths framecpp/VersionN/
# Source is at src/Universal/VersionRegistry/VersionN/, but linked to build/include/framecpp/VersionN/ for compatibility
foreach( version RANGE 3 9 )
  execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/framecpp/Version${version} )
endforeach( )
foreach( version RANGE 8 9 )
  execute_process( COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/framecpp/Version${version}/impl )
endforeach( )
cx_link_headers( framecpp ${version3_hdrs} )
cx_link_headers( framecpp ${version4_hdrs} )
cx_link_headers( framecpp ${version5_hdrs} )
cx_link_headers( framecpp ${version6_hdrs} )
cx_link_headers( framecpp ${version7_hdrs} )
cx_link_headers( framecpp ${version8_hdrs} )
cx_link_headers( framecpp ${version8_impl_hdrs} )
cx_link_headers( framecpp ${version9_hdrs} )
cx_link_headers( framecpp ${version9_impl_hdrs} )

# Install headers
# VersionRegistry.hh to framecpp/Universal/
cx_install_header(
  FILES ${version_registry_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Universal"
)

# Version-specific headers use original paths for backward compatibility
cx_install_header(
  FILES ${version3_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version3"
)
cx_install_header(
  FILES ${version4_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version4"
)
cx_install_header(
  FILES ${version5_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version5"
)
cx_install_header(
  FILES ${version6_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version6"
)
cx_install_header(
  FILES ${version7_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version7"
)
cx_install_header(
  FILES ${version8_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version8"
)
cx_install_header(
  FILES ${version8_impl_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version8/impl"
)
cx_install_header(
  FILES ${version9_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version9"
)
cx_install_header(
  FILES ${version9_impl_hdrs}
  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/framecpp/Version9/impl"
)
