modernize project() command and create project version string with dots

This commit is contained in:
Axel Kohlmeyer
2025-05-15 02:13:19 -04:00
parent 85f0853910
commit b3e7121535
2 changed files with 25 additions and 6 deletions

View File

@ -7,6 +7,10 @@ if(CMAKE_VERSION VERSION_LESS 3.20)
message(WARNING "LAMMPS is planning to require at least CMake version 3.20 by Summer 2025. Please upgrade!") message(WARNING "LAMMPS is planning to require at least CMake version 3.20 by Summer 2025. Please upgrade!")
endif() endif()
######################################## ########################################
# initialize version variables with project command
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
# set policy to silence warnings about ignoring <PackageName>_ROOT but use it # set policy to silence warnings about ignoring <PackageName>_ROOT but use it
if(POLICY CMP0074) if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
@ -27,7 +31,10 @@ endif()
######################################## ########################################
project(lammps CXX) project(lammps
DESCRIPTION "The LAMMPS Molecular Dynamics Simulator"
HOMEPAGE_URL "https://www.lammps.org"
LANGUAGES CXX C)
set(SOVERSION 0) set(SOVERSION 0)
get_property(BUILD_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) get_property(BUILD_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

View File

@ -75,13 +75,25 @@ function(get_lammps_version version_header variable)
list(FIND MONTHS "${month}" month) list(FIND MONTHS "${month}" month)
string(LENGTH ${day} day_length) string(LENGTH ${day} day_length)
string(LENGTH ${month} month_length) string(LENGTH ${month} month_length)
if(day_length EQUAL 1) # no leading zero needed for new version string with dots
set(day "0${day}") # if(day_length EQUAL 1)
# set(day "0${day}")
# endif()
# if(month_length EQUAL 1)
# set(month "0${month}")
#endif()
file(STRINGS ${version_header} line REGEX LAMMPS_UPDATE)
string(REGEX REPLACE "#define LAMMPS_UPDATE \"Update ([0-9]+)\"" "\\1" tweak "${line}")
if (line MATCHES "#define LAMMPS_UPDATE \"(Maintenance|Development)\"")
set(tweak "99")
endif() endif()
if(month_length EQUAL 1) if(NOT tweak)
set(month "0${month}") set(tweak "0")
endif() endif()
set(${variable} "${year}${month}${day}" PARENT_SCOPE) # new version string with dots
set(${variable} "${year}.${month}.${day}.${tweak}" PARENT_SCOPE)
# old version string without dots
# set(${variable} "${year}${month}${day}" PARENT_SCOPE)
endfunction() endfunction()
function(check_for_autogen_files source_dir) function(check_for_autogen_files source_dir)