# CS-08 shopping cart and checkout, built in steps. Each step is the whole
# program at that point in the study, and is built and tested on its own.
#   step-1  cart, catalog, pricing with promotions, inventory reservation,
#           checkout with a stubbed payment gateway and idempotent submission
#   step-2  change: coupons, with stacking rules and one use per customer
set(cs_cart_sources_1 cart.cpp checkout.cpp fake_gateway.cpp inventory.cpp pricing.cpp)
set(cs_cart_sources_2 ${cs_cart_sources_1} coupon_book.cpp)
foreach(step IN ITEMS 1 2)
  list(TRANSFORM cs_cart_sources_${step} PREPEND step-${step}/ OUTPUT_VARIABLE sources)
  add_library(cs_cart_step${step} STATIC ${sources})
  target_include_directories(cs_cart_step${step} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/step-${step})
  lld_add_test(cs_cart_step${step}_tests
    SOURCES step-${step}/tests/test_step${step}.cpp LABELS unit)
  target_link_libraries(cs_cart_step${step}_tests PRIVATE cs_cart_step${step})
  lld_add_example(cs_cart_step${step}_demo SOURCES step-${step}/main.cpp
    EXPECTED_OUTPUT step-${step}/expected_output.txt)
  target_link_libraries(cs_cart_step${step}_demo PRIVATE cs_cart_step${step})
endforeach()
