Adding option for EGL and OpenGL preference.#22
Conversation
|
Thanks for the PR 👍 |
1 similar comment
|
Thanks for the PR 👍 |
|
|
||
| if(OpenGL_GL_PREFERENCE) | ||
| list(APPEND ep_common_cmake_cache_args | ||
| -DOpenGL_GL_PREFERENCE:STRING=${OpenGL_GL_PREFERENCE}) |
There was a problem hiding this comment.
The variable OpenGL_GL_PREFERENCE doesn't seem to be set anywhere ? Should an an explicit option be added ?
There was a problem hiding this comment.
It is being added to ep_common_cmake_cache_args which is used for the VTK build.
There was a problem hiding this comment.
https://github.com/KitwareMedical/VTKPythonPackage/blob/master/CMakeLists.txt#L226
The option is used if you want to use GLVND vs the classic OpenGL. So one could do:
VTK_CMAKE_ARGS="-DOpenGL_GL_PREFERENCE:STRING=GLVND" python setup.py ...
There was a problem hiding this comment.
Would you prefer a separate config variable that is explicitly set?
There was a problem hiding this comment.
Setting VTK_CMAKE_ARGS env. variable make sense, you could also pass the options to setup.py using python setup.py bdist_wheel -- -DOpenGL_GL_PREFERENCE:STRING=GLVND (see doc)
But, it would also be great to add the variable OpenGL_GL_PREFERENCE here:
VTKPythonPackage/CMakeLists.txt
Lines 46 to 70 in 9a93fbe
Consider also listing all known options for OpenGL_GL_PREFERENCE and add any relevant documentation links.
There was a problem hiding this comment.
It also seems this option is linux specific: https://cmake.org/cmake/help/latest/module/FindOpenGL.html?highlight=opengl_gl_preference#linux-specific
There was a problem hiding this comment.
Alright, I will add it as a separate option and mention the valid options. But will append it to the ep_common_cmake_cache_args on Linux alone as it cannot be added as an explicit VTK option the way it is currently passed.
|
Made changes, please let me know if this is good. |
| # This is a Linux only option and the valid values can be either | ||
| # "LEGACY" or "GLVND". More information here: | ||
| # https://cmake.org/cmake/help/git-stage/policy/CMP0072.html | ||
| option(OpenGL_GL_PREFERENCE "Set the preferred OpenGL library" "LEGACY") |
There was a problem hiding this comment.
Almost. Option are only boolean.
Correct syntax would be:
set(OpenGL_GL_PREFERENCE "LEGACY" CACHE "Set the preferred OpenGL library")
Also, since this is linux only ... consider the following:
if(UNIX AND NOT APPLE)
set(OpenGL_GL_PREFERENCE "LEGACY" CACHE STRING "Set the preferred OpenGL library")
endif()
And finally, you could even add an extra check for invalid values and give some hints for cmake-gui, ccache ...
if(UNIX AND NOT APPLE)
set(OpenGL_GL_PREFERENCE "LEGACY" CACHE STRING "Set the preferred OpenGL library")
if(NOT OpenGL_GL_PREFERENCE MATCHES "^(LEGACY|GLVND)$")
message(FATAL_ERROR "Unknown value for OpenGL_GL_PREFERENCE. Valid values are LEGACY or GLVND")
endif()
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "LEGACY" "GLVND")
endif()
There was a problem hiding this comment.
Ahh, thank you, my ignorance of CMake is showing. I will make these fixes and update the PR.
| set(VTK_USE_X ON) | ||
| endif() | ||
|
|
||
| if(UNIX AND OpenGL_GL_PREFERENCE) |
There was a problem hiding this comment.
if(UNIX AND NOT APPLE)
list(APPEND ep_common_cmake_cache_args
-DOpenGL_GL_PREFERENCE:STRING=${OpenGL_GL_PREFERENCE})
endif()
There was a problem hiding this comment.
Thanks, you've done all the work. Sorry for a sloppy PR.
|
Thanks for your patience 👍 |
|
|
||
| # This is a Linux only option and the valid values can be either | ||
| # "LEGACY" or "GLVND". More information here: | ||
| # https://cmake.org/cmake/help/git-stage/policy/CMP0072.html |
There was a problem hiding this comment.
One last thing, since was introduced in CMake 3.11 ... could you also bump the minimum CMake version from 3.3 to 3.11 ?
See https://cmake.org/cmake/help/v3.13/manual/cmake-policies.7.html#policies-introduced-by-cmake-3-11
There was a problem hiding this comment.
Well, doesn't it only say that with 3.11 the default changes from legacy to glvnd? It doesn't say that the option is not valid before 3.11.
There was a problem hiding this comment.
Good point. That would be 3.10 then, see https://cmake.org/cmake/help/v3.10/release/3.10.html#modules
There was a problem hiding this comment.
Done! Thanks.
This is the version that supports the OpenGL_GL_PREFERENCE option.
No description provided.