Skip to content

Adding option for EGL and OpenGL preference.#22

Merged
jcfr merged 5 commits intoKitwareMedical:masterfrom
prabhuramachandran:add-egl-option
Oct 10, 2018
Merged

Adding option for EGL and OpenGL preference.#22
jcfr merged 5 commits intoKitwareMedical:masterfrom
prabhuramachandran:add-egl-option

Conversation

@prabhuramachandran
Copy link
Copy Markdown
Collaborator

No description provided.

@jcfr
Copy link
Copy Markdown
Collaborator

jcfr commented Oct 9, 2018

Thanks for the PR 👍

1 similar comment
@jcfr
Copy link
Copy Markdown
Collaborator

jcfr commented Oct 9, 2018

Thanks for the PR 👍

Comment thread CMakeLists.txt Outdated

if(OpenGL_GL_PREFERENCE)
list(APPEND ep_common_cmake_cache_args
-DOpenGL_GL_PREFERENCE:STRING=${OpenGL_GL_PREFERENCE})
Copy link
Copy Markdown
Collaborator

@jcfr jcfr Oct 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable OpenGL_GL_PREFERENCE doesn't seem to be set anywhere ? Should an an explicit option be added ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is being added to ep_common_cmake_cache_args which is used for the VTK build.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefer a separate config variable that is explicitly set?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

#-----------------------------------------------------------------------------
# Options
# When building different "flavor" of VTK python packages on a given platform,
# explicitly setting the following options allow to speed up package generation by
# re-using existing resources.
#
# VTK_SOURCE_DIR: Path to an existing source directory
# VTK_Group_Web: Whether web package should be included
# VTK_OPENGL_HAS_OSMESA: Whether to use OSMesa for offscreen rendering
#
option(VTKPythonPackage_BUILD_PYTHON "Build VTK python module" ON)
mark_as_advanced(VTKPythonPackage_BUILD_PYTHON)
option(VTK_Group_Web "Build VTK web module" OFF)
mark_as_advanced(VTK_Group_Web)
option(VTK_OPENGL_HAS_OSMESA "Use OSMesa for offscreen rendering" OFF)
mark_as_advanced(VTK_OPENGL_HAS_OSMESA)
if(VTK_OPENGL_HAS_OSMESA OR APPLE OR WIN32)
set(VTK_USE_X OFF)
else()
set(VTK_USE_X ON)
endif()

Consider also listing all known options for OpenGL_GL_PREFERENCE and add any relevant documentation links.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@prabhuramachandran
Copy link
Copy Markdown
Collaborator Author

Made changes, please let me know if this is good.

Copy link
Copy Markdown
Collaborator

@jcfr jcfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Almost there 🏎️

Comment thread CMakeLists.txt Outdated
# 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")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, thank you, my ignorance of CMake is showing. I will make these fixes and update the PR.

Comment thread CMakeLists.txt Outdated
set(VTK_USE_X ON)
endif()

if(UNIX AND OpenGL_GL_PREFERENCE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(UNIX AND NOT APPLE)
  list(APPEND ep_common_cmake_cache_args
    -DOpenGL_GL_PREFERENCE:STRING=${OpenGL_GL_PREFERENCE})
endif()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, you've done all the work. Sorry for a sloppy PR.

@jcfr
Copy link
Copy Markdown
Collaborator

jcfr commented Oct 10, 2018

Thanks for your patience 👍

Comment thread CMakeLists.txt

# 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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. That would be 3.10 then, see https://cmake.org/cmake/help/v3.10/release/3.10.html#modules

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks.

This is the version that supports the OpenGL_GL_PREFERENCE option.
@jcfr jcfr merged commit b16b084 into KitwareMedical:master Oct 10, 2018
@prabhuramachandran prabhuramachandran deleted the add-egl-option branch October 10, 2018 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants