CMAKE can't find EGL with VCPKG in windows

224 Views Asked by At

I'm porting a working project to windows, I'm using vcpkg to manage non-native libraries. The setup seem to be working alright as many libraries are correctly found by cmake (ie: freetype, openssh, libzip, tesseract, leptonica,...) but opengl is failing. CMake finds OpenGl but it doesn't find EGL and EGL libraries are installed (with vcpkg).

Relevant contents of VCPKG installation:

ls installed/x64-windows/lib/
ANGLE.lib     brotlicommon.lib              cairo.lib       freetype.lib  jpeg.lib              libcurl.lib         libpgport.lib    libssl.lib          libxml2.lib     mbedtls.lib   pkgconfig/       sqlite3.lib      utf8proc.lib
GlU32.Lib     brotlidec.lib                 charset.lib     getopt.lib    leptonica-1.83.1.lib  libecpg.lib         libpgtypes.lib   libwebp.lib         lz4.lib         mbedx509.lib  pthreadVC3.lib   ssh.lib          zlib.lib
OpenGL32.Lib  brotlienc.lib                 dl.lib          gif.lib       libEGL.lib            libecpg_compat.lib  libpng16.lib     libwebpdecoder.lib  lzma.lib        openjp2.lib   pthreadVCE3.lib  tesseract53.lib  zstd.lib
ZXing.lib     bz2.lib                       fmt.lib         iconv.lib     libGLESv2.lib         libexpat.lib        libpq.lib        libwebpdemux.lib    lzo2.lib        pixman-1.lib  pthreadVSE3.lib  tiff.lib
archive.lib   cairo-script-interpreter.lib  fontconfig.lib  intl.lib      libcrypto.lib         libpgcommon.lib     libsharpyuv.lib  libwebpmux.lib      mbedcrypto.lib  pkgconf.lib   spdlog.lib       turbojpeg.lib

ls installed/x64-windows/include/
EGL/    ZXing/           dirent.h         expat_config.h    glm/        jpeglib.h       libssh/            lz4hc.h       opj_stdint.h        pgtypes_interval.h   postgres_ext.h  sqlca.h                 tiff.h       zdict.h
GL/     _ptw32.h         dlfcn.h          expat_external.h  headers/    leptonica/      libxml/            lzma/         pg_config.h         pgtypes_numeric.h    psa/            sqlda-compat.h          tiffconf.h   zlib.h
GLES/   archive.h        ecpg_config.h    fmt/              iconv.h     libcharset.h    libxml2/           lzma.h        pg_config_ext.h     pgtypes_timestamp.h  pthread.h       sqlda-native.h          tiffio.h     zstd.h
GLES2/  archive_entry.h  ecpg_informix.h  fontconfig/       informix/   libintl.h       localcharset.h     lzo/          pg_config_manual.h  pixman-1/            sched.h         sqlda.h                 tiffvers.h   zstd_errors.h
GLES3/  brotli/          ecpgerrno.h      freetype/         internal/   libpng16/       lz4.h              mbedtls/      pg_config_os.h      pkgconf/             semaphore.h     sqlite3-vcpkg-config.h  turbojpeg.h
GLSC/   bzlib.h          ecpglib.h        ft2build.h        jconfig.h   libpq/          lz4file.h          openjpeg.h    pgtypes.h           png.h                server/         sqlite3.h               utf8proc.h
GLSC2/  cairo/           ecpgtype.h       getopt.h          jerror.h    libpq-events.h  lz4frame.h         openssl/      pgtypes_date.h      pngconf.h            spdlog/         sqlite3ext.h            webp/
KHR/    curl/            expat.h          gif_lib.h         jmorecfg.h  libpq-fe.h      lz4frame_static.h  opj_config.h  pgtypes_error.h     pnglibconf.h         sql3types.h     tesseract/              zconf.h

Simplified version of CMakeList.txt

cmake_minimum_required(VERSION 3.8)
find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL)

include_directories(OpenGL::EGL OpenGL::GL)

set (GL_HEADERS
    quegl.h
)
set (GL_SOURCES
    quegl.cpp
)
add_library (quillkhronos SHARED ${GL_HEADERS} ${GL_SOURCES} )
target_link_libraries (quillkhronos LINK_PUBLIC quill OpenGL::EGL OpenGL::GL )

Output of CMAKE:

Running C:\Qt\Tools\CMake_64\bin\cmake.exe -S C:/projects/quill -B C:/projects/build-quill-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug "-DENABLE_OPENGL:BOOL=ON" in C:\projects\build-quill-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug.
-- VCPKG-Info: CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL set to MinSizeRel;Release;
-- VCPKG-Info: CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO set to RelWithDebInfo;Release;
CMake Error at C:/Qt/Tools/CMake_64/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenGL (missing: EGL)
Call Stack (most recent call first):
  C:/Qt/Tools/CMake_64/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Qt/Tools/CMake_64/share/cmake-3.23/Modules/FindOpenGL.cmake:443 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  C:/projects/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package)
  quillkhronos/CMakeLists.txt:4 (find_package)


-- Configuring incomplete, errors occurred!
See also "C:/projects/build-quill-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/CMakeFiles/CMakeOutput.log".
See also "C:/projects/build-quill-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/CMakeFiles/CMakeError.log".
CMake process exited with exit code 1.

Elapsed time: 00:00.
1

There are 1 best solutions below

0
Alexander Neumann On

EGL is not generally available on windows. The windows equivalent ist WGL.
FindOpenGL.cmake assume the native OpenGL interfaces as such EGL is only available with GLVND.
However angle (DX redirect) and mesa (software) can provide libEGL as a wrapper if requested to do so and there exists a FindEGL.cmake in KDE extra-cmake-modules however I wouldn't advise directly using extensions.
As far as I know you are meant to access the extensions by asking the driver for a pointer to a requested extension function (if it is supported) and than invoke the function via said pointer. (But that is just my limited knowledge without ever having done anything with opengl just building and packaging mesa/angle/qt)