The package libmysql provides CMake targets:

    find_package(libmysql REQUIRED)
    target_link_libraries(main PRIVATE ${MYSQL_LIBRARIES})