cpp-best-practices / gui_starter_template

A template CMake project to get you started with C++ and tooling
The Unlicense
2.5k stars 447 forks source link

Add basic versioning #194

Closed lefticus closed 2 years ago

lefticus commented 2 years ago

Yes, this is probably better handled with a CMake configured file to make sure things do not get out sync with the main.cpp, but

lefticus commented 2 years ago

@aminya @ddalcino this is something I hit while recently using this template.

I say in the PR I'm not convinced that adding a configured header file to track the version information necessarily makes sense.

However, the more I think about it, maybe putting in a simple example for how to do that (and think of it as a best practice to make sure project information is properly transmitted to the C++ project) does make sense.

Please give me your thoughts on this.

codecov-commenter commented 2 years ago

Codecov Report

Merging #194 (9c7921f) into main (a85fe3d) will decrease coverage by 2.22%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #194      +/-   ##
==========================================
- Coverage   80.00%   77.77%   -2.23%     
==========================================
  Files           3        3              
  Lines          35       36       +1     
  Branches       18       19       +1     
==========================================
  Hits           28       28              
- Misses          6        7       +1     
  Partials        1        1              
Flag Coverage Δ
Linux 37.03% <0.00%> (-1.43%) :arrow_down:
Windows 80.00% <ø> (ø)
macOS ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main.cpp 42.85% <0.00%> (-3.30%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a85fe3d...9c7921f. Read the comment docs.

lefticus commented 2 years ago

This can be automated in CMake. I was planning to add this as part of the package_project PR.

https://github.com/TheLartians/PackageProject.cmake/blob/master/CMakeLists.txt

After looking through that file, I'm curious which part are you specifically saying can be automated with CMake?

I am specifying the project version via CMake, which automatically generates a config.hpp file.

lefticus commented 2 years ago

I took a second look at PackageProject, and this PR does seem to be orthogonal to that one. It assumes you already have an existing project() that is ready to be packaged.

aminya commented 2 years ago

This can be automated in CMake. I was planning to add this as part of the package_project PR. https://github.com/TheLartians/PackageProject.cmake/blob/master/CMakeLists.txt

After looking through that file, I'm curious which part are you specifically saying can be automated with CMake?

I am specifying the project version via CMake, which automatically generates a config.hpp file.

What I meant was that we can generate the version header file automatically.

ddalcino commented 2 years ago

What I meant was that we can generate the version header file automatically.

We could move config.hpp.in into project_options, but that moves a c++ file into a place where it cannot be modified on demand. That sounds like a problem to me.

Is the packaging code dependent on something like a config.hpp.in file?