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

Add a version and alias name for Jolt library in CMake #1426

Closed
nouturnsign opened this issue Dec 29, 2024 · 3 comments · Fixed by #1430
Closed

Add a version and alias name for Jolt library in CMake #1426

nouturnsign opened this issue Dec 29, 2024 · 3 comments · Fixed by #1430

Comments

@nouturnsign
Copy link

Could a version be added to the project? It would be helpful to be able to specify the version of Jolt in find_package.

Use case would be something like:

find_package(Jolt 5.2.0)

Also, could an ALIAS target be added for Jolt? e.g.

# ...
add_library(Jolt ${JOLT_PHYSICS_SRC_FILES})
add_library(Jolt::Jolt ALIAS Jolt)

I see that Jolt already exports with a namespace as in

	export(TARGETS Jolt
		NAMESPACE Jolt::
		FILE JoltConfig.cmake)

so it would be helpful to add a namespaced target for linking with Jolt when using add_subdirectory.

Use case would be something like:

add_subdirectory(vendor/JoltPhysics/Build)
target_link_libraries(my-library PRIVATE Jolt::Jolt)

Disclaimer: I am not good at CMake, but I see other projects do this. I can writeup a quick PR if it's relevant!

@jrouwe
Copy link
Owner

jrouwe commented Dec 30, 2024

Hello,

I have not seen these constructs before and I can't really find useful information on them either.

What does adding a version number do? Is it only a check so that if you do find_package(Jolt 10.0.0) that you would get an error? Or does it do more?

W.r.t. ALIAS, I have not tested this but wouldn't:

add_subdirectory(vendor/JoltPhysics/Build)
target_link_libraries(my-library PRIVATE Jolt)

work equally well? Also I'm not sure if the export won't conflict with the ALIAS since they're both defining Jolt::Jolt?

@nouturnsign
Copy link
Author

Re: version number, yes from my understanding, in the context of using CMake, it's useful so that find_package(Jolt 10.0.0 REQUIRED) would get an error if version 10.0.0 of Jolt was not found (REQUIRED would force an error; without REQUIRED, it would just not find the package). To add the version, it can be specified in the project command.

Re: ALIAS, yes that works equally well, but using a namespace appears to be a convention. No, it would not cause an error from my understanding. I see this in projects like spdlog and SDL. It's not always the case; I know GLFW does not.

@jrouwe jrouwe mentioned this issue Dec 31, 2024
@jrouwe
Copy link
Owner

jrouwe commented Dec 31, 2024

Ok, I ran some quick tests:

add_subdirectory(vendor/JoltPhysics/Build)
target_link_libraries(my-library PRIVATE Jolt)

works fine, but I guess there's no problem with having an alias. So I added both suggestions in #1430.

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 a pull request may close this issue.

2 participants