Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. modifying AndroidManifext.xml with CMake variable
Forum Updated to NodeBB v4.3 + New Features

modifying AndroidManifext.xml with CMake variable

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 345 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi -

    I've brought this subject up before, but I need to go a bit further.

    I need to introduce version numbering into my application, which will run on desktops and Android devices. I'd like to have a single place where I can define my version number (as a string is fine), and have it used in all environments.

    I know that for Android, the version number comes from the AndroidManifest.xml file, but I'm hazy on the syntax. For example:
    android.PNG

    1. what exactly is the meaning of the -- and %% in these fields? If this is documented somewhere, please feel free to refer me.

    2. can I populate this field with a CMake variable, such as:

    set(MYAPP_VERSION_NBR "1.0.3")
    

    and if so, how?

    1. if #2 is in fact possible, can I also use the value to set the value within my app as well, so that I can use it in the desktop builds?
        QCoreApplication::setApplicationVersion(/* what would I put in here? */)
    

    Thanks for any enlightment on this overall issue.

    mzimmersM 1 Reply Last reply
    1
    • mzimmersM mzimmers

      Hi -

      I've brought this subject up before, but I need to go a bit further.

      I need to introduce version numbering into my application, which will run on desktops and Android devices. I'd like to have a single place where I can define my version number (as a string is fine), and have it used in all environments.

      I know that for Android, the version number comes from the AndroidManifest.xml file, but I'm hazy on the syntax. For example:
      android.PNG

      1. what exactly is the meaning of the -- and %% in these fields? If this is documented somewhere, please feel free to refer me.

      2. can I populate this field with a CMake variable, such as:

      set(MYAPP_VERSION_NBR "1.0.3")
      

      and if so, how?

      1. if #2 is in fact possible, can I also use the value to set the value within my app as well, so that I can use it in the desktop builds?
          QCoreApplication::setApplicationVersion(/* what would I put in here? */)
      

      Thanks for any enlightment on this overall issue.

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by mzimmers
      #2

      Well, I put something together that works, partly based on this article:

      CMakeLists.txt snippet:

      # we set the version numbers here now.
      set (NGA_PRODUCT_ID "123")
      set (NGA_VERSION_MAJOR "1")
      set (NGA_VERSION_MINOR "0")
      
      # configure a header file to pass some of the CMake settings
      # to the source code
      configure_file (
        "${PROJECT_SOURCE_DIR}/versionnumber.h.in"
        "${PROJECT_BINARY_DIR}/versionnumber.h"  )
      

      A new file:

      // versionnumber.h.in
      // the configured options and settings for version numbers
      #define NGA_PRODUCT_ID @NGA_PRODUCT_ID@
      #define NGA_VERSION_MAJOR @NGA_VERSION_MAJOR@
      #define NGA_VERSION_MINOR @NGA_VERSION_MINOR@
      

      main.cpp (for now):

      #include "versionnumber.h"
      
      int main(int argc, char *argv[])
      {
          // macros below are defined in versionnumber.h.in
          QString version = QString::number(NGA_PRODUCT_ID)
              + "." + QString::number(NGA_VERSION_MAJOR)
              + "." + QString::number(NGA_VERSION_MINOR);
          QCoreApplication::setApplicationVersion(version);
          ...
      

      It works, but I'm not thrilled with it, because I'm bypassing the entry in the manifest file. If someone can show me how to use the CMake variables in the manifest file, I'd appreciate it. I also wasn't able to define those CMake variables as strings (tried various combinations of quotation marks), so I have to convert the numbers at runtime, which is a bit of a hack.

      Any suggestions are welcome. Thanks...

      JoeCFDJ 1 Reply Last reply
      1
      • mzimmersM mzimmers

        Well, I put something together that works, partly based on this article:

        CMakeLists.txt snippet:

        # we set the version numbers here now.
        set (NGA_PRODUCT_ID "123")
        set (NGA_VERSION_MAJOR "1")
        set (NGA_VERSION_MINOR "0")
        
        # configure a header file to pass some of the CMake settings
        # to the source code
        configure_file (
          "${PROJECT_SOURCE_DIR}/versionnumber.h.in"
          "${PROJECT_BINARY_DIR}/versionnumber.h"  )
        

        A new file:

        // versionnumber.h.in
        // the configured options and settings for version numbers
        #define NGA_PRODUCT_ID @NGA_PRODUCT_ID@
        #define NGA_VERSION_MAJOR @NGA_VERSION_MAJOR@
        #define NGA_VERSION_MINOR @NGA_VERSION_MINOR@
        

        main.cpp (for now):

        #include "versionnumber.h"
        
        int main(int argc, char *argv[])
        {
            // macros below are defined in versionnumber.h.in
            QString version = QString::number(NGA_PRODUCT_ID)
                + "." + QString::number(NGA_VERSION_MAJOR)
                + "." + QString::number(NGA_VERSION_MINOR);
            QCoreApplication::setApplicationVersion(version);
            ...
        

        It works, but I'm not thrilled with it, because I'm bypassing the entry in the manifest file. If someone can show me how to use the CMake variables in the manifest file, I'd appreciate it. I also wasn't able to define those CMake variables as strings (tried various combinations of quotation marks), so I have to convert the numbers at runtime, which is a bit of a hack.

        Any suggestions are welcome. Thanks...

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • mzimmersM mzimmers has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved