Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use directly from CMAKE #186

Closed
computersarecool opened this issue Nov 7, 2018 · 6 comments
Closed

How to use directly from CMAKE #186

computersarecool opened this issue Nov 7, 2018 · 6 comments

Comments

@computersarecool
Copy link

Hi,

I want to use the .h and .c. files created by the webservice in my project but I do not want to store each ~10k line file in my repo.

Is there a way to include this and "build" it via CMAKE and have the needed files generated (similar to GLFW)?

Thanks for your project

@Shimmen
Copy link

Shimmen commented Nov 7, 2018

Yes it's possible. Make a subdirectory in your project and add a CMakeLists.txt in it together with the files:

cmake_minimum_required(VERSION 3.0)
project(Glad)

add_library(glad include/glad/glad.h src/glad.c)
target_include_directories(glad PUBLIC include/)

Then in your main CMakeLists.txt file put:

add_subdirectory(glad/)
target_link_libraries(<your target> PRIVATE glad)

Or something like that. There are a bunch of ways of achieving this.

@Dav1dde
Copy link
Owner

Dav1dde commented Nov 7, 2018

@Shimmen thanks for the explanation!

You can also look through the issue #174 where a few awesome people added more ways to do that.

Personally I'd include the generated files though, the symbols should be sorted so if you upgrade the generated files at one point you'll get minimal diffs, also it means you don't have a dependency on external resources and Python.

@Shimmen
Copy link

Shimmen commented Nov 7, 2018

I just realized I didn't at all supply an answer to the original question! Personally I like to keep the glad stuff out of my source directory and out of the build step of my main executable, so that's what my example does.

@Dav1dde
Copy link
Owner

Dav1dde commented Jan 19, 2019

I'll assume this is answered, if not please feel free to re-open.

@Dav1dde Dav1dde closed this as completed Jan 19, 2019
@DerekCresswell
Copy link

I understand it's typical to put the generated files into your include directory, but IS there a way to have this generate when building CMake?

I don't think requiring Python is that big of a deal, it's very common place. Having the option is at least nice.

@Dav1dde
Copy link
Owner

Dav1dde commented May 19, 2020

@DerekCresswell yes you can run the generator on a build, there is a CMakeLists.txt in the root of this repository that should allow you to do that (iirc through add_subdirectory).

I've also been working on glad2 which has a new CMakeLists.txt with an example here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants