Build system - setting VERSION in project() does not set PROJECT_VERSION_ variables

meowsqueak
Posts: 151
Joined: Thu Jun 15, 2017 4:54 am
Location: New Zealand

Build system - setting VERSION in project() does not set PROJECT_VERSION_ variables

Postby meowsqueak » Thu Feb 17, 2022 10:55 pm

Apologies if this has been asked before - the Search function on this forum seems to be broken (very slow, finally serves up a blank white page).

With ESP-IDF v4.3, I wish to set the project version (e.g. "1.2.3") in the CMake call to `project(... VERSION 1.2.3 ...)`, however from what I can tell, this is a redefined `project()` macro that doesn't seem to pass on the VERSION parameter.

Therefore the variables CMAKE_PROJECT_VERSION and PROJECT_VERSION are not set:

Code: Select all

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(myproject VERSION 1.2.3 LANGUAGES C)
message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")
message(STATUS "CMAKE_PROJECT_VERSION: ${CMAKE_PROJECT_VERSION}")
Both messages output null.

Obviously I can set these manually in the top-level CMakeLists.txt, which is tedious because there are a lot of them (CMAKE_PROJECT_VERSION_MAJOR, CMAKE_PROJECT_VERSION_MINOR, ..., PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, ...) but apart from that, is there an intention for the redefined `project` to not pass in such parameters? Is this a bug-by-omission or intended?

Looking at esp-idf/tools/cmake/project.cmake I see:

Code: Select all

macro(project project_name)
    ...
    # The actual call to project()
    __project(${project_name} C CXX ASM)
This doesn't seem to handle VERSION at all, although I see that shortly after this, the original definition of `project()` is restored and this does handle VERSION properly.

I found some docs for `PROJECT_VER`: https://docs.espressif.com/projects/esp ... ystem.html
However this does not automatically expand out to PROJECT_VERSION_MAJOR, _MINOR, etc.

For context, I need the _MAJOR, _MINOR, _PATCH numbers to pass to CPack.

Who is online

Users browsing this forum: No registered users and 91 guests