# port/core: the game region of each disc the port plays (region.h; the
# rows of config/regions.txt).
#
#   ico_region  region.c (the game's index ico_region, the selection and
#               the look-ups), region_table.c (ico_region_info[] in the
#               table's order, generated by tools/region_blocks.py
#               gen-table) and region_<slug>.c (each row's numbers):
#               plain data, no game header but ico2/common/include/region.h, compiled once and
#               linked by the program and by every test program that
#               compiles game sources (the top-level CMakeLists.txt,
#               ico_link_region), since the game code reads ico_region
add_library(ico_region STATIC region.c region_table.c region_pal.c region_jpn.c region_kor.c region_ntsc.c region_aug6.c region_jun26.c region_cn.c)
target_include_directories(ico_region PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
                                             "${CMAKE_SOURCE_DIR}/ico2/common/include")
target_compile_options(ico_region PRIVATE ${ICO_SEMANTIC_OPTIONS} ${ICO_PORT_WARNINGS})

# region_select_test: every slug selects and ico_region follows, nothing else
# selects; the selectors and LN on each row; the disc ids; the per-disc config
# keys; the stage rows on each disc; ico_region_info[] in config/regions.txt's
# order (read at test time); every value of the Japanese and Korean rows (CPU
# only); the disc table ico_discs
# (port/data/discs.c, plain data, compiled in) against the same rows. The
# argument: the table.
add_executable(region_select_test test/region_select_test.c "${CMAKE_SOURCE_DIR}/port/data/discs.c")
target_include_directories(region_select_test PRIVATE "${CMAKE_SOURCE_DIR}/port/data")
target_compile_options(region_select_test PRIVATE ${ICO_SEMANTIC_OPTIONS} ${ICO_PORT_WARNINGS})
target_link_libraries(region_select_test PRIVATE ico_region)
if(ICO_RUN_TESTS)
    add_test(NAME region_select COMMAND region_select_test "${CMAKE_SOURCE_DIR}/config/regions.txt")
endif()
