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

Make godot-cpp installable with CMake/SCons #1418

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ytnuf
Copy link
Contributor

@ytnuf ytnuf commented Mar 23, 2024

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.

@ytnuf ytnuf requested a review from a team as a code owner March 23, 2024 18:18
@AThousandShips AThousandShips added enhancement This is an enhancement on the current functionality discussion topic:buildsystem Related to the buildsystem or CI setup labels Mar 23, 2024
@AThousandShips AThousandShips added this to the 4.x milestone Mar 23, 2024
@AThousandShips
Copy link
Member

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

@ytnuf ytnuf force-pushed the installable branch 2 times, most recently from 10df0ac to c08b93e Compare March 23, 2024 19:48
@dsnopek dsnopek added the cmake label Apr 9, 2024
vicroms pushed a commit to microsoft/vcpkg that referenced this pull request Jun 8, 2024
Fixes #34492

- [X] Changes comply with the [maintainer
guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [X] The name of the port matches an existing name for this component
on https://repology.org/ if possible, and/or is strongly associated with
that component on search engines.
- [X] Optional dependencies are resolved in exactly one way. For
example, if the component is built with CMake, all `find_package` calls
are REQUIRED, are satisfied by `vcpkg.json`'s declared dependencies, or
disabled with
[CMAKE_DISABLE_FIND_PACKAGE_Xxx](https://cmake.org/cmake/help/latest/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.html).
- [X] The versioning scheme in `vcpkg.json` matches what upstream says.
- [X] The license declaration in `vcpkg.json` matches what upstream
says.
- [X] The installed as the "copyright" file matches what upstream says.
- [X] The source code of the component installed comes from an
authoritative source.
- [X] The generated "usage text" is accurate. See
[adding-usage](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/examples/adding-usage.md)
for context.
- [X] The version database is fixed by rerunning `./vcpkg x-add-version
--all` and committing the result.
- [X] Only one version is in the new port's versions file.
- [X] Only one version is added to each modified port's versions file.

Notes:
- This library is static only, so it's only supported for the static
triplets.
- Unfortunately, godot-cpp is not yet installable, so I had to patch its
cmake script.
I have made a PR upstream:
godotengine/godot-cpp#1418
But in the meanwhile, I have created an unofficial export target
`unofficial::godot::cpp`.
@ytnuf ytnuf closed this Aug 5, 2024
@ytnuf ytnuf deleted the installable branch August 5, 2024 10:14
@ytnuf ytnuf restored the installable branch October 12, 2024 14:59
@ytnuf ytnuf reopened this Oct 12, 2024
@ytnuf ytnuf marked this pull request as draft October 12, 2024 15:00
@ytnuf ytnuf force-pushed the installable branch 2 times, most recently from 5f31b59 to 76b3663 Compare October 13, 2024 15:53
@ytnuf
Copy link
Contributor Author

ytnuf commented Oct 13, 2024

With #1595 restructuring the CMake code, this PR has been changed to reflect that.

@ytnuf ytnuf marked this pull request as ready for review October 13, 2024 15:54
@ytnuf ytnuf force-pushed the installable branch 2 times, most recently from a7acff6 to ea6c9e4 Compare October 15, 2024 04:04
@ytnuf ytnuf force-pushed the installable branch 4 times, most recently from 6f3e9ab to bb02a3e Compare November 14, 2024 10:35
@ytnuf ytnuf changed the title Make godot-cpp installable with cmake config Make godot-cpp installable with CMake/SCons Nov 14, 2024
@ytnuf ytnuf marked this pull request as draft November 14, 2024 10:36
@ytnuf ytnuf force-pushed the installable branch 2 times, most recently from c7f4f49 to 77c3e62 Compare November 18, 2024 19:57
godot-cpp can be installed like this:
cmake && make && make install

It can be used like this:
find_pacakge("godot")
target_link_libraries("my_gdextension_project" PRIVATE "godot::cpp")

The install destination uses CMAKE_INSTALL_ so that package managers
can choose the best location for these artifacts

As BUILD_INTERFACE requires absolute path, this means that
GODOT_GDEXTENSION_DIR needs to be an absolute path
This for interoperability with other build systems
This aims to have feature parity with the installation via cmake
@enetheru
Copy link
Contributor

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake discussion enhancement This is an enhancement on the current functionality topic:buildsystem Related to the buildsystem or CI setup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow godot-cpp to be installable
4 participants