# Build test modules
list(APPEND MODULES_LIST "commandfilter")
list(APPEND MODULES_LIST "basics")
list(APPEND MODULES_LIST "testrdb")
list(APPEND MODULES_LIST "fork")
list(APPEND MODULES_LIST "infotest")
list(APPEND MODULES_LIST "propagate")
list(APPEND MODULES_LIST "misc")
list(APPEND MODULES_LIST "hooks")
list(APPEND MODULES_LIST "blockonkeys")
list(APPEND MODULES_LIST "blockonbackground")
list(APPEND MODULES_LIST "scan")
list(APPEND MODULES_LIST "datatype")
list(APPEND MODULES_LIST "datatype2")
list(APPEND MODULES_LIST "auth")
list(APPEND MODULES_LIST "keyspace_events")
list(APPEND MODULES_LIST "blockedclient")
list(APPEND MODULES_LIST "getkeys")
list(APPEND MODULES_LIST "getchannels")
list(APPEND MODULES_LIST "test_lazyfree")
list(APPEND MODULES_LIST "timer")
list(APPEND MODULES_LIST "defragtest")
list(APPEND MODULES_LIST "keyspecs")
list(APPEND MODULES_LIST "hash")
list(APPEND MODULES_LIST "zset")
list(APPEND MODULES_LIST "stream")
list(APPEND MODULES_LIST "mallocsize")
list(APPEND MODULES_LIST "aclcheck")
list(APPEND MODULES_LIST "list")
list(APPEND MODULES_LIST "subcommands")
list(APPEND MODULES_LIST "reply")
list(APPEND MODULES_LIST "cmdintrospection")
list(APPEND MODULES_LIST "eventloop")
list(APPEND MODULES_LIST "moduleconfigs")
list(APPEND MODULES_LIST "moduleconfigstwo")
list(APPEND MODULES_LIST "publish")
list(APPEND MODULES_LIST "usercall")
list(APPEND MODULES_LIST "postnotifications")
list(APPEND MODULES_LIST "moduleauthtwo")
list(APPEND MODULES_LIST "rdbloadsave")
list(APPEND MODULES_LIST "crash")
list(APPEND MODULES_LIST "cluster")
list(APPEND MODULES_LIST "helloscripting")

foreach (MODULE_NAME ${MODULES_LIST})
    message(STATUS "Building test module: ${MODULE_NAME}")
    add_library(${MODULE_NAME} SHARED "${CMAKE_SOURCE_DIR}/tests/modules/${MODULE_NAME}.c")
    target_include_directories(${MODULE_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/src")
    if (LINUX AND NOT APPLE)
        # set the std to gnu11 here, to allow crash.c to get compiled
        target_compile_options(${MODULE_NAME} PRIVATE "-std=gnu11")
    endif ()
    set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
    valkey_install_bin(${MODULE_NAME})
    if (APPLE)
        # Some symbols can only be resolved during runtime (they exist in the executable)
        target_link_options(${MODULE_NAME} PRIVATE -undefined dynamic_lookup)
    endif ()
endforeach ()
