Clion: Could NOT find SDL2... Even when I put everything in the exact location


So when loading the Cmake for SDL2, I got this error.

Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)

Problem is, I have put everything in the correct location:

- The Path in the FindSDL2.Cmake file:

- The SDL2 Library

So I am 100% sure that this is not because of me writing some wrong location. To prove it further, I have added the PATH_SUFFIXES to the SDL2_INCLUDE_DIR:

After doing so, it only becomes:

missing: SDL2_LIBRARY

So, yeah, to add for information, if I change the SDL2 files to some other folders, it sometimes work, and sometimes doesn't. I am 200% sure this is not my fault of setting the wrong directory. 

This stupid error has been torturing me for a week now. 

Please, any idea on how to fix this :<

Comment actions Permalink

@Anna Falevskaya

I pushed Enter by an error so the page published my question without information. I have edited my post. Please unmark my question as answered.

Comment actions Permalink

On the following screenshot there is the unnecessary [ in the path:

Is it like this in your real project? Could you please remove it and reload the CMake project (Tools | CMake | Reset Cache and Reload Project)?

Comment actions Permalink

@Anna Falevskaya

okay, I see the problem. It seems that the [ is from my stupidity for sure, but Cmake sometimes keeps holding to the old Cmake cache I think, so delete CMakeCache.txt to make sure it reloads.

Thank you for the , my savior.

Comment actions Permalink

I'm glad that resetting cache helped! :)


Please sign in to leave a comment.