CMake在Clion的Windows上找不到Freeglut [英] CMake cannot find freeglut on windows in Clion

查看:109
本文介绍了CMake在Clion的Windows上找不到Freeglut的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经被卡住了一段时间了,我不知道如何使freeglut正常工作.我以为我知道它要我做什么,所以我添加了set(prefix_path)行,但是它什么也没做.我应该编写自己的freeglut-config.cmake还是什么?

I've been stuck for a while now and I can't figure out how to get freeglut working. I thought I knew what it was asking me to do, so I added that set(prefix_path) line but it didn't do anything. Am I supposed to write my own freeglut-config.cmake or what?

注意:我正在从网站

CMake文件:

cmake_minimum_required(VERSION 3.7)
project(HW1)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES Triangle.cpp)
set(CMAKE_PREFIX_PATH "C:/freeglut")

find_package(GLEW REQUIRED STATIC)
find_package(FREEGLUT REQUIRED)
find_package(OPENGL REQUIRED)

include_directories(${FREEGLUT_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS})
link_directories(${FREEGLUT_LIBRARY_DIRS} ${GLEW_LIBRARY_DIRS} ${OPENGL_LIBRARY_DIRS})
add_definitions(${FREEGLUT_DEFINITIONS} ${GLEW_DEFINITIONS} ${OPENGL_DEFINITIONS})

add_executable(HW1 ${SOURCE_FILES})
target_link_libraries(HW1 ${FREEGLUT_LIBRARIES} ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES})

完整错误:

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

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

    FREEGLUTConfig.cmake
    freeglut-config.cmake

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

推荐答案

如果您的应用程序与 GLUT兼容,并且它不使用freeglut的任何扩展名,那么搜索 GLUT 而不是 FREEGLUT :

If your application is GLUT-compatible, that it doesn't use any extension of freeglut, then it is better to search GLUT instead of FREEGLUT:

find_package(GLUT REQUIRED)

此命令所使用的查找"脚本已经包含在CMake发行版中,并且它也搜索freeglut.

"Find" script used by this command is already shipped into CMake distro, and it searches freeglut too.

(请注意,包含目录和链接库的命令变量分别是 GLUT_INCLUDE_DIR GLUT_LIBRARY ).

(Note, that with that command variables for include directories and linking libraries are GLUT_INCLUDE_DIR and GLUT_LIBRARY correspondingly).

如果您的应用程序需要完全免费的胶粘剂(也就是说,使用其某些扩展名与其他GLUT实现不兼容),则需要打包strong>和 FindFREEGLUT.cmake 脚本并相应地调整 CMAKE_MODULE_PATH 变量:

If your application requires exactly freeglut (that is, uses some of its extensions incompatible with other GLUT implementations), you need to ship your package with FindFREEGLUT.cmake script and adjust CMAKE_MODULE_PATH variable correspondingly:

# Assuming you have <source-dir>/cmake/FindFREEGLUT.cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(FREEGLUT REQUIRED)

您可以在网上找到现有脚本,也可以自己编写,例如

You may find existing script in the net, or write it by yourself, like here.

无论如何,如果您将freeglut安装在非系统位置,则需要向CMake提示.例如,通过调整 CMAKE_PREFIX_PATH .

In any case, if you have freeglut installed into non-system location, you need to hint CMake about that. E.g., by adjusting CMAKE_PREFIX_PATH.

这篇关于CMake在Clion的Windows上找不到Freeglut的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆