PROJECT(libcwmpdm.so)

ADD_DEFINITIONS(-Wall -Werror -Wformat -g)
ADD_DEFINITIONS(-D_GNU_SOURCE)
ADD_DEFINITIONS(-DBBF_VENDOR_PREFIX="${BBF_VENDOR_PREFIX}")

# Compile and install libcwmpdm.so
ADD_LIBRARY(cwmpdm SHARED datamodel.c)

# Copy libcwmpdm.so to the main repo
add_custom_command(
    TARGET cwmpdm
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy
            libcwmpdm.so
            ${CMAKE_SOURCE_DIR}
    COMMENT "Copying libcwmpdm.so to main repo"
)

# Add a custom target to trigger the custom command
add_custom_target(copy_lib_target
    DEPENDS cwmpdm
)

# Make sure the copy_lib_target is built after the library is built
add_dependencies(copy_lib_target cwmpdm)
