[CMake] How to Build Subdirectory CMake Project GLFW and Change Targets

junk email mlg420sniperxxx69 at gmail.com
Fri May 17 02:55:37 EDT 2019


Hello,

I am trying to understand how to build a subdirectory project that has its
own CMakeLists.txt file already setup. In this case, I am using the open
source library GLFW to help me with some of my OpenGL applications. Here is
a sample directory structure I am working with.

Root
├── CMakeLists.txt
├── MainProject
├── build
└── glfw-3.3

The folder MainProject is where I will be doing all my own development and
has a src, include, and lib folder associated with it. The glfw-3.3
directory was downloaded from online and has its own CMakeLists.txt file as
mentioned previously. So if I were to build my project from the current
build directory shown here, how should I add the glfw library to it and
also change its target outputs?

Answers online suggest using ExternalProject_Add(), while others say to
simply add_subdirectory() and then change some of the properties. I want to
be able to have a user run the root CMake file and have the targets be
correctly placed (since users might be on different operating systems).
Either way I have not been able to find an explicit example, perhaps my
Googling skills for CMake are lacking, and any help on this would be
appreciated. Thank you for your time.

Best,
mlg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190516/f488edfc/attachment.html>


More information about the CMake mailing list