-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Integrate libwebsockets into existing projects (based on CMake build method) #2965
Comments
There's lots of ways to add LWS into a cmake file.
IMO your best bet is to break your cmake into a test case, and then try to port what you learned to your project's CMakeLists.txt. I am just a fan of minimal test cases when troubleshooting, though. It's usually the fastest way to figure things out. I did so here For an example of build as a submodule, link statically LWS's cmake files expose a handful of library targets and include targets, see the CMakeLists.txt in what I put on github there. pkg_config also works if your environment has it, but that's for like OS installed libraries usually. target_compile_options( Distros can have fairly out of date packages for LWS. Linking statically is sort of a safe bet and should provide for a reliable build process. Or having the dynamic library in the binary path. The MIT license is pretty permissive I think but I am not a lawyer. I posted a similar question earlier, was closed as it is indeed more of a cmake question...butttt cmake doesn't dictate what you export as the cmake library name with add_library...or any helper things for linking, include paths, or cflags needed. I ended up going to chatgpt and asked it generically, if I have a library B as a submodule in a git repo for project a, how do I link my application a to library b - and it informed me I needed to set stuff in the CMakeLists.txt file in library B with examples. It let me know what to look for at least, that I can't actually do it without knowing what B is making available as there isn't a standard. I am using msys2 for compiling, no idea about Visual Studio, I'm guessing VS is super smart about cmake and importing third party libraries into a project though! |
Hi lws-team,
First of all thank you for sharing such great work.
My project is built based on cmake. It mainly runs on windows and macos platforms. I hope to integrate libwebsockets into the project through cmake in an elegant way. I hope to get help from lws-team.
I have read almost all the files in the READMEs directory. This may be the most attentive and serious work I have ever seen on any project. So much documentation, so awesome. It's a pity that there are no tips on how to integrate it into the cmake project :(
emm...since I don't understand libwebsockets, I thought of the simplest way, which is to show the cmake structure of my project so that lws-team can better guide me on how to integrate libwebsockets elegantly.
TL;DR
My project folder structure is roughly as follows:
I usually put third-party dependencies in the deps directory
This CMakeLists.txt is located in the root directory of my-app, and its content is as follows:
Next is the content of the CMakeLists.txt file located in the deps root directory:
The CMakeLists.txt in the win32-pthreads directory looks like this:
The above content and directory structure constitute the cmake function of my project. If I want to integrate libwebsockets into my project, how should I do it? Looking forward to your guidance.
Thanks, Best Wishes!
The text was updated successfully, but these errors were encountered: