Appending version number to project bin file

alsaleem00
Posts: 8
Joined: Tue Oct 06, 2020 12:40 pm

Appending version number to project bin file

Postby alsaleem00 » Sun Jan 31, 2021 10:46 am

I managed to set app version number to project using PROJECT_VER in "CMakeLists.txt".

If I compile the project, it will produce {projectname}.bin.
I can read the version using code. However, all versions have same bin name.

Is there a config variable i can use to make build produces distinctive bin name based on PROJECT_VER and/or other variable ?
Something like {projectname}_{othervar}_{PROJECT_VER}.bin

Thanks.

chegewara
Posts: 2376
Joined: Wed Jun 14, 2017 9:00 pm

Re: Appending version number to project bin file

Postby chegewara » Mon Feb 01, 2021 7:39 am

How about this:

Code: Select all

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(PROJECT_VER "1.0.0")
project(projectname_${PROJECT_VER})
Only thing is that PROJECT_VER is stripped after first dot which will result:

Code: Select all

-- App "projectname_1.0.0" version: 1.0.0
...
build/projectname_1.bin


Maybe @Angus can help with that.

alsaleem00
Posts: 8
Joined: Tue Oct 06, 2020 12:40 pm

Re: Appending version number to project bin file

Postby alsaleem00 » Mon Feb 01, 2021 11:49 am

Hi @chegewara,
this is smart approach.
Indeed, it will produce {projectname}_1.bin for (1.0.1) PROJECT_VER.

I tried to concat the two strings out side like

set(PROJECT_VER "3.0.1")
set(PROJECT_PREF "myproject")
set(PROJECT_BIN "${PROJECT_PREF}_${PROJECT_VER}")

project(${PROJECT_BIN})
but same result. It looks that dot is prohibited?

can you help @Angus ?

thanks.

alsaleem00
Posts: 8
Joined: Tue Oct 06, 2020 12:40 pm

Re: Appending version number to project bin file

Postby alsaleem00 » Mon Feb 01, 2021 12:25 pm

It looks that this is a problem with cmake.
If i replace dots with underscore 1_0_1, it works.
.map & .elf files are produced correctly (with dots)

Any further suggestion?

Thanks.

alsaleem00
Posts: 8
Joined: Tue Oct 06, 2020 12:40 pm

Re: Appending version number to project bin file

Postby alsaleem00 » Mon Feb 01, 2021 5:22 pm

I came up with a compromise solution:

Code: Select all

set(PROJECT_VER "4.0.1")
set(PROJECT_VERU ${PROJECT_VER})
set(PROJECT_PREF "myproject")

string (REPLACE "\." "_" PROJECT_VERU ${PROJECT_VERU})
set(PROJECT_BIN "${PROJECT_PREF}_${PROJECT_VERU}")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)

project("${PROJECT_BIN}")
This way i keep the version number inside with "dot" and produce bin file that shows version with underscore.

Thanks.

Who is online

Users browsing this forum: Baidu [Spider] and 126 guests