add "package" target to support building a windows installer with NSIS

This commit is contained in:
Axel Kohlmeyer
2022-06-23 23:09:13 -04:00
parent db079cd620
commit 6273e593a3
2 changed files with 24 additions and 0 deletions

View File

@ -81,6 +81,13 @@ function(get_newest_file path variable)
set(${variable} ${_bestfile} PARENT_SCOPE) set(${variable} ${_bestfile} PARENT_SCOPE)
endfunction() endfunction()
# get LAMMPS version date
function(get_lammps_version version_header variable)
file(STRINGS ${version_header} line REGEX LAMMPS_VERSION)
string(REGEX REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" "\\1\\2\\3" date "${line}")
set(${variable} "${date}" PARENT_SCOPE)
endfunction()
################################################################################# #################################################################################
# LAMMPS C++ interface. We only need the header related parts except on windows. # LAMMPS C++ interface. We only need the header related parts except on windows.
add_library(lammps INTERFACE) add_library(lammps INTERFACE)

View File

@ -31,6 +31,23 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
set_target_properties(paceplugin PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols") set_target_properties(paceplugin PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
endif() endif()
get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION)
find_program(MAKENSIS_PATH makensis)
if(MAKENSIS_PATH)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/lammps.ico
${CMAKE_SOURCE_DIR}/lammps-text-logo-wide.bmp ${CMAKE_SOURCE_DIR}/paceplugin.nsis ${CMAKE_BINARY_DIR})
if(BUILD_MPI)
add_custom_target(package ${MAKENSIS_PATH} -V1 -DVERSION=${LAMMPS_VERSION}-MPI paceplugin.nsis
DEPENDS paceplugin
BYPRODUCTS LAMMPS-ML-PACE-plugin-${LAMMPS_VERSION}-MPI.exe)
else()
add_custom_target(package ${MAKENSIS_PATH} -V1 -DVERSION=${LAMMPS_VERSION} paceplugin.nsis
COMMAND ${CMAKE_COMMAND} -E echo ${PWD}
DEPENDS paceplugin lammps.ico lammps-text-logo-wide.bmp paceplugin.nsis
BYPRODUCTS LAMMPS-ML-PACE-plugin-${LAMMPS_VERSION}.exe)
endif()
endif()
else() else()
set_target_properties(paceplugin PROPERTIES LINK_FLAGS "-rdynamic") set_target_properties(paceplugin PROPERTIES LINK_FLAGS "-rdynamic")
endif() endif()