How do I write the cmake script for clion to include glfw?

pale_rider
cmake_minimum_required(VERSION 3.15)
project(hello)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
set(CMAKE_CXX_STANDARD 11)

add_executable(hello main.cpp)
INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(hello ${GLFW_STATIC_LIBRARIES})

It tells me

CMake Error at /home/suprateek/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/193.5233.144/bin/cmake/linux/share/cmake-3.15/Modules/FindPkgConfig.cmake:696 (message):
  None of the required 'glfw3' found

when I try to build it. My glfw folder is located at /usr/local/include/GLFW.

Mizux

AFAIK, glfw3 is using CMake as the build system, (src: packages.debian.org/fr/sid/amd64/libglfw3-dev/filelist) which uses modern CMake, so you don't need GLFW_INCLUDE_DIRS etc...

Inside this file /usr/lib/cmake/glfw3/glfw3Targets.cmake (loaded by /usr/lib/cmake/glfw3/glfw3Config.cmake), you'll see:

...
# Create imported target glfw
add_library(glfw SHARED IMPORTED)

set_target_properties(glfw PROPERTIES
  INTERFACE_COMPILE_DEFINITIONS "GLFW_DLL"
  INTERFACE_INCLUDE_DIRECTORIES "/usr/include"
)
...

So you can simply use:

find_package(glfw3 REQUIRED)
...
target_link_libraries(Foo glfw) 

ps: same as my previous comment

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I include jars in a groovy script?

How to include external library (boost) into CLion C++ project with CMake?

How do I write a bash script to restart a process if it dies?

How do I include a literal double quote in a custom CMake command?

How do I write a loop in a gdb script?

GLFW3 library in CLion with CMake causes undefined symbols on MacOS

How do I do a proper input class in GLFW for a game engine

How do I write a script that kills a docker container?

How can i include SDL_gfx libraries in a Clion project?

How do I write a proper include and modulize my app in C?

How do I write a file path which include a regular expression

How can I include my direct x install location in clion?

How to correctly setup cmake for glfw on clion on MacOS

How can I include Vulkan-hpp with glfw?

How can I include a script with document.write?

How do I compile a subdirectory file in CLion?

How do I write a script that iterates over input values?

How do I write shell script for Redhat Linux bash shell

How do I make a block of script write to another script?

How do I write a script that runs on startup?

How do I write this BDD script?

How do I write the output of this loop to a script

How can i link GLFW and Dear ImGUI in CMAKE

How do I ask CMake to copy include directory while running "cmake install"?

How do I include a file in HTML Google Apps Script?

How to include external library in C++ from GitHub using CLion and CMake on Windows?

How do I include GitHub secrets in a python script?

How do I include the API key in apps script?

How do I know which DLLs I need to include to properly build a project on windows using cmake and mingw?