Don't add manually DWITH_OPENGL flags. Use PKG_CONFIG_USE_DEPENDENCY instead.