From 6273e593a35d96585b2c7b68d4b15150ca8097d3 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 23 Jun 2022 23:09:13 -0400 Subject: [PATCH] add "package" target to support building a windows installer with NSIS --- cmake/Modules/LAMMPSInterfacePlugin.cmake | 7 +++++++ examples/PACKAGES/pace/plugin/CMakeLists.txt | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cmake/Modules/LAMMPSInterfacePlugin.cmake b/cmake/Modules/LAMMPSInterfacePlugin.cmake index 0cdf0bb564..d80d7609b7 100644 --- a/cmake/Modules/LAMMPSInterfacePlugin.cmake +++ b/cmake/Modules/LAMMPSInterfacePlugin.cmake @@ -81,6 +81,13 @@ function(get_newest_file path variable) set(${variable} ${_bestfile} PARENT_SCOPE) 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. add_library(lammps INTERFACE) diff --git a/examples/PACKAGES/pace/plugin/CMakeLists.txt b/examples/PACKAGES/pace/plugin/CMakeLists.txt index f4068a03c9..6ad9c791ba 100644 --- a/examples/PACKAGES/pace/plugin/CMakeLists.txt +++ b/examples/PACKAGES/pace/plugin/CMakeLists.txt @@ -31,6 +31,23 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_CROSSCOMPILING) set_target_properties(paceplugin PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols") 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() set_target_properties(paceplugin PROPERTIES LINK_FLAGS "-rdynamic") endif()