Sorry, I know very little about CMake - but couldn't you simply set SDL_BUILDING_LIBRARY to stop the linker error?