Can you share your top level CMakeLists.txt where you call add_subdirectory() for the SDL libraries? I don't know for sure, but I suspect that targets from those SDL_* subdirectories are clashing with eachother.
This has a more complete sample to build just about what you're describing: https://github.com/Ravbug/sdl3-sample/blob/main/CMakeLists.txt#L65
SDL2-image build also outputs this somewhere in the process:
To this problem, that's happening here: https://github.com/libsdl-org/SDL_image/blob/release-2.8.x/cmake/FindSDL2main.cmake#L6
I think you can fix that by setting SDL2_DIR variable to point to your build directory.
Also I think its finding libSDL2main.a in /usr/local/lib because that's where cmake installs built libraries by default, so I suspect this SDL subdirectory is getting built then installed there.
This line prevents that from happening
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE INTERNAL "")
Also from that sample https://github.com/Ravbug/sdl3-sample/blob/main/CMakeLists.txt#L8-L9