nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.66k stars 621 forks source link

build on OSX and Linux with cmake, cannot find source file `src/glewinfo.c` #231

Closed zchrissirhcz closed 5 years ago

zchrissirhcz commented 5 years ago

I've read the readme file and notice that glew can be build with cmake.

Yes, I've successfully build glew-2.1.0 on windows with cmake and Visual Studio 2017. However, on OSX, it fails.

cmake version

3.13.4

glew version

both master and glew-2.1.0 fail

steps to reproduce

cd ~/work
git clone https://github.com/nigels-com/glew
cd glew/build
mkdir mac
cd mac
cmake ../cmake -DCMAKE_INSTALL_PREFIX=./

cmake output

-- The C compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework
-- Configuring done
CMake Error at CMakeLists.txt:181 (add_executable):
  Cannot find source file:

    /Users/chris/work/glew/src/glewinfo.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at CMakeLists.txt:111 (add_library):
  Cannot find source file:

    /Users/chris/work/glew/include/GL/wglew.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at CMakeLists.txt:181 (add_executable):
  No SOURCES given to target: glewinfo

CMake Error at CMakeLists.txt:111 (add_library):
  No SOURCES given to target: glew_s

CMake Error at CMakeLists.txt:107 (add_library):
  No SOURCES given to target: glew

-- Build files have been written to: /Users/chris/work/glew/build/mac

build result on Linux (manjaro)

I now try use cmake to build glew on linux. I'm using manjaro 18.0.4.

cmake version: 3.14 glew version: master

steps:

cd ~/work
git clone https://github.com/nigels-com/glew
cd glew/build
mkdir linux
cd linux
cmake ../cmake -DCMAKE_INSTALL_PREFIX=./

and the cmake gives the following output, which also failed to build:

cmake version 3.14.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[zz@zz-manjaro linux]$ cmake ../cmake -DCMAKE_INSTALL_PREFIX=./
-- The C compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Warning (dev) at /usr/share/cmake-3.14/Modules/FindOpenGL.cmake:275 (message):
  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/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/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.
Call Stack (most recent call first):
  CMakeLists.txt:43 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL: /usr/lib/libOpenGL.so   
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Configuring done
CMake Error at CMakeLists.txt:111 (add_library):
  Cannot find source file:

    /home/zz/work/glew/include/GL/wglew.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at CMakeLists.txt:181 (add_executable):
  Cannot find source file:

    /home/zz/work/glew/src/glewinfo.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at CMakeLists.txt:111 (add_library):
  No SOURCES given to target: glew_s

CMake Error at CMakeLists.txt:107 (add_library):
  No SOURCES given to target: glew

CMake Error at CMakeLists.txt:181 (add_executable):
  No SOURCES given to target: glewinfo

-- Build files have been written to: /home/zz/work/glew/build/linux
zchrissirhcz commented 5 years ago

Update: I've figured out a solution. The glew-2.1.0 tag in this git repo differs what is downloaded in sourceforge, and to use cmake build correctly people have to choose the sourceforge version.. I use the sourceforge downloaded glew-2.1.0.tgz and build with cmake on both OSX and Linux, both are OK. @nigels-com Why would you make them different? It makes me confuse and waste my time. Strongly suggest you mention that in readme file, thanks.