c++ - GLFW directory not found with CMake and vcpkg -
i have been unable figure out how cmake find , set correct glfw cmake constants when using cmake in vs2017. appreciated :).
i downloaded glfw3
through microsoft's vcpkg
tool. have checked files physically exist in directory vcpkg
puts them in (~\vcpkg\installed\x86-windows\include
). set cmakesettings.json
per docs here. used tutorial basis getting glfw set correctly.
i use find_package(glfw3 required)
find glfw3
library. not spit out errors. cmakelists.txt
doesn't complain @ all. it's @ compile stage complains.
after add glfw3
target_link_libraries(exe ${glfw3_libraries})
executable.
then when try , build simple example (including header file), compilation fails because cannot find glfw/glfw3.h
.
the error msvc:
fatal error c1083: cannot open include file: 'glfw/glfw3.h': no such file or directory
here cmakelists.txt
added reference:
cmake_minimum_required(version 3.7) project(learn-opengl) find_package(glfw3 required) add_executable(learn-opengl main.cpp) target_link_libraries(learn-opengl ${glfw3_libraries})
glfw3_libraries
got glfw3config.cmake
snooping around vcpkg
puts in installed directory (~\vcpkg\installed\x86-windows\share\glfw3
)
and in case, main.cpp
:
#include <glfw/glfw3.h> int main() { return 0; }
i have tried calling cmake
command line well, no avail didn't work either.
am missing something? did perhaps misunderstand in vcpkg
documentation? have no idea missing... :/ should say, in addition, new cmake well.
reformulating previous comment answer:
you should add imported target glfw
target_link_libraries
command instead of ${glfw3_libraries}
. find_package(glfw3)
generates import target glfw
. making target learn-opengl
dependent on imported target specify both library link , include directories use.
Comments
Post a Comment