Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get product version via terminal when building cmake project

Is there a way to get product version when building the project via cmake from terminal. In the CMakeLists.txt I have declared:

project(sayProject VERSION "1.0")

Appreciate any help.

like image 262
Oleg Avatar asked Oct 28 '25 05:10

Oleg


1 Answers

If you want to read the setting of PROJECT_VERSION without actually running cmake, then this answer will get you that.

Specifically, I use this script:

cmake --system-information |
  awk -F= '$1~/CMAKE_PROJECT_VERSION:STATIC/{print$2}'
like image 140
Guss Avatar answered Oct 31 '25 08:10

Guss



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!