1

I downloaded the source code of OpenGL 4 Shading Language Cookbook, 3rd Edition from PacktPublishing github

I have downloaded the glm source code version glm-0.9.9.3 and I have downloaded the glfw source code version glfw-3.2.1. I successfully compiled, built and installed both glm and glfw using the "cmake ."

To find the GLFW installation, I executed the below command in the src (examples) folder

cmake -D CMAKE_PREFIX_PATH=e:\mysrcpath\glfw-3.2.1\src .

I am getting the below error

-- Selecting Windows SDK version  to target Windows 10.0.17134.
CMake Error at E:/glfw-3.2.1/src/glfw3Config.cmake:1 (include):
include could not find load file:

E:/glfw-3.2.1/src/glfw3Targets.cmake
Call Stack (most recent call first):
CMakeLists.txt:13 (find_package)

-- Found OpenGL: opengl32
-- Configuring incomplete, errors occurred!

The glfw3Config.cmake is having the code

include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake")

The "CMAKE_CURRENT_LIST_DIR" is

E:/glfw-3.2.1/src/

But the glfw3Targets.cmake is located in

E:/glfw-3.2.1/CMakeFiles/Export/lib/cmake/glfw3/

The 'cmake' build is not able to find the glfw3Targets.cmake in the correct path.

How to fix this issue?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Arun AC
  • 417
  • 7
  • 17

1 Answers1

1

It seem like GLFW version 3.2.1 does not support using it directly from the build tree. You should install GLFW instead and add the directory to the cmake prefix paths.

in the glfw directory:

mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=c:/local/ ..
cmake --build . --target install

Then when invoking cmake for your projects:

cmake -D CMAKE_PREFIX_PATH=c:/local/
Guillaume Racicot
  • 39,621
  • 9
  • 77
  • 141
  • Thanks for the quick reply. On executing the commands, I am getting the error >cd e:/glfw-3.2.1 >mkdir build && cd build >cmake -DCMAKE_INSTALL_PREFIX=c:/local/ --build .. --target install CMake Error: The source director "E:/glfw-3.2.1/build/install" does not exist. How to fix this error? Shall I build the code using Visual Studio ? – Arun AC Feb 18 '19 at 18:11
  • @ArunAC sorry, my bad. I mixed the cmake build command and the generation step – Guillaume Racicot Feb 18 '19 at 18:17
  • @ArunAC if you use the correct generator, you shouldn't need to open visual studio, even with the visual studio generator. Everything can be done through the command line (better scriptable) – Guillaume Racicot Feb 18 '19 at 18:19
  • thanks a lot Guillaume. It works. And, i added 'dot' at the end of the command. cmake -D CMAKE_PREFIX_PATH=c:/local/ . I will start using the command line for code generation and code building. Thanks... – Arun AC Feb 18 '19 at 18:57