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 find package #619

Merged
merged 14 commits into from
Jul 15, 2024
Merged

CMake find package #619

merged 14 commits into from
Jul 15, 2024

Conversation

alxvth
Copy link
Contributor

@alxvth alxvth commented May 10, 2024

Installs ManiVaultTargets.cmake, ManiVaultConfig.cmake and related cmake packages files such that ManiVault can be found using find_package.

The ExamplePlugins, BinIO and SpectralViewer plugins show how this looks from a plugins perspective:

find_package(ManiVault COMPONENTS Core PointData ClusterData ImageData CONFIG)
target_include_directories(${MyPlugin} PRIVATE "${ManiVault_INCLUDE_DIR}")
target_link_libraries(${MyPlugin} PRIVATE ManiVault::Core ManiVault::PointData ManiVault::ClusterData ManiVault::ImageData)

The variables ManiVault_INCLUDE_DIR, ManiVault_INSTALL_DIR, ManiVault_LIB_DIR, ManiVault_LINK_LIBS and ManiVault_VERSION are automatically set in CONFIG mode.

For CMake to find the package, you need to define a path ManiVault_DIR that point to where the ManiVaultConfig.cmake lies. After building the core, this will be MV_INSTALL_DIR/cmake/mv, i.e. will now be a cmake folder next to the Debug, Release, etc. config folder in the install directory.

Since ManiVault is installed into a bit of a non-standard directory layout, I couldn't yet figure out how to set INTERFACE_INCLUDE_DIRECTORIES correctly, meaning that the target_include_directories have to be set explicitly. (Ideally only the target_link_libraries should be necessary).

You can also specify versions:

find_package(ManiVault 1 COMPONENTS Core PointData CONFIG)    # Ok
find_package(ManiVault 2 COMPONENTS Core PointData CONFIG)    # Won't work, we are at version 1

When using the core and plugins in a project with add_subdirectory (like in the DevBundle), the find package command must not use the REQUIRED argument.

TODO:

  • find_package on CI
  • Compatibility with add_subdirectory, as used in DevBundle
  • Test on Windows (msvc)
  • Test on Linux (gcc)
  • Test on MacOS (apple clang)
  • rebase to current master

@alxvth alxvth marked this pull request as draft May 10, 2024 15:16
@ThomasKroes ThomasKroes mentioned this pull request May 21, 2024
37 tasks
@alxvth alxvth marked this pull request as ready for review June 14, 2024 08:14
@sbvis
Copy link
Contributor

sbvis commented Jul 8, 2024

I built and ran the core and the ExamplePlugins, BinIO and SpectralViewer plugins on macOS. It was built correctly and ran correctly. Please see the screenshot below.

image

Copy link
Contributor

@sbvis sbvis left a comment

Choose a reason for hiding this comment

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

image

It build and ran successfully and I also see a cmake folder next to the Release.

Copy link
Contributor

@ThomasKroes ThomasKroes left a comment

Choose a reason for hiding this comment

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

Works on Win11

@alxvth
Copy link
Contributor Author

alxvth commented Jul 11, 2024

Nice, thanks for testing this! :)

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