Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add CMake build system support #49
This adds support for building libhydrogen with CMake and—more importantly—easily integrating libhydrogen with CMake-based projects and IDEs.
# uncomment to use a local copy of libhydrogen or, say, git submodule # instead of searching for a system-installed version: #add_subdirectory(./libhydrogen) find_package(hydrogen REQUIRED) target_link_libraries(foo PRIVATE hydrogen::hydrogen)
Less "tacky" and more "mature", I would say :)
I went with CMake for a few reasons that I think make it a stronger choice than competing build systems.
Firstly, it has broad support in the larger C/C++ ecosystem. For example, Visual Studio, CLion, VS Code, and QtCreator all work natively with CMake projects, and plugins are available for any other major IDE. Even if you don't use an IDE to develop
Continuing along the same lines, I've found modern CMake's dependency integration story to be quite straightforward and flexible when I'm working with a well-configured package. Say I'm working on a project called
find_package(hydrogen REQUIRED) target_link_libraries(foo PRIVATE hydrogen::hydrogen)
By default, CMake will look for a system-installed copy of
I don't even have to modify
Once the local copy of
Finally, and—admittedly—more specific to my particular use case, CMake is the standard way to compile C/C++ code into Android projects via Android NDK, so
I've discussed what I see as CMake's strengths versus other, comparable build systems. But of course there's another alternative: no build system at all. A developer can always simply bundle up
Alright, let's get this in, then. But I probably won't be able to maintain this. I have no idea how to make this work for e.g. WebAssembly or the Arduino IDE.
We should make sure that the project never depends on this, and that the
Excellent, thanks! Your point about making sure libhydrogen can always be compiled directly seems completely reasonable to me.
I can add a target for the Arduino IDE, and for WebAssembly if you have an example of how you'd do that with, say, a Makefile.