FindOpenGL.cmake documentation is unclear
The FindOpenGL.cmake documentation mentions legacy things, and "GLVND". I have no idea what GLVND is, so it is not clear what is legacy and what is not. Apparently ARB comes from the legacy libGL.so
.
$ cat ../mylib.cpp
#include <GL/gl.h>
int foo()
{
glActiveTextureARB(GL_TEXTURE0_ARB);
glActiveTextureARB(GL_TEXTURE0_ARB);
float texCoord0[4], texCoord1[4];
glBegin(GL_QUADS);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, texCoord1[0], texCoord1[1]);
return 0;
}
$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(cmakeplayground VERSION 1.2.3)
find_package(OpenGL REQUIRED)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
add_library(mylib SHARED mylib.cpp)
target_link_libraries(mylib PRIVATE OpenGL::GL)
$ ninja
[0/1] Re-running CMake...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stephen/dev/src/playground/cmake/build
[2/2] Linking CXX shared library libmylib.so
FAILED: libmylib.so
: && /usr/lib/ccache/c++ -fPIC -Wl,--no-undefined -shared -Wl,-soname,libmylib.so -o libmylib.so CMakeFiles/mylib.dir/mylib.cpp.o /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so && :
CMakeFiles/mylib.dir/mylib.cpp.o: In function `foo()':
mylib.cpp:(.text+0x1d): undefined reference to `glActiveTextureARB'
mylib.cpp:(.text+0x27): undefined reference to `glActiveTextureARB'
mylib.cpp:(.text+0x4e): undefined reference to `glMultiTexCoord2fARB'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Is this the right way to use OpenGL with CMake?