#========================================================================
# -*- mode: cmake -*-
#------------------------------------------------------------------------
# Tests for igwn-cmake macros.
#
# Test drivers in this directory exercise the macros from Modules/. They
# are not themselves modules and are not installed -- only registered with
# ctest. Each driver is a standalone `cmake -P` script; per-test skip
# logic (e.g. "skip if Python not installed") lives inside the driver.
#------------------------------------------------------------------------

add_test(
  NAME cx_python_functional
  COMMAND ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" -P ${CMAKE_CURRENT_SOURCE_DIR}/cx_python_test.cmake )

# Precedence + warning coverage for cm_init (issue #43). Each scenario
# runs in a child cmake -P process so its variable environment is
# isolated. Fast but cmake -P script mode cannot actually call
# project() -- the scenarios fabricate the "post-project()" state by
# directly setting PROJECT_NAME / PROJECT_VERSION / etc.
add_test(
  NAME cm_init_precedence
  COMMAND ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" -P ${CMAKE_CURRENT_SOURCE_DIR}/cm_init_precedence_test.cmake )

# End-to-end configure-mode coverage for cm_init's project()-first
# detection (issues #20 + #43). Each scenario generates a tiny
# mini-project that actually calls project() in one of cmake's
# documented forms, then cm_init(), and runs a full cmake configure
# via execute_process. Asserts on the resolved PROJECT_* values and
# on AUTHOR_WARNING emission. Closes the gap that the script-mode
# cm_init_precedence test cannot cover (project() is invalid in
# cmake -P mode).
add_test(
  NAME cm_init_configure
  COMMAND ${CMAKE_COMMAND} "-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" -P ${CMAKE_CURRENT_SOURCE_DIR}/cm_init_configure_test.cmake )
