Giter Club home page Giter Club logo

cmakeextrautils's Introduction

CMakeExtraUtils

Extra utilities for cmake:

Installation

These utilities can be included using both find_package() and ExternalProject, e.g. if CMakeExtraUtils is already installed on your system:

cmake_minimum_required(VERSION 3.20)

find_package(CMakeExtraUtils REQUIRED)

include(DynamicVersion)
dynamic_version()

project(MyProject
        VERSION ${PROJECT_VERSION})

or if you want to download a specific version:

cmake_minimum_required(VERSION 3.20)

FetchContet_Declare(CMakeExtraUtils
        GIT_REPOSITORY https://github.com/LecriUT/CMakeExtraUtils
        GIT_TAG v0.1.1)
FetchContent_MakeAvailable(CMakeExtraUtils)

include(DynamicVersion)
dynamic_version()

project(MyProject
        VERSION ${PROJECT_VERSION})

TODO for v1.0

  • Automation:
  • Add simple pre-commit and pyproject.toml environment
  • Fix DynamicVersion to work with buildable projects
  • Test coverage:
    • DynamicVersion
    • PackageComps

cmakeextrautils's People

Contributors

lecrisut avatar loriab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

loriab

cmakeextrautils's Issues

status and minimum cmake

Hi @LecrisUT, we've chatted about CMake some over at Libxc. The Libint project could use something like your DynamicVersion, but they'd like to stick with cmake=3.16. Preliminary tests show DynamicVersion does not like 3.16. Possibly they might be willing to bump the version, but I wanted to inquire if (1) 3.16 is even feasible after modifications and (2) are you ready for users at this stage? Thanks!

[packit] Invalid config

Failed to load packit config file:

Cannot parse package config: ValidationError({'jobs': {0: {'packages': defaultdict(<class 'dict'>, {'cmake-extra-utils': {'value': {'files_to_sync': {3: {'deest': ['Unknown field.']}}}}})}, 1: {'packages': defaultdict(<class 'dict'>, {'cmake-extra-utils': {'value': {'files_to_sync': {3: {'deest': ['Unknown field.']}}}}})}, 2: {'packages': defaultdict(<class 'dict'>, {'cmake-extra-utils': {'value': {'files_to_sync': {3: {'deest': ['Unknown field.']}}}}})}, 3: {'packages': defaultdict(<class 'dict'>, {'cmake-extra-utils': {'value': {'files_to_sync': {3: {'deest': ['Unknown field.']}}}}})}, 4: {'packages': defaultdict(<class 'dict'>, {'cmake-extra-utils': {'value': {'files_to_sync': {3: {'deest': ['Unknown field.']}}}}})}}, 'packages': defaultdict(<class 'dict'>, {'cmake-extra-utils': {'value': {'files_to_sync': {3: {'deest': ['Unknown field.']}}}}})}).

For more info, please check out the documentation or contact the Packit team.

`DynamicVersion` fails with `FALLBACK_VERSION` + `git`

execute_process(COMMAND ${GIT_EXECUTABLE} status
WORKING_DIRECTORY ${ARGS_PROJECT_SOURCE}
RESULT_VARIABLE git_status_result
OUTPUT_QUIET)
if (NOT git_status_result EQUAL 0)
message(${error_message_type}
"Project source is neither a git repository nor a git archive:\n"
" Source: ${ARGS_PROJECT_SOURCE}"
)
return()
endif ()
# Get version and describe-name
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --long --match=?[0-9.]*
WORKING_DIRECTORY ${ARGS_PROJECT_SOURCE}
OUTPUT_VARIABLE describe-name
OUTPUT_STRIP_TRAILING_WHITESPACE
COMMAND_ERROR_IS_FATAL ANY)

Should remove COMMAND_ERROR_IS_FATAL ANY and instead parse the exit code

Generating `full_version`

This is more nuanced as discussed in the PR. Need to investigate how setuptools_scm calculates it more carefully.

          >> but computing the next M.m.p always seemed iffy -- perhaps scm has conventions nowadays.

Interesting, can you elaborate. I thought it was just the git describe info directly.

I was referring to .postN being distance beyond the most recent tag, which is what one gets from git describe. Whereas .devN is distance on the way to the next tag, so the versioner software has to make a choice whether that's M+1.0 or M.m+1 or M.m.p+1, etc. I get around this in that psi4 script by having the user commit the intended upcoming tag, but I don't pretend that that's a feature :-) scm might well have conventions on this now -- I just haven't looked into it lately. https://packaging.python.org/en/latest/specifications/version-specifiers/#summary-of-permitted-suffixes-and-relative-ordering (succeeds pep440).

Originally posted by @loriab in #19 (comment)

Parsing `DynamicVersion` with suffix

For example if the latest tag is v2.1.0-rc1, this is allowed by git describe --match=?[0-9.]*. But there is an inconsistency between parsing from git_archival.txt and setuptools-scm

  • git_archival.txt: describe-name = v2.1.0-rc1-257-gcbc8618a5
  • PKG-INFO: Version: 2.1.0rc2.dev257+gcbc8618

Issues are that the - in the rc is removed and the regex needs to account for the version syntax having - suffix in its name.

DynamicVersion: New commits requires re-configuration

It is not ideal because you need to run cmake --build twice to pick up changes on the commit/tag, etc. This is because it is consumed via configure_file

Potential alternatives:

  • Allow to provide a custom file(WRITE) script/function or other way to write the commit metadata at build time instead of configure time

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.