Advice on integrating GLFW into a CMAKE project?

Hey guys,

I’ll show an example CMakeLists.txt using the C++ lib fmt so you’ll have an idea what it is I’m trying to do.

cmake_minimum_required(VERSION 3.13)




target_link_libraries(libProj PRIVATE ${COMMON_LIBRARIES})

Basically, fmt defines an alias and adding it to target_link_libraries gives cmake all the information it needs to setup the include directories and the -l flags.

I did a look through the GLFW CMakeLists.txt file and didn’t see any aliases and couldn’t find any examples.

What’s the recommended way of integrating GLFW into an existing cmake project? Ideally I’d like to be able to just git clone … into a lib/ directory under my project root and then add it to cmake and voila.

Any advice/recommendations?

Have a look at the bulding applications with cmake and GLFW source chapter which should answer your questions.

Thank you for the link, that’s exactly what I was looking for.

I’m not sure why I wasn’t able to find it previously, but what I did find was the following, which didn’t describe accurately what I was looking for.