Adding Raspberry Pi support with CMakeLists.txt

realh wrote on Tuesday, December 17, 2013:

I want to try to get GLFW3 working on Raspberry Pi. I enabled EGL and glesv2 but my test app failed with an error about not being able to get the EGL display. I think this is because RPi has special versions of EGL and GLES2 in /opt/vc, but pkg-config still uses the mesa versions.

I tried to add a GLFW_RASPBERRY_PI option to CMakeLists.txt which forces on EGL and glesv2 but uses the hard-wired paths instead of pkg-config. The trouble is it needs at least another include path (possibly more): /opt/vc/include/interface/vcos. I tried adding it with this:

if (GLFW_RASPBERRY_PI)
    list(APPEND glfw_INCLUDE_DIRS "/opt/vc/include/interface/vcos")
endif()

but it has no effect. I think it’s because ultimately glfw_INCLUDE_DIRS doesn’t do anything, and the paths are all set with pkg-config. How can I get it to add the necessary compiler options? And I might have to do something similar with glfw_LIBRARIES?

I suppose the proper solution would be to replace the relevant .pc files with special RPi ones but it would be nice to know how to do an alternative fix with cmake.