在CLion上将GLFW链接到CMake [英] Linking GLFW on CLion with CMake

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

问题描述

有人知道如何将glfw链接到CLion项目吗? CLion基于CMake,因此,如果您对CMake有所了解,可以为您提供帮助。

Does anyone know how to link glfw to a CLion project? CLion is based on CMake so if you have knowledge on CMake, you can help.

我要做的是将依赖项放入项目文件夹,以便当我将我的代码推送到git,其他下载该代码的人将不必在本地进行任何链接,便会为他们建立环境。

What I want to do is, to put my dependencies into my project folder so when I push my code to git, others who download the code won't have to do any linking locally, the environment will be set up for them.

我试图移动从glfw的根文件夹到项目文件夹,但是从那时起,我一直无法成功调整我的 CMakelist.txt 文件,使其实际上能够正确链接该库。我无法正常工作。我尝试按照glfw网站上的教程进行操作,但假定您知道如何通过添加子目录以及所有内容来解决CMake的问题,而这正是我失败的地方。

I tried to moving the root folder of glfw to the project folder, but from then on, I have failed to successfully adjust my CMakelist.txt file to actually be able to link the library properly. I couldn't get it to work. I tried following the tutorial on the glfw website but that assumes you know your way around CMake with the addition of sub directories and all and that's where I fail anyway.

这是我的 CMakelists.txt 文件不起作用。

This is my CMakelists.txt file that doesn't work.

cmake_minimum_required(VERSION 3.3)
project(Boomer)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

include_directories(${PROJECT_SOURCE_DIR}/glfw-3.1.2.bin.WIN64)

set(SOURCE_FILES main.cpp)
add_executable(Boomer ${SOURCE_FILES})

任何帮助都会得到帮助。

Any help would be appreicated.

推荐答案

尝试一下:

find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(Boomer ${GLFW_STATIC_LIBRARIES})

这篇关于在CLion上将GLFW链接到CMake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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