-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
WIP: build(uwebsockets): add cmakelists #1788
base: master
Are you sure you want to change the base?
Conversation
Hey @uNetworkingAB , I’ve been thinking that we could benefit from using CMake as the standard build system, so I drafted some CMakeLists for both uWebSockets and uSockets. I was able to successfully compile all the examples and run the HelloWorld example on Windows (with MSVC!). I’m planning to add CMakeLists for the benchmarks and tests as well. What are your thoughts on that? For testing, since uSockets is a submodule, I’m unsure about the best approach for a pull request (PR), as it would involve two parallel PRs. The process might be simpler if both uSockets and uWebSockets were in a monorepo, allowing for a single PR, but I understand that might be difficult or undesirable to change at this point. |
Project already uses Make and NMake. This CMake support is not Windows compatible (you have hardcoded flags just like the current approach). It is also not any simpler than current approach "make". It's also known from prior testing that CMake produces slower binaries due to CMake being an intermediary compiler rather than having explicit control of all flags (I have seen 20% perf. loss with CMake PRs). Project is more concerned with providing standards compliant headers, compatible with ANY "build system" rather than try and implement every single kind of variation of different competing "build systems" (I have enough experience dealing with people to know there are for every CMake fanatic, equal amount of Bazel fanatics, etc). There are videos of people unfamiliar with the project, still being perfectly capable of quickly finding the "make" approach and building binaries. TLDR; current approach is no act of randomness. And btw, old versions of uWS had CMake support and it was the most contended parts of the project that nobody could agree on. Literally saw 16 Prs of people making conflicting changes to CMake files. So I just removed it and ever since, has been quiet on that front. Also, uWS itself already is in vcpkg |
Speak of the devil - #1789 |
If there are mistakes, they can be fixed quickly. CMake has some real benefits: it makes it easier to find and manage dependencies, has built-in testing features, and supports cross-platform builds. It’s more flexible than using Make or NMake and works well with IDEs, making projects easier to set up and maintain.
I’m not so sure about that. CMake essentially generates Makefiles or Ninja files, and both can use identical flags. It’s possible the CMake you came across was misconfigured. You can pass any desired flags directly to the compiler, and there’s no inherent difference in the flags applied to Clang through CMake versus a Makefile. Alternatively, maybe the project was using MSVC or GCC? Most of CMake’s additional features are related to tooling: testing, dependency management, incremental builds, and integration with vcpkg. I don’t see it as being overly attached to a tool; I’m also not particularly familiar with Bazel. I just think improving tooling over time is as crucial as refining the code itself, as it ultimately enhances development speed.
CMake doesn't contradict the focus on standards-compliant headers and compatibility but it supports it. CMake promotes best practices and standard C++ features, ensuring the project remains portable across platforms. It acts as an abstraction layer, simplifying the build process without implementing every variation of other systems, as it generates them.
The problem is not compiling, but maintaining and building on top. Tooling is important and makefiles are just inferior in IDE than more proper buildsystem.
People may not have changed it simply because they don’t know how to modify build.c. Conflicts don’t necessarily mean that it was an issue either. If contributors are making conflicting changes, it just means they were not aligned, which can be addressed by having a clean CMake setup and proper guidelines.
Which doesn't allow me to custom build. -- Anyway, I guess it's not necessary to do. However, I believe it could offer significant benefits. We could even consider moving away from vcpkg entirely and leverage CMake's FetchContent tool instead. This would allow us to include the library at CMake configure time and build it as a dependency with specific options, such as whether to add libuv or other features, all managed through CMake's own dependency management system. |
😂 |
I just get this when I try your branch: cmake . [...] /usr/bin/ld: cannot find uSockets/*.o: No such file or directory |
just of curiosity, why is it |
It's not working
|
… both top level and uws)
will check tomorrow, with different compilers / system |
Suggesting a CMakeLists.txt file for easily building the project.
CMake also integrates well with vcpkg (inside IDE notably). This worked for me when building uWebSockets on Windows (with MSVC!).
ran with (through CLion) :
also : uNetworking/uSockets#229
Remaining tasks :