#========================================================================
# -*- mode: cmake -*-
#
#------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)

set( MODULE_SOURCES
  LDASToolsCMakeConfig.cmake
  ${CMAKE_CURRENT_BINARY_DIR}/LDASToolsCMakeConfigVersion.cmake
  FindAxLDASExecutable.cmake
  FindAxLDASProject.cmake
  FindAxLDASTools.cmake
  LDASToolsInstallDirs.cmake
  cx_check_compile_flag.cmake
  cx_check_compile_hardening.cmake
  cx_install_license.cmake
  cx_boost_base.cmake
  cx_boost_chrono.cmake
  cx_boost_component.cmake
  cx_boost_date_time.cmake
  cx_boost_filesystem.cmake
  cx_boost_log.cmake
  cx_boost_log_setup.cmake
  cx_boost_program_options.cmake
  cx_boost_regex.cmake
  cx_boost_serialization.cmake
  cx_boost_system.cmake
  cx_boost_thread.cmake
  cx_pthread.cmake
  cx_static_libs.cmake
  )

configure_file(
  LDASToolsCMakeConfigVersion.cmake.in
  LDASToolsCMakeConfigVersion.cmake
  @ONLY
  )
#========================================================================
# Install files
#------------------------------------------------------------------------
install(
  FILES ${MODULE_SOURCES}
  DESTINATION "${LDASTOOLS_INSTALL_DATADIR}/cmake/Modules"
  )

# Local overrides of upstream igwn-cmake-macros helpers. See the
# per-file headers for the rationale — the short version is that on
# macOS 26 the upstream cm_try_run probe deadlocks inside the ASan
# runtime, and the answer on APPLE is knowable without executing
# anything. Installing under the same relative subpath causes these
# to shadow the upstream copies because LDASToolsCMake sits earlier
# on CMAKE_MODULE_PATH.
install(
  FILES
    Autotools/ArchiveX/cx_check_asan_runtime.cmake
    Autotools/ArchiveX/cx_scheme_sanitizer_asan.cmake
    Autotools/ArchiveX/cx_struct_procfs_stat.cmake
    Autotools/ArchiveX/cx_struct_procfs_psinfo.cmake
  DESTINATION "${LDASTOOLS_INSTALL_DATADIR}/cmake/Modules/Autotools/ArchiveX"
  )

# License-content templates consumed by cx_install_license().
# Must install to ../templates relative to the Modules install dir so
# the helper finds them via CMAKE_CURRENT_LIST_DIR/../templates.
install(
  FILES
    "${CMAKE_CURRENT_SOURCE_DIR}/../templates/COPYING.in"
    "${CMAKE_CURRENT_SOURCE_DIR}/../templates/LICENSE.md.in"
    "${CMAKE_CURRENT_SOURCE_DIR}/../templates/debian-copyright.in"
  DESTINATION "${LDASTOOLS_INSTALL_DATADIR}/cmake/templates"
  )
