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

don't depend on submodules for clap and clap-helpers #38

Closed
wants to merge 2 commits into from
Closed

don't depend on submodules for clap and clap-helpers #38

wants to merge 2 commits into from

Conversation

witte
Copy link

@witte witte commented Jan 25, 2024

Hi folks!

I'm not that sure about this one, but thought it would be better to propose a PR directly instead of discussing different approaches beforehand, so feel free to give any feedback or even close it if you already have anything else in mind.

This solves #29 (by removing the submodules), and with some work on the RtAudio and RtMidi repos (to make them more FetchContent friendly) could also in the future solve #28 (RtAudio version mismatch), #27 (whatever problem pkg-config is having), #17 (old versions packaged on distro) and #2 (depend on vcpkg).

Actually with a little hacking even a small, static Qt could be made to work: I almost made this PR with Qt, RtAudio and RtMidi, but couldn't get them to behave consistently on all three platforms (yet)... 😢

I've seen you're using CPM on clap-helpers. I like it, but to me it looks like for simpler use cases like these just vanilla cmake is enough, that's why I wanted to check this out with you folks.

Thanks for the great work on clap!

@@ -1,3 +1,6 @@
# OS's
.DS_Store
Copy link
Author

Choose a reason for hiding this comment

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

these are all over the place on macOS, hope you don't mind

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally don't mind.
Though in the best practice, you could add those to your personal gitignore (global git config).

@@ -1,10 +1,8 @@
cmake_minimum_required(VERSION 3.17)
cmake_minimum_required(VERSION 3.24)
Copy link
Author

Choose a reason for hiding this comment

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

needed for the behavior that I want in FetchContent, I'll explain on another comment

Copy link
Contributor

Choose a reason for hiding this comment

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

3.24 is OK, it is quite old already.

@@ -40,6 +37,8 @@ else()
find_package(RtMidi CONFIG REQUIRED)
find_package(RtAudio CONFIG REQUIRED)
endif()
find_package(clap CONFIG REQUIRED)
find_package(clap-helpers CONFIG REQUIRED)
Copy link
Author

Choose a reason for hiding this comment

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

just wanted to get all the compiler flag stuff before all the find_package stuff

Comment on lines 3 to 22
FetchContent_Declare(
clap
GIT_REPOSITORY https://github.com/free-audio/clap.git
GIT_TAG main
SYSTEM
# 'FIND_PACKAGE_ARGS' will skip download if
# the target is already available in the system
FIND_PACKAGE_ARGS NAMES clap
)

FetchContent_Declare(
clap-helpers
GIT_REPOSITORY https://github.com/free-audio/clap-helpers.git
GIT_TAG main
SYSTEM
FIND_PACKAGE_ARGS NAMES clap-helpers
)


FetchContent_MakeAvailable(clap clap-helpers)
Copy link
Author

@witte witte Jan 25, 2024

Choose a reason for hiding this comment

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

This is the interesting bit: with FIND_PACKAGE_ARGS, if find_package is called and the package is already somewhere in the system, then FetchContent won't download (and build) the dependency.

I like it because it's very non intrusive: you can get your dependencies however it works for you (distro package manager, conan, homebrew, some custom cmake scripts, whatever) and, if none of that is available, FetchContent is used as a fallback to make things JustWork.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the benefit.
clap-host and clap-plugin aren't meant to be submodules of other projects.
They need a precise version of clap and clap-helpers to be built with.

Copy link
Author

@witte witte Jan 26, 2024

Choose a reason for hiding this comment

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

Sorry, I think I didn't make myself clear: this is about adding clap and clap-helpers as dependencies of clap-host using native cmake features only. FetchContent can be thought of as a cmake native CPM, even if a little more lower level.

We can tie them to specific versions (that need to be git tags or branches in the fetched repos) using the GIT_TAG property, I'll update the PR.

Copy link
Author

@witte witte Jan 26, 2024

Choose a reason for hiding this comment

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

added 1.2.0 as the version for the clap dependency at https://github.com/free-audio/clap-host/pull/38/files#diff-12e8125164bbfc7556b1781a8ed516e333cc0bf058acb7197f7415be44606c72R6 (clap-helpers doesn't have numbered versions yet).

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I think I didn't make myself clear: this is about adding clap and clap-helpers as dependencies of clap-host using native cmake features only. FetchContent can be thought of as a cmake native CPM, even if a little more lower level.

We can tie them to specific versions (that need to be git tags or branches in the fetched repos) using the GIT_TAG property, I'll update the PR.

But having them as submodules does almost the same (tied to a version, can be fetched and so on.). And they are both not very large repos so it's no problem to have them on the drive twice. So I think it's fine to have them as submodules

Copy link
Author

Choose a reason for hiding this comment

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

the biggest advantage is that, if you have a system wide installation of clap and clap-helpers, then FetchContent will use that instead of downloading their sources (fixing issues like #29).

Same would work if you call, say, cmake .. -DCMAKE_PREFIX_PATH=/some/folder/with/clap/and/clap-helpers/installed: if cmake can find the packages ready to use it'll use them, and fallback to downloading their sources only if needed (as opposed to the git submodules in which they always have to be downloaded).

Copy link
Author

@witte witte Feb 13, 2024

Choose a reason for hiding this comment

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

also, I'm probably not the only one who constantly forgets the --recurse-submodules on git clone and/or git submodule update --init, but that's on me.

@abique
Copy link
Contributor

abique commented Feb 10, 2024

Could it be that you want to add the clap-host as a submodule of your own project, for having simpler launchers?

@witte
Copy link
Author

witte commented Feb 13, 2024

Could it be that you want to add the clap-host as a submodule of your own project, for having simpler launchers?

not really, I really just see FetchContent as a more flexible, less error prone git submodule.

@witte
Copy link
Author

witte commented May 10, 2024

no problem, folks, I'd personally prefer a consistent way of dealing with the dependencies but what's here now makes sense too.

Cheers!

@witte witte closed this May 10, 2024
@witte witte deleted the fetchcontent-clap-clap-helpers branch May 10, 2024 01:43
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.

3 participants