sdl2-image provides CMake targets: find_package(SDL2_image CONFIG REQUIRED) target_link_libraries(main PRIVATE $,SDL2_image::SDL2_image,SDL2_image::SDL2_image-static>)