我正在尝试使用CPACK和NSIS创建Windows安装程序。我正在使用Windows 10,CMake GUI,NSIS和Visual Studio社区版。
它很好用,但是我找不到选项,因此默认安装位置为:
C:\package-version.patch (e.g. C:\apbs-3.0)
apbs软件是一项协作工作,是跨平台的,但它不喜欢路径名中的“空格”,因此Windows 10 x64上NSIS的默认位置是:
C:\Program Files\package version (e.g. C:\Program Files\apbs 3.0\)
我最接近的是:
C:\\apbs 3.0
使用以下配置:
string(TOLOWER ${PROJECT_NAME} PACKAGE_NAME)
set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
set(CPACK_PACKAGE_DESCRIPTION "${PACKAGE_DESC}")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE.md")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGING_INSTALL_PREFIX "${PACKAGE_NAME}")
set(CPACK_PACKAGE_VERSION "${APBS_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VENDOR "${VENDOR}")
set(CPACK_PACKAGE_CONTACT "${CONTACT}")
set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${APBS_VERSION}")
set(CPACK_STRIP_FILES ON)
if(WIN32)
# From: https://martinrotter.github.io/it-programming/2014/05/09/integrating-nsis-cmake/
list(APPEND CPACK_GENERATOR "NSIS")
set(CPACK_PACKAGING_INSTALL_PREFIX "\\\\${PACKAGE_NAME}-${APBS_VERSION}")
set(CPACK_NSIS_INSTALL_ROOT "C:\\\\")
endif()
include (CPack)
是否有一套神奇的/未公开的CPACK变量集来消除多余的'\',并用'-'代替“空格”,以便使我的默认安装是?
C:\apbs-3.0\
以下内容为我提供了安装目录,C:\ APBS-3.0.0
set(CMAKE_MAJOR_VERSION "3")
set(CMAKE_MINOR_VERSION "0")
set(CMAKE_MICRO_VERSION "0")
set(PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
set(CPACK_PACKAGE_DESCRIPTION "APBS - Adaptive Poisson Boltzmann Solver")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/../LICENSE.md")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_BINARY_DIR};/.git/;.gitignore")
set(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_MAJOR_VERSION}")
set(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${CMAKE_MICRO_VERSION}")
set(CPACK_PACKAGE_VENDOR "PNNL")
set(CPACK_PACKAGE_CONTACT "APBS - https://github.com/Electrostatics/apbs-pdb2pqr")
set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_NAME}-${APBS_VERSION}")
set(CPACK_STRIP_FILES ON)
if(WIN32)
# From: https://martinrotter.github.io/it-programming/2014/05/09/integrating-nsis-cmake/
SET(CPACK_NSIS_PACKAGE_NAME "${PACKAGE_NAME}-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_MICRO_VERSION}")
SET(CPACK_NSIS_DISPLAY_NAME "${PACKAGE_NAME}-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_MICRO_VERSION}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${PACKAGE_NAME}-${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_MICRO_VERSION}")
SET(CPACK_NSIS_INSTALL_ROOT "C:")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PACKAGE_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}")
list(APPEND CPACK_GENERATOR "NSIS")
endif()
希望这可以帮助其他人寻找类似的解决方案。