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.
Appending version number to project bin file
-
- Posts: 8
- Joined: Tue Oct 06, 2020 12:40 pm
Re: Appending version number to project bin file
How about this:
Only thing is that PROJECT_VER is stripped after first dot which will result:
Maybe @Angus can help with that.
Code: Select all
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(PROJECT_VER "1.0.0")
project(projectname_${PROJECT_VER})
Code: Select all
-- App "projectname_1.0.0" version: 1.0.0
...
build/projectname_1.bin
Maybe @Angus can help with that.
-
- Posts: 8
- Joined: Tue Oct 06, 2020 12:40 pm
Re: Appending version number to project bin file
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.
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.
-
- Posts: 8
- Joined: Tue Oct 06, 2020 12:40 pm
Re: Appending version number to project bin file
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.
If i replace dots with underscore 1_0_1, it works.
.map & .elf files are produced correctly (with dots)
Any further suggestion?
Thanks.
-
- Posts: 8
- Joined: Tue Oct 06, 2020 12:40 pm
Re: Appending version number to project bin file
I came up with a compromise solution:
This way i keep the version number inside with "dot" and produce bin file that shows version with underscore.
Thanks.
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}")
Thanks.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 344 guests