modernize project() command and create project version string with dots
This commit is contained in:
@ -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!")
|
||||
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
|
||||
if(POLICY CMP0074)
|
||||
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)
|
||||
get_property(BUILD_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
|
||||
@ -75,13 +75,25 @@ function(get_lammps_version version_header variable)
|
||||
list(FIND MONTHS "${month}" month)
|
||||
string(LENGTH ${day} day_length)
|
||||
string(LENGTH ${month} month_length)
|
||||
if(day_length EQUAL 1)
|
||||
set(day "0${day}")
|
||||
# no leading zero needed for new version string with dots
|
||||
# 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()
|
||||
if(month_length EQUAL 1)
|
||||
set(month "0${month}")
|
||||
if(NOT tweak)
|
||||
set(tweak "0")
|
||||
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()
|
||||
|
||||
function(check_for_autogen_files source_dir)
|
||||
|
||||
Reference in New Issue
Block a user