Using CMake to setup OpenGL on OSX Yosemite (10.10)


I am kind of new to C++ development on Mac as it has been a while since I was hacking on Linux.

I am not sure if I have found a bug in the latest EAP build:
CLion CL-143.249.8
Build #CL-143.249, built on October 14, 2015
JRE: 1.8.0_40-release-b92 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

The problem seems to be that CLion generates an incorrect include statement using the automagic feature of "option-return". It generates a: "#include <OpenGL/OpenGL.h>" which is the limited CGL stuff. However, the correct the statement should be "#include <OpenGL/gl.h>".

Is this a bug? Or is there something else I should do in the cmakelists.txt file to fix it?

Comment actions Permalink

Hi William.

Sorry for the inconvenience, we have several issues about auto-import feature. For example:
Please upvote.

Could you please send us an example to reproduce your problem with OpenGL? I will create the issue in the tracker or you can add it:

Also you can turn off auto-import pop ups via Editor | General | Auto-import. The pop-up with include suggestion won’t show up in that case, though you’ll still be able to invoke an auto-import when necessary using an intention action (Alt+Enter).

You can find out more information about this feature in our blog:
Comment actions Permalink

Hi Anna,

I have included the 3 files that make up the simple project.

The Auto-import feature seems to work most of the time. In this case it seems to fixate on the OpenGL.h file rather than the gl.h file. There must be some way to specifiy which one to use in the cmakelists.txt file, otherwise I can understand why CLion would get confused from the ambiquos situation after all they are both in the same include directory so how would it know which one to choose. To me it is obvious because I can inspect both headers and easily see which one is the correct one. Technically they are both opengl header files. I guess CLion would parse the headers to figure out which one to use and this must be where the problem is.

Anyway, thanks for the tip.

Comment actions Permalink

Hi William.

Thanks for the details! I've found the same issue: Feel free to comment or upvote.


Please sign in to leave a comment.