Perlmint / glew-cmake

GLEW(https://github.com/nigels-com/glew, source updated nightly) with Cmake and pre-generated sources
Other
234 stars 95 forks source link

Set the CMP0072 policy to NEW #31

Closed janekb04 closed 3 years ago

janekb04 commented 3 years ago

Currently when building with with CMake 3.16.3 and above, the following warning is issued

Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.

I think this policy has to be set with cmake_policy(SET CMP0072 NEW)

janekb04 commented 3 years ago

The issue is caused by find_package(OpenGL REQUIRED) in line 39. Currently I have solved it in my code with set(CMAKE_POLICY_DEFAULT_CMP0072 NEW).

nigels-com commented 3 years ago

Thanks!

janekb04 commented 3 years ago

@Perlmint I saw that in the referenced commit, you set the policy to LEGACY. Shouldn't it be set to NEW instead to use the new OpenGL libraries instead of the legacy ones?

janekb04 commented 3 years ago

I think it should be set to NEW as the CMake documentation states that the OLD behaviour is deprecated and may be removed.

Perlmint commented 3 years ago

@Perlmint I saw that in the referenced commit, you set the policy to LEGACY. Shouldn't it be set to NEW instead to use the new OpenGL libraries instead of the legacy ones?

Hmm... Actually, OpenGL_GL_PREFERENCE doesn't affect this cmake - I noticed after pushing it 😭 . I selected LEGACY to avoid changing any behaviour. I just wanted to avoid the warning.

I think it should be set to NEW as the CMake documentation states that the OLD behaviour is deprecated and may be removed.

You're right. It should be changed to NEW at last. I'll change it soon.

Thanks a lot!

Perlmint commented 3 years ago

Using GLVND at a79115599b7941cddb3f3b336cc1ad0e5bfc3efa - same behaviour as NEW of CMP0072