rougier / freetype-gl

OpenGL text using one vertex buffer, one texture and FreeType
Other
1.65k stars 266 forks source link

Link to `glfw` in demos/CMakeLists.txt #124

Closed djjh closed 7 years ago

djjh commented 8 years ago

While building the demos on osx, cmake was able to find the glfw3 cmake package, but still failed to link to the library.

Passing the glfw variable (not enclosed in ${}), rather than ${GLFW3_LIBRARY} to target_link_libraries in the CREATE_DEMO macro in demos/CMakeLists.txt solves the issue.

The glfw docs only seem to mention linking this way when building from source (http://www.glfw.org/docs/latest/build_guide.html, section titled 'With CMake and GLFW source'), but I'm pretty sure it's also the recommended way to go when linking to an installed distribution as well.

I've only tested this on osx, so I can't say why the current way of linking to ${GLFW3_LIBRARY} works on other os's while it doesn't on osx.

rougier commented 8 years ago

From memory I think you're not the first to point to this bug but I think the solution is on glfw side. If you browse at previous issues, you might find the reason. And of course, a PR would be welcome.

Sakari369 commented 8 years ago

Yeah this seems to fix the compiling on Os X, just replacing ${GLFW3_LIBRARY} with 'glfw'. Can make a pull request for this, but I suspect this wont work with Linux or Windows maybe ?

I'll check later if I can find a proper fix for this, probably the GLFW3 library is not set properly on Os X for some reason.

schmittl commented 7 years ago

This seems to be not OS X specific, because I ran into this issue on Windows when building with MSYS2 MINGW64. Switching to glfw for linking fixed it for me as well.

Checking the paths confirmed that GLFW3_LIBRARY is not being set

message("GLFW3_LIBRARY_DIR " ${GLFW3_LIBRARY_DIR})     => ""
message("GLFW3_LIBRARY " ${GLFW3_LIBRARY})             => ""
message("GLFW3_INCLUDE_DIR" ${GLFW3_INCLUDE_DIR})      => ""
message("glfw3_dir " ${glfw3_DIR})                     => C:/msys64/mingw64/lib/cmake/glfw3
message("GLFW3_FOUND" ${glfw3_FOUND})                  => 1

So I am wondering if perhaps one is supposed to use glfw for newer version of GLFW. (I have 3.2.2) Anyway I tried to address this issue in my PR.