Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building With CMake and installed GLFW binaries #45

Open
thomastjeffery opened this issue Jan 11, 2018 · 16 comments
Open

Building With CMake and installed GLFW binaries #45

thomastjeffery opened this issue Jan 11, 2018 · 16 comments
Assignees

Comments

@thomastjeffery
Copy link

This page says that you can add the line

find_package(glfw3 3.2 REQUIRED)

to your CMakeLists.txt, and be able to build the project using CMake.

It does nothing to explain where to put the glfw3 binaries, and does not provide a Findglfw3.cmake, glfw3Config.cmake, or a glfw3-config.cmake file, which CMake needs to evaluate the find_package macro. The precompiled binaries from here do not provide them either.

Simply adding the above find_package line to a simple CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
project(Test)
add_executable(test main.cc)

find_package(glfw3 3.2 REQUIRED)

yields this error:

CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "Findglfw3.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "glfw3", but
  CMake did not find one.

  Could not find a package configuration file provided by "glfw3" (requested
  version 3.2) with any of the following names:

    glfw3Config.cmake
    glfw3-config.cmake

  Add the installation prefix of "glfw3" to CMAKE_PREFIX_PATH or set
  "glfw3_DIR" to a directory containing one of the above files.  If "glfw3"
  provides a separate development package or SDK, be sure it has been
  installed.

Is there an example Findglfw3.cmake, glfw3Config.cmake, or glfw3-config.cmake file somewhere?

@siavashserver
Copy link
Member

@thomastjeffery related glfw/glfw#634

@thomastjeffery
Copy link
Author

As far as I can tell, the binary release contains no .cmake files whatsoever.

It really isn't trivial to find a FindGLFW3.cmake file that you can be certain (as a new user) is compatible. If the main docs continue to recommend using CMake, they should really provide this file in releases.

@yuqli
Copy link

yuqli commented Apr 20, 2019

I have this exact same problem. Thanks for raising the issue up!

@varungoel1988
Copy link

same issue.. anyone can help??

@jollescott
Copy link

jollescott commented Oct 21, 2019

Ran into this issue today, solved by installing the libglfw3-dev package instead of libglfw3 on Ubuntu 18.04 LTS. Not sure if it is an optimal solution though.

@mholzel
Copy link

mholzel commented Nov 28, 2019

For reference, I have seen two cases where this happens (these don't seem to be the case for the original user, but will hopefully help others):

  1. The case that @jollescott mentions
  2. People putting the find_package call before a project declaration

@onoriofelipe
Copy link

onoriofelipe commented Apr 2, 2020

Stumbled upon this via google, adding a "redirect" link.

(...)
Is there an example Findglfw3.cmake, glfw3Config.cmake, or glfw3-config.cmake file somewhere?

As explained in glfw/glfw#483 (comment) , when you build and install GLFW then the file glfw3Config.cmake can be found in <install_dir>/lib/cmake/glfw/ .

The file is not available in the precompiled Windows binary release.

@TJ-Perez
Copy link

TJ-Perez commented Dec 9, 2020

Still having this issue using the latest precompiled Windows binaries, can't find any information about where to find these files/where they need to be

@bartholmberg
Copy link

Updates on Findglfw3.cmake /glfw3Config.cmake [?] So glfw3 lib binaries, /include but no cmake files for dependent builds. Like Ospay_studio...snipped below....

:\catkin_ws>cd c:\repo\ospray_studio

c:\repo\ospray_studio>cmake .
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- C:/repo/ospray_studio/glfw3libs
-- This build is for C++14
CMake Error at CMakeLists.txt:46 (find_package):
By not providing "Findglfw3.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "glfw3", but
CMake did not find one.

Could not find a package configuration file provided by "glfw3" with any of
the following names:

glfw3Config.cmake
glfw3-config.cmake

@sparshpriyadarshi
Copy link

  • for anyone wondering about this issue on Windows with VCPKG, install libigl[glfw], it should pull in the required cmakes.

image

@weisterki
Copy link

glfw3-config.cmake

I installed libigl[glfw], and find the glfw3Config.cmake at C:\src\vcpkg\installed\x86-windows\share\glfw3; but there is no glfw3-config.cmake in any folder.

@Areshkew
Copy link

Same issue, there is a solution?

@Areshkew
Copy link

Same issue, there is a solution?

I found a Solution, you should follow this steps:

  1. Download GLFW Source.

  2. Execute the following cmake commands:
    cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S . -B build
    cmake --build build
    cmake --install build --prefix install

  3. Then a "install" folder will be created, there will be the lib, cmake, and include folders, copy them into your project folder.
    I copied them in "project_root/dependencies/GLFW".

  4. Finally in your cmakelist.txt add the following.
    list(APPEND CMAKE_PREFIX_PATH "dependencies/GLFW/lib/cmake")
    find_package(glfw3 REQUIRED)
    target_link_libraries(Chess glfw)

Now you can build your project :D

@FSSRepo
Copy link

FSSRepo commented Mar 4, 2024

@Areshkew I'm getting this on windows:

  wave.c
  wave.vcxproj -> C:\Users\stewa\Downloads\VkGalaxy-main\glfw-master\build\examples\Debug\wave.exe
  1>Building Custom Rule C:/Users/stewa/Downloads/VkGalaxy-main/glfw-master/tests/CMakeLists.txt
  window.c
  window.vcxproj -> C:\Users\stewa\Downloads\VkGalaxy-main\glfw-master\build\tests\Debug\window.exe
  1>Building Custom Rule C:/Users/stewa/Downloads/VkGalaxy-main/glfw-master/examples/CMakeLists.txt
  windows.c
  windows.vcxproj -> C:\Users\stewa\Downloads\VkGalaxy-main\glfw-master\build\examples\Debug\windows.exe
  1>Building Custom Rule C:/Users/stewa/Downloads/VkGalaxy-main/glfw-master/CMakeLists.txt

C:\Users\stewa\Downloads\VkGalaxy-main\glfw-master\build>cmake --install .
-- Install configuration: "Release"
CMake Error at src/cmake_install.cmake:39 (file):
  file INSTALL cannot find
  "C:/Users/stewa/Downloads/VkGalaxy-main/glfw-master/build/src/Release/glfw3.lib":
  File exists.
Call Stack (most recent call first):
  cmake_install.cmake:37 (include)



C:\Users\stewa\Downloads\VkGalaxy-main\glfw-master\build>cmake --install . --prefix install
-- Install configuration: "Release"
CMake Error at src/cmake_install.cmake:39 (file):
  file INSTALL cannot find
  "C:/Users/stewa/Downloads/VkGalaxy-main/glfw-master/build/src/Release/glfw3.lib":
  File exists.
Call Stack (most recent call first):
  cmake_install.cmake:37 (include)



C:\Users\stewa\Downloads\VkGalaxy-main\glfw-master\build>

@RiwajMainali
Copy link

@FSSRepo For windows, you gotta make the build files, where you will find the cmake-gui to be easiest way.
I recommend this tutorial till you have glfw-build folder, just make sure to run the cmd as admin.
after you have glfw-build, just add it to your project lib folder

Also, make sure to use glfw3 as package name not just glfw, this is because the cmake in glfw-build is named glfw3Config.cmake

As an example, here is mine,

set(glfw3_DIR  "${CMAKE_SOURCE_DIR}/Lib/glfw-build/src")
find_package(glfw3 3.4 REQUIRED)
include_directories(${glfw3_DIR})

@FSSRepo
Copy link

FSSRepo commented Mar 12, 2024

@FSSRepo For windows, you gotta make the build files, where you will find the cmake-gui to be easiest way.

I realized that I had to build it in Release mode, that's why it didn't allow me to use the cmake --install build --prefix install command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests