by oln » 12 Nov 2014, 19:35
You seem to be setting both the "-lSDL2" in the compiler flags and telling cmake to link with SDL with target_link_libraries. You don't need both. target_link_libraries links the provided libraries, you don't need to add the linker flags manually.
You can also use the "find_package" command to locate libraries, which is the common way of using cmake, but you will need to look on the web for a FindSDL2.cmake module, as the one coming with cmake is not updated for SDL2.
I would recommend looking at other projects using cmake to see how they are set up, cmake can be a bit confusing to get used to.