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