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

cmake: Add install rules and option to use submodule dependencies #356

Merged
merged 3 commits into from Nov 9, 2023

Conversation

ekilmer
Copy link
Contributor

@ekilmer ekilmer commented Nov 7, 2023

Package ecosystems that know how to install CMake projects can now package nanobind for distribution without using submodule'd dependencies.

nanobind does not install any compiled library artifacts. Instead, all necessary source files and supporting CMake files are installed to build nanobind within another CMake project.

A CMake user can now adjust the CMake option NB_USE_SUBMODULE_DEPS to choose whether nanobind will use and/or install the submodule'd external dependencies. This is ON by default, allowing nanobind's CMake logic to continue operating as it did previously.

Another CMake option was introduced, NB_CREATE_INSTALL_RULES, to allow users to choose whether to enable or disable the installation rules. Notably, if nanobind is added to a CMake project with add_subdirectory, the installation rules are disabled, because installing source files probably isn't the expected result of the parent project(s). Install-rule generation still respects the standard CMake CMAKE_SKIP_INSTALL_RULES variable.

Package ecosystems that know how to install CMake projects can now
package nanobind for distribution without using submodule'd
dependencies.

nanobind does not install any compiled library artifacts. Instead, all
necessary source files and supporting CMake files are installed to build
nanobind within another CMake project.

A CMake user can now adjust the CMake option `NB_USE_SUBMODULE_DEPS` to
choose whether nanobind will use and/or install the submodule'd external
dependencies. This is `ON` by default, allowing nanobind's CMake logic
to continue operating as it did previously.

Another CMake option was introduced, `NB_CREATE_INSTALL_RULES`, to allow
users to choose whether to enable or disable the installation rules.
Notably, if nanobind is added to a CMake project with
`add_subdirectory`, the installation rules are disabled, because
installing source files probably isn't the expected result of the parent
project(s). Install-rule generation still respects the standard CMake
`CMAKE_SKIP_INSTALL_RULES` variable.
CMakeLists.txt Outdated Show resolved Hide resolved
Use CMake's `GNUInstallDirs` to provide initial variable values, then
create a variable `NB_INSTALL_DATADIR` to allow a user to specify where
nanobind's files are installed.
Copy link
Owner

@wjakob wjakob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That smaller set of changes looks much more reasonable, thanks! A few comments from me.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
cmake/nanobind-config.cmake Show resolved Hide resolved
@wjakob
Copy link
Owner

wjakob commented Nov 9, 2023

Looks all good to me now, thank you!

@wjakob wjakob merged commit 5bde652 into wjakob:master Nov 9, 2023
21 checks passed
@ekilmer ekilmer deleted the add-install-rules branch November 9, 2023 14:43
@ekilmer ekilmer restored the add-install-rules branch November 9, 2023 14:43
@ekilmer ekilmer deleted the add-install-rules branch January 4, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants