forked from lijiext/lammps
Add utility function to determine LAMMPS version in CMake
This commit is contained in:
parent
db180209b3
commit
b0f5400d52
|
@ -43,6 +43,29 @@ function(validate_option name values)
|
|||
endif()
|
||||
endfunction(validate_option)
|
||||
|
||||
function(get_lammps_version version_header variable)
|
||||
file(READ ${version_header} line)
|
||||
set(MONTHS x Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
|
||||
string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\1" day "${line}")
|
||||
string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\2" month "${line}")
|
||||
string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\3" year "${line}")
|
||||
string(STRIP ${day} day)
|
||||
string(STRIP ${month} month)
|
||||
string(STRIP ${year} year)
|
||||
list(FIND MONTHS "${month}" month)
|
||||
string(LENGTH ${day} day_length)
|
||||
string(LENGTH ${month} month_length)
|
||||
if(day_length EQUAL 1)
|
||||
set(day "0${day}")
|
||||
endif()
|
||||
if(month_length EQUAL 1)
|
||||
set(month "0${month}")
|
||||
endif()
|
||||
set(${variable} "${year}${month}${day}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION)
|
||||
|
||||
# Cmake modules/macros are in a subdirectory to keep this file cleaner
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@ find_package(PkgConfig)
|
|||
pkg_check_modules(PC_LAMMPS liblammps@LAMMPS_LIB_SUFFIX@)
|
||||
find_path(LAMMPS_INCLUDE_DIR lammps/library.h HINTS ${PC_LAMMPS_INCLUDE_DIRS} @CMAKE_INSTALL_FULL_INCLUDEDIR@)
|
||||
|
||||
# TODO figure these out library version from header
|
||||
set(LAMMPS_VERSION 20180822)
|
||||
set(LAMMPS_VERSION @LAMMPS_VERSION@)
|
||||
set(LAMMPS_API_DEFINES @LAMMPS_API_DEFINES@)
|
||||
|
||||
find_library(LAMMPS_LIBRARY NAMES lammps@LAMMPS_LIB_SUFFIX@ HINTS ${PC_LAMMPS_LIBRARY_DIRS} @CMAKE_INSTALL_FULL_LIBDIR@)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# after you added @CMAKE_INSTALL_FULL_LIBDIR@/pkg-config to PKG_CONFIG_PATH,
|
||||
# e.g. export PKG_CONFIG_PATH=@CMAKE_INSTALL_FULL_LIBDIR@/pkgconfig
|
||||
|
||||
prefix=@CMAKE_INSTALL_FULL_PREFIX@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
|
||||
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
|
||||
|
||||
|
|
Loading…
Reference in New Issue