Fix OpenGL detection and miniswig wrapper generation for CMake