include(${SIPLASPLAS_REFLECTION_MODULE})

function(add_example NAME)
    cmake_parse_arguments(
        "EXAMPLE"
        ""
        ""
        "INSTALL_SOURCES"
        ${ARGN}
    )

    add_siplasplas_executable(${NAME}
        ${EXAMPLE_UNPARSED_ARGUMENTS}
        SOURCES ${NAME}.cpp
        INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/examples"
        NAMESPACE examples
    )

    target_include_directories(examples-${NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

    install_siplasplas_example(examples-${NAME}
        SOURCES ${EXAMPLE_INSTALL_SOURCES} ${NAME}.cpp
    )
endfunction()

function(add_reflection_example NAME)
    cmake_parse_arguments(ARGS
        ""
        ""
        "DEPENDS;INSTALL_SOURCES"
        ${ARGN}
    )

    list(APPEND ARGS_DEPENDS siplasplas-reflection)

    if(ARGS_INSTALL_SOURCES)
        set(install_sources INSTALL_SOURCES ${ARGS_INSTALL_SOURCES})
    endif()

    add_example(${NAME} DEPENDS ${ARGS_DEPENDS} ${install_sources} ${ARGS_UNPARSED_ARGUMENTS})
    configure_siplasplas_reflection(examples-${NAME})
endfunction()

add_subdirectory(3rdParty)
add_subdirectory(utility)
add_subdirectory(allocator)
add_subdirectory(reflection)
add_subdirectory(variant)
add_subdirectory(metatype)
add_subdirectory(signals)
add_subdirectory(fswatch)
add_subdirectory(cmake)

include(${SIPLASPLAS_REFLECTION_MODULE})

function(add_example NAME)
    cmake_parse_arguments(
        "EXAMPLE"
        ""
        ""
        "INSTALL_SOURCES"
        ${ARGN}
    )

    add_siplasplas_executable(${NAME}
        ${EXAMPLE_UNPARSED_ARGUMENTS}
        SOURCES ${NAME}.cpp
        INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/examples"
        NAMESPACE examples
    )

    target_include_directories(examples-${NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

    install_siplasplas_example(examples-${NAME}
        SOURCES ${EXAMPLE_INSTALL_SOURCES} ${NAME}.cpp
    )
endfunction()

function(add_reflection_example NAME)
    cmake_parse_arguments(ARGS
        ""
        ""
        "DEPENDS;INSTALL_SOURCES"
        ${ARGN}
    )

    list(APPEND ARGS_DEPENDS siplasplas-reflection-dynamic)

    if(ARGS_INSTALL_SOURCES)
        set(install_sources INSTALL_SOURCES ${ARGS_INSTALL_SOURCES})
    endif()

    add_example(${NAME} DEPENDS ${ARGS_DEPENDS} ${install_sources} ${ARGS_UNPARSED_ARGUMENTS})
    configure_siplasplas_reflection(examples-${NAME})
endfunction()

add_subdirectory(3rdParty)
add_subdirectory(utility)
add_subdirectory(allocator)
add_subdirectory(reflection)
add_subdirectory(variant)
add_subdirectory(metatype)
add_subdirectory(signals)
add_subdirectory(fswatch)
add_subdirectory(cmake)

Remove old add_reflection_example() function from reflection examples config
Remove old add_reflection_example() function from reflection examples config
