将GLFW与CMake关联的问题

时间:2018-11-04 18:18:46

标签: c++ cmake static-linking glfw

我正在尝试将CLF中的GLFW添加到我的C ++项目中。我已经下载了预构建的Windows二进制文件,并试图将它们添加到CMake文件中,但是却出现错误。这是我的CMakeLists.txt文件:

cmake_minimum_required(VERSION 3.12.3)
project(Streamlined)

set(CMAKE_CXX_STANDARD 17)

list(APPEND CMAKE_MODULE_PATH "$(CMAKE_CURRENT_LIST_DIR}/cmake")

add_executable(Streamlined src/main.cpp)

find_package(glfw3 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GLFW_LIBRARY})

还有我的cmake / Findglfw3.cmake文件:

set(FIND_GLFW_PATHS ${CMAKE_SOURCE_DIR}/../Library/glfw-3.2.1.bin.WIN64/lib)

find_path(GLFW_INCLUDE_DIR glfw3.h
        PATH_SUFFIXES include
        PATHS ${FIND_GLFW_PATHS})

find_library(GLFW_LIBRARY NAMES libglfw3
        PATH_SUFFIXES lib
        PATHS ${FIND_GLFW_PATHS})

但是,出现以下错误:

CMake Error at CMakeLists.txt:10 (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

  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.

我创建了Findglfw3.cmake文件,并将其附加到CMAKE_MODULE_PATH,所以我不明白为什么会收到此错误。我也尝试了this solution,但收到“找不到PkgConfig”错误。

0 个答案:

没有答案
相关问题