Giter Club home page Giter Club logo

Comments (5)

foonathan avatar foonathan commented on May 16, 2024

I'm not sure. Is it possible to use the commit hash as a version number? Because that's the only one the project has at the moment.

from lexy.

Ryan-rsm-McKenzie avatar Ryan-rsm-McKenzie commented on May 16, 2024

This will fetch the current commit hash, which you can then pass to the project command.

execute_process(
    COMMAND "git" "rev-parse" "--short" "HEAD"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    RESULT_VARIABLE LEXY_VERSION
    OUTPUT_QUIET
)

from lexy.

foonathan avatar foonathan commented on May 16, 2024

I don't think that works, the version has to be integers separated by dots: https://cmake.org/cmake/help/latest/command/project.html?highlight=project#options

from lexy.

Ryan-rsm-McKenzie avatar Ryan-rsm-McKenzie commented on May 16, 2024

You could convert the result into a decimal.

execute_process(
    COMMAND "git" "rev-parse" "--short" "HEAD"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    OUTPUT_VARIABLE LEXY_VERSION
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
math(EXPR LEXY_VERSION "0x${LEXY_VERSION}" OUTPUT_FORMAT DECIMAL)

from lexy.

foonathan avatar foonathan commented on May 16, 2024

Yeah, that seems like too much magic. I'm closing this for now and will revisit it once I'm closer to an actual stable release.

from lexy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.