Git Product home page Git Product logo

version.cmake's Introduction

CMake module to easily generate version.h and version.rc file


Usage

The easiest way to use Version.cmake is by adding GetCPM.cmake to your project.

First add GetCPM.cmake module :

mkdir cmake
wget -O cmake/GetCPM.cmake https://raw.githubusercontent.com/cppmf/GetCPM.cmake/master/GetCPM.cmake

Then add the following lines to the project's CMakeLists.txt.

# include CPM.cmake module
include(cmake/GetCPM.cmake)

# add Version.cmake
CPMAddPackage(
  NAME Version.cmake
  GITHUB_REPOSITORY cppmf/Version.cmake
  VERSION 2.0.0
)

# then call ProjectVersion function
generate_version_header(${PROJECT_NAME}
    # Description of the project
    DESCRIPTION ${PROJECT_DESCRIPTION}
    # Author
    AUTHOR_ORGANIZATION "Cpp Modern Framework"
    # Major version
    VERSION_MAJOR ${VERSION_MAJOR}
    # Minor version
    VERSION_MINOR ${VERSION_MINOR}
    # Patch version
    VERSION_PATCH ${VERSION_PATCH}
    # Revision version
    VERSION_REVISION ${VERSION_REVISION}
    # Version name
    VERSION_NAME ${VERSION_NAME}
    # Use custom config file
    VERSION_FILE ${CMAKE_CURRENT_LIST_DIR}/test_version.h.in
    # Use custom file name
    VERSION_FILE_NAME ${PROJECT_NAME}_version.h
)

# Add version file to the include directories
target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)

# Add rc file
if(WIN32)
  target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_version.rc)
endif()

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.