-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement dynamic versioning #1
base: FetchContent
Are you sure you want to change the base?
Conversation
Also please rebase this later after we've resolved the discussion in the PR |
@LecrisUT Nice work ! Thanks a lot. I didn't know it was possible to do that :) This will be very nice even for my personal projects. So if I understand correctly the only thing I need to do now is to check is the version has a pos-version to trigger a warning on CPM to warn user ? |
Yes, I've made a comment on the original PR about a regex you can use for that.
Be careful that as I've written in my note, this does not work for build-able cmake projects. I am still working on an interface for that and if you're interested I'll ping you back when I have that. |
You mean it is not econfiguring on version changes? |
I.e.: $ cmake -B ./build_dir -S ./
$ cmake --build ./build_dir
$ git tag v1.2.3
$ cmake --build ./build_dir Last step will not be re-configured. There are ways around it by defining a |
@flagarde Heads up cmake_minimum_required(VERSION 3.25)
find_package(CmakeExtraUtils REQUIRED)
include(DynamicVersion)
dynamic_version(PROJECT_PREFIX My_Project_)
project(My_Project
VERSION ${PROJECT_VERSION})
configure_file(version.cpp.in version.cpp)
add_library(version_lib ${CMAKE_CURRENT_BINARY_DIR}/version.cpp)
# Make sure version is re-calculated even if you pass `cmake --build . --target version_lib`
# `My_Project_Version` is automatically generated target with the name from `PROJECT_PREFIX`
add_dependencies(version_lib My_Project_Version)
# Rebuild `version.cpp` whenever the version changes
# `.version` is automatically generated
set_property(SOURCE version.cpp.in APPEND PROPERTY
OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/.version) Would appreciate any testing or feedback on this |
Looks very nice. I will try to dedicate so time on this. Thx for this nice work 😀 |
This is more relevant in the PR, but I don't want to pollute it, especially since the maintainers did not respond to us yet. The installation location does not work for using with The idea is that This seems to work:
I yes you need to activate a language for cmake to find the right place. I enable C language when installing so it should be ok. |
@LecrisUT yes you need to activate a language for cmake to find the right place. I enable C language when installing so it should be ok? |
You don't actually need to, it's just a developer warning. The only variable that will not be constructed is |
Good to know that there is a place that we can use. I didn't know. As the cpm it is endianess independent we can use this path. I will supress then the enable_language |
I have left out setting the logic of how to configure
CPM.cmake
if it is release or not. You can do that fromGIT_DESCRIBE
(if it has a post-version or not)