democloid / picoTracker

BSD 3-Clause "New" or "Revised" License
187 stars 17 forks source link

Enable the PROJECT_NUMBER, PROJECT_RELEASE and BUILD_COUNT to be overridden when running cmake #194

Closed mattsoftware closed 2 months ago

mattsoftware commented 2 months ago

Updates the defines in the project to be surrounded by #ifndef statements so existing functionality should not be changed.

Updates the CMakeLists.txt file to accept the following flags from the command line when doing a cmake on the project...

-DPROJECT_NUMBER -DPROJECT_RELEASE -DBUILD_COUNT

Also with the appropriate defaults that already exist in the existing files.

I'm not sure how these values are updated (are they updated manually or during a pipline build?) if so it would probably be best to remove the defaults from the source code an rely on the config in the CMakeList.txt file. (If this pull request is accepted in the first place :)

maks commented 2 months ago

Thanks for contributing this. I think it will be useful as this way I and others could just have a shell script or shell env vars defined for local builds instead of needing to modify BuildNumber.h and even for CI it will be a bit cleaner as currently the Github action does:

run: echo "#define BUILD_COUNT \"$GH_RUN_NUMBER\"" > sources/Application/Model/BuildNumber.h