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 config #1418

Open
wants to merge 2 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.

# after building it
cmake --install <insert_build_directory_here> --component godot-cpp-dev

The reason is so that this can be easily installed via a package manager without resorting to patches.

This project uses the standard CMAKE_INSTALL_* variables, so that the package manager can decide where to install the various artifacts of this package.

Also provides:

  • config file so it can be found via find_package
  • config-version file can the user can specify which version they require

From a user's perspective they can use this library like so:

find_package("godot-cpp" 4.2.0 CONFIG REQUIRED)
target_link_library("my-gdextension-project" PRIVATE "godot::cpp")

Note that the target library's name godot::cpp is the consistent as when used via find_package or as a sub-project.

This is because target_link_options was added in v3.13
So this wouldn't build with cmake v3.12

Likewise in CMAKE_CXX_STANDARD only supports value of 17 starting with
cmake v3.9
So the test wouldn't build properly with cmake v3.6
@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

This is so this library can be used via a package manager

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

godot-cpp-dev is the installed component this is so that if this
library is a subproject, the user can install their project without
installing this library by specifying the components

As BUILD_INTERFACE requires absolute path, this means that
GODOT_GDEXTENSION_DIR needs to be an absolute path

config filename can either be PascalCase or kebab-case, the latter was
chosen to be consistent with the package's name (godot-cpp)

string(JSON ...) is only available in cmake v3.19, as it is used to
obtain the version, this means that config-version file is only created
when using cmake v3.19 or later
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
3 participants