#------------------------------------------------------------------------
# -*- mode: cmake -*-
#------------------------------------------------------------------------
#
# LDASTools Frame Library  - Frame library
#
# Copyright (C) 2018 California Institute of Technology
#
# LDASTools Frame Library  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 Frame Library 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
#
#------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.12...4.0)

set( LDAS_TOOLS_SUITE_PACKAGE_NAME ldas-tools-suite )
set( LDAS_TOOLS_SUITE_VERSION      3.3.1)
set( MAINTAINER_NAME               "Edward Maros" )
set( MAINTAINER_EMAIL              "ed.maros@ligo.org" )

set( LDAS_TOOLS_CMAKE_VERSION         1.5.1 )

# ldas-tools-suite is a metapackage (issue #256): its debian/control.in
# Depends: block, rpm/*.spec.in Requires: block, and config/meta.yaml.in
# run: block pin every component of the LDAS Tools Suite to its release
# version. Those templates are substituted at cmake-configure time by
# .gitlab-ci-local/configure_packaging_file.cmake, which sources variables
# from this file's scope only — so every @LDAS_TOOLS_*_VERSION@ referenced
# by those templates must be defined here. The values match
# suite/PackageVersions.md and are bumped by /ldas-release-plan alongside
# the sub-package bumps.
set( LDAS_TOOLS_AL_VERSION             2.10.0 )
set( LDAS_TOOLS_AL_SWIG_VERSION        2.6.14 )
set( LDAS_TOOLS_LDASGEN_VERSION        2.7.8 )
set( LDAS_TOOLS_LDASGEN_SWIG_VERSION   2.6.14 )
set( LDAS_TOOLS_FILTERS_VERSION        2.6.10 )
set( LDAS_TOOLS_FRAMECPP_VERSION       4.1.1 )
set( LDAS_TOOLS_FRAMECPP_SWIG_VERSION  3.1.2 )
set( LDAS_TOOLS_DISKCACHEAPI_VERSION       2.7.11 )
set( LDAS_TOOLS_DISKCACHEAPI_SWIG_VERSION  2.6.16 )
set( LDAS_TOOLS_FRAMEAPI_VERSION       3.0.8 )
set( LDAS_TOOLS_FRAMEAPI_SWIG_VERSION  2.6.16 )
set( LDAS_TOOLS_UTILITIES_VERSION      2.7.6 )

set( PROJECT_SUMMARY
  "LDAS Tools suite"
  )
set(
  PROJECT_DESCRIPTION
  "This provides information about the LDAS Tools Suite."
  )
set(
  PROJECT_DESCRIPTION_LONG
  "This is an overview of the collection of packages know as"
  " the LDAS Tools Suite."
  )

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

project( ${LDAS_TOOLS_SUITE_PACKAGE_NAME} LANGUAGES NONE )

#------------------------------------------------------------------------
# Locate the standard LDAS Tools cmake macro directory
#------------------------------------------------------------------------

find_package(
  LDASToolsCMake
  CONFIG
  REQUIRED
  HINTS ${CMAKE_INSTALL_PREFIX}/share/ldas-tools/cmake/Modules
  )

#========================================================================
# Start pulling in the LDAS Tools macros for easy setup
#========================================================================

find_package(AxLDASTools)

cm_init(
  ${LDAS_TOOLS_SUITE_PACKAGE_NAME}
  "${LDAS_TOOLS_SUITE_VERSION}"
  ${LDAS_TOOLS_BUG_REPORT_URL}
  ${LDAS_TOOLS_SUITE_PACKAGE_NAME}
  ${LDAS_TOOLS_HOMEPAGE_URL}
  LANGUAGES NONE
  DESCRIPTION "${PROJECT_DESCRIPTION}"
  )
# Render COPYING, LICENSE.md, debian/copyright from suite-wide templates.
# See ldastools_cmake/Modules/cx_install_license.cmake (issue #267).
cx_install_license( )

#dnl =====================================================================
#dnl  Prepare a header file to store the glorious configuration info
#dnl =====================================================================

# =====================================================================
#  Check for compilers and language features
# =====================================================================

# =====================================================================
#  Check for key programs
# =====================================================================

# ---------------------------------------------------------------------
#  Checks for packaging
# ---------------------------------------------------------------------

# =====================================================================
#  Check for header files
# =====================================================================

# =======================================================================
#  Check for key programs
# =======================================================================

# =====================================================================
#  Check for structures/sizes
# =====================================================================

# =====================================================================
#  Check for individual libraries
# =====================================================================

#========================================================================
# Traverse the tree
#========================================================================

add_subdirectory(doc)

#========================================================================
# Prepare the distribution
#========================================================================

# Issue #307: distribution-template relocation. See ldastoolsal/CMakeLists.txt
# for the rationale.
set( PROJECT_DEBIAN_CONTROL_INPUT_FILENAME
  "${CMAKE_CURRENT_SOURCE_DIR}/debian/control.in" )

cx_cpack(
  MACPORTS_CATEGORY devel
  MAINTAINER "${MAINTAINER_NAME} <${MAINTAINER_EMAIL}>"
  RPM_SPEC_FILE_TEMPLATE
    "${CMAKE_CURRENT_SOURCE_DIR}/rpm/${PROJECT_NAME}.spec.in"
  )

#========================================================================
# Report configuration information
#  CMAKE_MAKE_PROGRAM:FILEPATH
#========================================================================
cm_msg_notice( "=========================================================")
cm_msg_notice( " Project ${PROJECT_NAME} has now ben successfully configured:" )
cm_msg_notice( "      VERSION: ${PROJECT_VERSION}" )
cm_msg_notice( " " )
cm_msg_notice( " installation directories:" )
cm_msg_notice( "      CMAKE_INSTALL_BINDIR           ${CMAKE_INSTALL_BINDIR}" )
cm_msg_notice( "      CMAKE_INSTALL_DATADIR          ${CMAKE_INSTALL_DATADIR}" )
cm_msg_notice( " package information:" )
cm_msg_notice( "      LDASTOOLS_FOUND:               ${LDASTOOLS_FOUND}" )
cm_msg_notice( "      LDASTOOLS_LIBRARIES:           ${LDASTOOLS_LIBRARIES}" )
cm_msg_notice( "      LDASTOOLS_LIBRARIES_FULL_PATH: ${LDASTOOLS_LIBRARIES_FULL_PATH}" )
cm_msg_notice( " " )
cm_msg_notice( "  Now run 'cmake --build .' to build ${PROJECT_NAME}" )
cm_msg_notice( "  and run 'cpack' to package ${PROJECT_NAME}" )
cm_msg_notice( "=========================================================" )
