summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-03-13 13:37:30 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-03-13 13:37:41 (GMT)
commit072372aeb80a5de15a4a9c4ecb3bc0981da0bf11 (patch)
tree29b1b13eaa17ef49e2f296a31b2d6c565a2b6d25 /Tests
parenta237d98bf9e58fe2400fce954a58de7ee594bd80 (diff)
parentbeb0a56c865f8290e9d0431fdd08f9b8f83481dd (diff)
downloadCMake-072372aeb80a5de15a4a9c4ecb3bc0981da0bf11.zip
CMake-072372aeb80a5de15a4a9c4ecb3bc0981da0bf11.tar.gz
CMake-072372aeb80a5de15a4a9c4ecb3bc0981da0bf11.tar.bz2
Merge topic 'findopengl-gles'
beb0a56c86 FindOpenGL: support finding GLES2 and GLES3 Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Acked-by: Alex <leha-bot@yandex.ru> Merge-request: !8309
Diffstat (limited to 'Tests')
-rw-r--r--Tests/FindOpenGL/Test/CMakeLists.txt129
-rw-r--r--Tests/FindOpenGL/Test/main_gles2.c17
-rw-r--r--Tests/FindOpenGL/Test/main_gles3.c17
3 files changed, 142 insertions, 21 deletions
diff --git a/Tests/FindOpenGL/Test/CMakeLists.txt b/Tests/FindOpenGL/Test/CMakeLists.txt
index 9004a98..7c805c0 100644
--- a/Tests/FindOpenGL/Test/CMakeLists.txt
+++ b/Tests/FindOpenGL/Test/CMakeLists.txt
@@ -44,28 +44,115 @@ else()
add_test(NAME test_comp_glx_novnd COMMAND test_comp_glx_novnd)
endif()
-# EGL is only available on Linux+GLVND at present.
-if(OpenGL_TEST_VND)
- find_package(OpenGL COMPONENTS OpenGL EGL)
- if(OpenGL_EGL_FOUND)
- add_executable(test_comp_egl main.c)
- target_link_libraries(test_comp_egl PRIVATE OpenGL::OpenGL OpenGL::EGL)
- add_test(NAME test_comp_egl COMMAND test_comp_egl)
- # EGL-only code should not link to GLX.
- execute_process(COMMAND ldd test_comp_egl
- OUTPUT_VARIABLE LDD_OUT
- ERROR_VARIABLE LDD_ERR)
- if("${LDD_OUT}" MATCHES "GLX")
- message(FATAL_ERROR "EGL-only code links to GLX!")
- endif()
+find_package(OpenGL COMPONENTS OpenGL EGL)
+if(OpenGL_EGL_FOUND)
+ add_executable(test_comp_egl main.c)
+ target_link_libraries(test_comp_egl PRIVATE OpenGL::OpenGL OpenGL::EGL)
+ add_test(NAME test_comp_egl COMMAND test_comp_egl)
+ # EGL-only code should not link to GLX.
+ get_target_property(iface_libs OpenGL::EGL INTERFACE_LINK_LIBRARIES)
+ if(iface_libs MATCHES "GLX")
+ message(FATAL_ERROR "EGL-only code links to GLX!")
+ endif()
+endif()
+
+# all three COMPONENTS together.
+find_package(OpenGL COMPONENTS OpenGL EGL GLX)
+if(OpenGL_EGL_FOUND AND OpenGL_GLX_FOUND)
+ add_executable(test_comp_both main.c)
+ target_link_libraries(test_comp_both PRIVATE OpenGL::OpenGL OpenGL::EGL
+ OpenGL::GLX)
+ add_test(NAME test_comp_both COMMAND test_comp_both)
+endif()
+
+find_package(OpenGL COMPONENTS GLES2)
+if(OpenGL_GLES2_FOUND)
+ add_executable(test_comp_gles2 main_gles2.c)
+ target_link_libraries(test_comp_gles2 PRIVATE OpenGL::GLES2)
+ add_test(NAME test_comp_gles2 COMMAND test_comp_gles2)
+ # GLES2-only code should not link to OpenGL
+ get_target_property(iface_libs test_comp_gles2 LINK_LIBRARIES)
+ if(iface_libs MATCHES "OpenGL::OpenGL")
+ message(FATAL_ERROR "GLES2-only code links to OpenGL!")
endif()
+endif()
+
+# GLES2 and EGL together.
+find_package(OpenGL COMPONENTS GLES2 EGL)
+if(OpenGL_GLES2_FOUND AND OpenGL_EGL_FOUND)
+ add_executable(test_comp_gles2_egl main_gles2.c)
+ target_link_libraries(test_comp_gles2_egl PRIVATE OpenGL::GLES2
+ OpenGL::EGL)
+ add_test(NAME test_comp_gles2_egl COMMAND test_comp_gles2_egl)
+ # GLES2-EGL-only code should not link to OpenGL or GLX
+ get_target_property(iface_libs test_comp_gles2_egl LINK_LIBRARIES)
+ if(iface_libs MATCHES "OpenGL::OpenGL")
+ message(FATAL_ERROR "GLES2-only code links to OpenGL!")
+ endif()
+ if(iface_libs MATCHES "GLX")
+ message(FATAL_ERROR "GLES2-EGL-only code links to GLX!")
+ endif()
+endif()
- # all three COMPONENTS together.
- find_package(OpenGL COMPONENTS OpenGL EGL GLX)
- if(OpenGL_EGL_FOUND AND OpenGL_GLX_FOUND)
- add_executable(test_comp_both main.c)
- target_link_libraries(test_comp_both PRIVATE OpenGL::OpenGL OpenGL::EGL
- OpenGL::GLX)
- add_test(NAME test_comp_both COMMAND test_comp_both)
+# GLES2 and GLX together.
+find_package(OpenGL COMPONENTS GLES2 GLX)
+if(OpenGL_GLES2_FOUND AND OpenGL_GLX_FOUND)
+ add_executable(test_comp_gles2_glx main_gles2.c)
+ target_link_libraries(test_comp_gles2_glx PRIVATE OpenGL::GLES2
+ OpenGL::GLX)
+ add_test(NAME test_comp_gles2_glx COMMAND test_comp_gles2_glx)
+ # GLES2-GLX-only code should not link to OpenGL or EGL
+ get_target_property(iface_libs test_comp_gles2_glx LINK_LIBRARIES)
+ if(iface_libs MATCHES "OpenGL::OpenGL")
+ message(FATAL_ERROR "GLES2-only code links to OpenGL!")
+ endif()
+ if(iface_libs MATCHES "EGL")
+ message(FATAL_ERROR "GLES2-GLX-only code links to EGL!")
+ endif()
+endif()
+
+find_package(OpenGL COMPONENTS GLES3)
+if(OpenGL_GLES3_FOUND)
+ add_executable(test_comp_gles3 main_gles3.c)
+ target_link_libraries(test_comp_gles3 PRIVATE OpenGL::GLES3)
+ add_test(NAME test_comp_gles3 COMMAND test_comp_gles3)
+ # GLES3-only code should not link to OpenGL.
+ get_target_property(iface_libs test_comp_gles3 LINK_LIBRARIES)
+ if(iface_libs MATCHES "OpenGL::OpenGL")
+ message(FATAL_ERROR "GLES3-only code links to OpenGL!")
+ endif()
+endif()
+
+# GLES3 and EGL together.
+find_package(OpenGL COMPONENTS GLES3 EGL)
+if(OpenGL_GLES3_FOUND AND OpenGL_EGL_FOUND)
+ add_executable(test_comp_gles3_egl main_gles3.c)
+ target_link_libraries(test_comp_gles3_egl PRIVATE OpenGL::GLES3
+ OpenGL::EGL)
+ add_test(NAME test_comp_gles3_egl COMMAND test_comp_gles3_egl)
+ # GLES3-EGL-only code should not link to OpenGL or GLX
+ get_target_property(iface_libs test_comp_gles3_egl LINK_LIBRARIES)
+ if(iface_libs MATCHES "OpenGL::OpenGL")
+ message(FATAL_ERROR "GLES3-only code links to OpenGL!")
+ endif()
+ if(iface_libs MATCHES "GLX")
+ message(FATAL_ERROR "GLES3-EGL-only code links to GLX!")
+ endif()
+endif()
+
+# GLES3 and GLX together.
+find_package(OpenGL COMPONENTS GLES3 GLX)
+if(OpenGL_GLES3_FOUND AND OpenGL_GLX_FOUND)
+ add_executable(test_comp_gles3_glx main_gles3.c)
+ target_link_libraries(test_comp_gles3_glx PRIVATE OpenGL::GLES3
+ OpenGL::GLX)
+ add_test(NAME test_comp_gles3_glx COMMAND test_comp_gles3_glx)
+ # GLESr-GLX-only code should not link to OpenGL or EGL
+ get_target_property(iface_libs test_comp_gles3_glx LINK_LIBRARIES)
+ if(iface_libs MATCHES "OpenGL::OpenGL")
+ message(FATAL_ERROR "GLES3-only code links to OpenGL!")
+ endif()
+ if(iface_libs MATCHES "EGL")
+ message(FATAL_ERROR "GLES3-GLX-only code links to EGL!")
endif()
endif()
diff --git a/Tests/FindOpenGL/Test/main_gles2.c b/Tests/FindOpenGL/Test/main_gles2.c
new file mode 100644
index 0000000..52f5936
--- /dev/null
+++ b/Tests/FindOpenGL/Test/main_gles2.c
@@ -0,0 +1,17 @@
+#ifdef _WIN32
+# error "GLES2 cannot be tested on WIN32 platforms."
+#endif
+#ifdef __APPLE__
+# error "GLES2 cannot be tested on macOS platform."
+#else
+# include <GLES2/gl2.h>
+#endif
+
+#include <stdio.h>
+
+int main()
+{
+ /* Reference a GL symbol without requiring a context at runtime. */
+ printf("&glGetString = %p\n", &glGetString);
+ return 0;
+}
diff --git a/Tests/FindOpenGL/Test/main_gles3.c b/Tests/FindOpenGL/Test/main_gles3.c
new file mode 100644
index 0000000..875f73c
--- /dev/null
+++ b/Tests/FindOpenGL/Test/main_gles3.c
@@ -0,0 +1,17 @@
+#ifdef _WIN32
+# error "GLES3 cannot be tested on WIN32 platforms."
+#endif
+#ifdef __APPLE__
+# error "GLES3 cannot be tested on macOS platform."
+#else
+# include <GLES3/gl3.h>
+#endif
+
+#include <stdio.h>
+
+int main()
+{
+ /* Reference a GL symbol without requiring a context at runtime. */
+ printf("&glGetString = %p\n", &glGetString);
+ return 0;
+}