Make godot-cpp installable with CMake/SCons
This PR allows this library to be installable.
So the library can be built like this: Via CMake:
cmake && make && make install
Or via SCons:
scons install
A GDExtension project can use this library like so: Via CMake:
find_package("godot-cpp" 4.2.0 CONFIG REQUIRED)
target_link_library("my-gdextension-project" PRIVATE "godot::cpp")
Or via SCons:
env.ParseConfig("pkg-config godot-cpp --cflags --libs")
Reason
Currently the only supported way to use godot-cpp is to use as a subproject of your project. It kinda works but it's rather cumbersome because you need to rebuild godot-cpp when you build your project from scratch. This can be especially painful in CI. By allowing godot-cpp to be installable one can prevent unnecessary rebuilds. This also allows usage with a package manager (e.g vcpkg). As this also install a pkg-config file, godot-cpp can be used by projects that doesn't use neither CMake nor SCons.
- Bugsquad edit, closes: https://github.com/godotengine/godot-proposals/issues/9364
Please open a proposal to track the support and details of this feature, this is pretty specific and we'd need to judge the actual demand
With #1595 restructuring the CMake code, this PR has been changed to reflect that.
@ytnuf check the recent comments here Is there anything further to add to the discussion?
@dsnopek I guess we keep these PR's around in case others want to build upon your work for their own purposes?