Skip to content

Commit 022f761

Browse files
robertodrarnfinn
authored andcommitted
Fix versioning regex (#128)
* Fix versioning regex * Make versioning regex robust, fixes CI failures The current solutions is hacky, since we want to keep using pure CMake to extract this information. It should all be transferred to Python and use Git to describe the number of commits that occurred since a tag (as done in Psi4). * Remove trailing dash in version with description
1 parent 90ef546 commit 022f761

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

cmake/custom/pcmsolver.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}
2020
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
2121

2222
if(NOT DEFINED PYMOD_INSTALL_LIBDIR)
23-
message(STATUS "Setting (unspecified) option ${variable}: ${default}")
23+
message(STATUS "Setting (unspecified) option PYMOD_INSTALL_LIBDIR: python")
2424
set(PYMOD_INSTALL_LIBDIR "python" CACHE STRING "Location within CMAKE_INSTALL_LIBDIR to which Python modules are installed" FORCE)
2525
else()
2626
message(STATUS "Setting option PYMOD_INSTALL_LIBDIR: ${PYMOD_INSTALL_LIBDIR}")

cmake/custom/version.cmake

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
file(READ ${PROJECT_SOURCE_DIR}/README.md _readme)
2-
#string(REGEX MATCH "[0-9]\\.[0-9]\\.[0-9]" _version_string ${_readme})
3-
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" _version_string ${_readme})
4-
string(REPLACE "." ";" _version_list ${_version_string})
2+
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)(-[a-z,A-Z,0-9]+)?" PCMSolver_VERSION ${_readme})
3+
string(REPLACE "." ";" _version_list ${PCMSolver_VERSION})
54
list(GET _version_list 0 PROJECT_VERSION_MAJOR)
65
list(GET _version_list 1 PROJECT_VERSION_MINOR)
7-
list(GET _version_list 2 PROJECT_VERSION_PATCH)
6+
list(GET _version_list 2 _patch_describe)
7+
# Get PROJECT_VERSION_PATCH
8+
string(FIND ${_patch_describe} "-" _has_describe)
9+
if(_has_describe GREATER -1)
10+
string(REGEX REPLACE "-[a-z,A-Z,0-9]+" "" PROJECT_VERSION_PATCH ${_patch_describe})
11+
else()
12+
set(PROJECT_VERSION_PATCH ${_patch_describe})
13+
endif()
814

9-
set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
10-
message(STATUS "${BoldGreen}PCMSolver v${${PROJECT_NAME}_VERSION}${ColourReset}")
15+
message(STATUS "${BoldGreen}PCMSolver v${PCMSolver_VERSION}${ColourReset}")

include/Config.hpp.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
2929
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
3030

31-
#define PROJECT_VERSION \
32-
@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
31+
#define PROJECT_VERSION @PCMSolver_VERSION@
3332
#define PCMSOLVER_VERSION \
3433
((PROJECT_VERSION_MAJOR << 16) | PROJECT_VERSION_MINOR | PROJECT_VERSION_PATCH)
3534
// clang-format on

0 commit comments

Comments
 (0)