nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.61k stars 610 forks source link

cmake/MSYS2: TARGET_PDB_FILE with "Unix Makefiles" cmake generator #104

Open bit2shift opened 7 years ago

bit2shift commented 7 years ago

An obvious feature of VC++ is being checked when the chosen generator clearly states NOT M$. The invocation goes like: cd dep/glew/build && cmake -G "Unix Makefiles" cmake. It's followed by make -C dep/glew/build glew_s in order to compile just the static lib. These are invocated from a makefile (as if it really matters). This occurs on MSYS2.

nigels-com commented 7 years ago

I give this a try with MSYS2. It does look like the cmake needs to support this better.

MSYS ~/Downloads/glew-2.0.0/build/cmake
$ cmake -G "Unix Makefiles" cmake .
-- The C compiler identification is GNU 5.3.0
-- The CXX compiler identification is GNU 5.3.0
CMake Warning at /usr/share/cmake-3.5.2/Modules/Platform/MSYS.cmake:15 (message):
  CMake no longer defines WIN32 on MSYS!

  (1) If you are just trying to build this project, ignore this warning or
  quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
  the CMake cache.  If later configuration or build errors occur then this
  project may have been written under the assumption that MSYS is WIN32.  In
  that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.

  (2) If you are developing this project, add the line

    set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required

  at the top of your top-level CMakeLists.txt file or set the minimum
  required version of CMake to 2.8.4 or higher.  Then teach your project to
  build on Cygwin without WIN32.
Call Stack (most recent call first):
  /usr/share/cmake-3.5.2/Modules/CMakeSystemSpecificInformation.cmake:37 (include)
  CMakeLists.txt:5 (project)

-- Check for working C compiler: /usr/bin/cc.exe
-- Check for working C compiler: /usr/bin/cc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenGL: /usr/lib/w32api/libopengl32.a
-- Configuring done
-- Generating done
-- Build files have been written to: /c/Users/nigels/Downloads/glew-2.0.0/build/cmake

MSYS ~/Downloads/glew-2.0.0/build/cmake
$ make
Scanning dependencies of target glew
[ 12%] Building C object CMakeFiles/glew.dir/c/Users/nigels/Downloads/glew-2.0.0/src/glew.c.o
In file included from /c/Users/nigels/Downloads/glew-2.0.0/src/glew.c:43:0:
/c/Users/nigels/Downloads/glew-2.0.0/include/GL/glxew.h:98:22: fatal error: X11/Xlib.h: No such file or directory
 #include <X11/Xlib.h>
                      ^
compilation terminated.
make[2]: *** [CMakeFiles/glew.dir/build.make:63: CMakeFiles/glew.dir/c/Users/nigels/Downloads/glew-2.0.0/src/glew.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/glew.dir/all] Error 2
make: *** [Makefile:128: all] Error 2

nigels@zootv MSYS /c/Users/nigels/Downloads/glew-2.0.0/build/cmake
$
nigels-com commented 7 years ago

For what it's worth, the native make also seems to have issues for MSYS2:

$ make SYSTEM=msys-win64 clean all
rm -f -r tmp/
rm -f -r lib/
rm -f -r bin/
rm -f glew.pc
mkdir lib
gcc -DGLEW_NO_GLU -DGLEW_BUILD -mtune=generic -O2 -Wall -W -Iinclude -D_WIN32 -fno-builtin -fno-stack-protector -m64  -o tmp/msys-win64/default/shared/glew.o -c src/glew.c
gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a    -o lib/glew32.dll tmp/msys-win64/default/shared/glew.o  -nostdlib -m64 -lopengl32 -lgdi32 -luser32 -lkernel32
/usr/lib/gcc/x86_64-pc-msys/5.3.0/../../../../x86_64-pc-msys/bin/ld: warning: cannot find entry symbol _msys_dll_entry; defaulting to 000000043dab1000
strip -x lib/glew32.dll
gcc -DGLEW_NO_GLU -DGLEW_STATIC -mtune=generic -O2 -Wall -W -Iinclude -D_WIN32 -fno-builtin -fno-stack-protector -m64  -o tmp/msys-win64/default/static/glew.o -c src/glew.c
ar rv lib/libglew32.a tmp/msys-win64/default/static/glew.o
ar: creating lib/libglew32.a
a - tmp/msys-win64/default/static/glew.o
strip -x lib/libglew32.a
sed \
        -e "s|@prefix@|/usr|g" \
        -e "s|@libdir@|/usr/bin|g" \
        -e "s|@exec_prefix@|/usr/bin|g" \
        -e "s|@includedir@|/usr/include/GL|g" \
        -e "s|@version@|2.0.0|g" \
        -e "s|@cflags@||g" \
        -e "s|@libname@|glew32|g" \
        -e "s|@requireslib@|glu|g" \
        < glew.pc.in > glew.pc
mkdir bin
gcc -DGLEW_NO_GLU -mtune=generic -O2 -Wall -W -Iinclude -D_WIN32 -fno-builtin -fno-stack-protector -m64  -o tmp/msys-win64/default/shared/glewinfo.o -c src/glewinfo.c
gcc -mtune=generic -O2 -Wall -W -Iinclude -D_WIN32 -fno-builtin -fno-stack-protector -m64 -o bin/glewinfo.exe tmp/msys-win64/default/shared/glewinfo.o -Llib  -lglew32  -nostdlib -m64 -lopengl32 -lgdi32 -luser32 -lkernel32
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x30): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x52): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x52): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x5a): undefined reference to `strlen'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x5a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strlen'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x92): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x92): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0xb4): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0xb4): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0xe5): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0xe5): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x102): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x10a): undefined reference to `strlen'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x10a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `strlen'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x128): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x128): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x153): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x153): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x186): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x186): additional relocation overflows omitted from the output
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x1a2): undefined reference to `fprintf'
tmp/msys-win64/default/shared/glewinfo.o:glewinfo.c:(.text+0x1aa): undefined reference to `strlen'
...
bit2shift commented 7 years ago

Although for the particular case I'm looking for, I could make a PR with finer control over make glew.lib by adding two child targets of glew.lib, namely glew.lib.shared and glew.lib.static:

glew.lib: glew.lib.shared glew.lib.static
glew.lib.shared: lib lib/$(LIB.SHARED) glew.pc
glew.lib.static: lib lib/$(LIB.STATIC) glew.pc
nigels-com commented 7 years ago

Sure, I'd seriously consider that.

bit2shift commented 7 years ago

I'll work on it right away. In my scenario, with MSYS2, I'm just doing make extensions glew.lib.

nigels-com commented 7 years ago

Commenting out this line in config/Makefile.msys seems helpful. The idea is that glew32.dll doesn't not depend on the C library. But glewinfo and visualinfo need that.

LDFLAGS.EXTRA += -nostdlib
nigels-com commented 7 years ago

Two things to try here: