summaryrefslogtreecommitdiffstats
path: root/Tests/FindOpenGL
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/FindOpenGL')
-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;
+}