Build Windows Installer package with CPack and WIX

This commit is contained in:
Sebastian Messmer 2018-09-27 04:18:06 +02:00
parent c4b56e0d99
commit e45e410973
6 changed files with 68 additions and 23 deletions

View File

@ -10,8 +10,9 @@ platform:
- Any CPU
configuration:
- Debug
- RelWithDebInfo
- Debug
- RelWithDebInfo
- Release
version: '{branch}-{build}'
@ -45,3 +46,11 @@ build_script:
- cmd: .\test\blobstore\%CONFIGURATION%\blobstore-test.exe
- cmd: .\test\cryfs\%CONFIGURATION%\cryfs-test.exe
#- cmd: .\test\cryfs-cli\%CONFIGURATION%\cryfs-cli-test.exe
- cmd: cpack --verbose -G WIX
on_failure:
- cmd: type C:\projects\cryfs\build\_CPack_Packages\win64\WIX\wix.log
artifacts:
- path: build/cryfs-*.msi
name: CryFS

View File

@ -1,3 +1,23 @@
# appends a build number from the APPVEYOR_BUILD_NUMBER environment variable as fourth component to a version number,
# i.e. "0.10" becomes "0.10.0.[buildnumber]", "1" becomes "1.0.0.[buildnumber]".
function(append_build_number VERSION_NUMBER OUTPUT)
string(REPLACE "." ";" VERSION_COMPONENTS ${STRIPPED_VERSION_NUMBER})
list(LENGTH VERSION_COMPONENTS NUM_VERSION_COMPONENTS)
if (${NUM_VERSION_COMPONENTS} LESS_EQUAL 0)
message(FATAL_ERROR "Didn't find any version components")
endif()
if (${NUM_VERSION_COMPONENTS} LESS_EQUAL 1)
string(APPEND STRIPPED_VERSION_NUMBER ".0")
endif()
if (${NUM_VERSION_COMPONENTS} LESS_EQUAL 2)
string(APPEND STRIPPED_VERSION_NUMBER ".0")
endif()
if (NOT $ENV{APPVEYOR_BUILD_NUMBER} STREQUAL "")
string(APPEND STRIPPED_VERSION_NUMBER ".$ENV{APPVEYOR_BUILD_NUMBER}")
endif()
set(${OUTPUT} "${STRIPPED_VERSION_NUMBER}" PARENT_SCOPE)
endfunction()
# We only allow generating distribution packages if:
# - it is a release build (to ensure all generated debian packages are fine to be distributed)
string(TOUPPER "${CMAKE_BUILD_TYPE}" BUILDTYPE)
@ -11,27 +31,32 @@ if(BUILDTYPE MATCHES RELEASE OR BUILDTYPE MATCHES RELWITHDEBINFO)
# When installing the .deb package and these files have the wrong permissions, the package manager complains.
execute_process(COMMAND /bin/bash -c "chmod 0755 ${CMAKE_CURRENT_SOURCE_DIR}/debfiles/*")
set(CPACK_GENERATOR TGZ DEB RPM)
set(CPACK_PACKAGE_NAME "cryfs")
get_git_version(GITVERSION_VERSION_STRING)
set(CPACK_PACKAGE_VERSION "${GITVERSION_VERSION_STRING}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Encrypt your files and store them in the cloud.")
set(CPACK_PACKAGE_DESCRIPTION "CryFS encrypts your files, so you can safely store them anywhere. It works well together with cloud services like Dropbox, iCloud, OneDrive and others.")
set(CPACK_PACKAGE_CONTACT "Sebastian Messmer <messmer@cryfs.org>")
set(CPACK_PACKAGE_VENDOR "Sebastian Messmer")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE.txt")
get_git_version(GITVERSION_VERSION_STRING)
if(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
#set(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
#set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\cryfs.exe")
#set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} CryFS")
#set(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.cryfs.org")
#set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.cryfs.org")
#set(CPACK_NSIS_CONTACT "messmer@cryfs.org")
#set(CPACK_NSIS_MODIFY_PATH ON)
else(WIN32 AND NOT UNIX)
set(CPACK_GENERATOR WIX)
string(REGEX REPLACE "^([0-9\\.]+)([-+][0-9\\.a-zA-Z+-]+)?$" "\\1" STRIPPED_VERSION_NUMBER "${GITVERSION_VERSION_STRING}")
append_build_number(${STRIPPED_VERSION_NUMBER} WIX_VERSION_NUMBER)
message(STATUS "WIX package version is ${WIX_VERSION_NUMBER}")
set(CPACK_PACKAGE_VERSION "${WIX_VERSION_NUMBER}")
set(CPACK_WIX_UPGRADE_GUID "8b872ce1-557d-48e6-ac57-9f5e574feabf")
set(CPACK_WIX_PRODUCT_GUID "26116061-4f99-4c44-a178-2153fa396308")
#set(CPACK_WIX_PRODUCT_ICON "...")
set(CPACK_WIX_PROPERTY_ARPURLINFOABOUT "https://www.cryfs.org")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CryFS/${GITVERSION_VERSION_STRING}")
set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/wix/change_path_env.xml")
else()
set(CPACK_GENERATOR TGZ DEB RPM)
set(CPACK_PACKAGE_VERSION "${GITVERSION_VERSION_STRING}")
set(CPACK_STRIP_FILES OFF)
set(CPACK_SOURCE_STRIP_FILES OFF)
endif()

View File

@ -0,0 +1,7 @@
<CPackWiXPatch>
<CPackWiXFragment Id="CM_CP_bin.cryfs.exe">
<Environment Id="MyPath" Action="set" Part="first"
Name="PATH" Value="[INSTALL_ROOT]bin"
System="yes"/>
</CPackWiXFragment>
</CPackWiXPatch>

View File

@ -28,5 +28,5 @@ target_activate_cpp14(${PROJECT_NAME}_bin)
install(TARGETS ${PROJECT_NAME}_bin
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Release
CONFIGURATIONS Release RelWithDebInfo
)

View File

@ -19,17 +19,21 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
get_target_architecture(TARGET_ARCH)
message(STATUS "Linking to Dokan ${TARGET_ARCH}")
if ("${TARGET_ARCH}" STREQUAL "x86_64")
set(DOKAN_LIB_PATH "${DOKAN_PATH}\\lib")
set(DOKAN_LIB_PATH "${DOKAN_PATH}")
elseif("${TARGET_ARCH}" STREQUAL "i386")
set(DOKAN_LIB_PATH "${DOKAN_PATH}\\x86\\lib")
set(DOKAN_LIB_PATH "${DOKAN_PATH}\\x86")
else()
message(FATAL_ERROR "Unsupported architecture: ${TARGET_ARCH}")
endif()
target_include_directories(${PROJECT_NAME} PUBLIC "${DOKAN_PATH}\\include")
target_link_libraries(${PROJECT_NAME} PUBLIC "${DOKAN_LIB_PATH}\\dokan1.lib")
#target_link_libraries(${PROJECT_NAME} PUBLIC "${DOKAN_LIB_PATH}\\dokannp1.lib")
target_link_libraries(${PROJECT_NAME} PUBLIC "${DOKAN_LIB_PATH}\\dokanfuse1.lib")
target_link_libraries(${PROJECT_NAME} PUBLIC "${DOKAN_LIB_PATH}\\lib\\dokan1.lib")
#target_link_libraries(${PROJECT_NAME} PUBLIC "${DOKAN_LIB_PATH}\\lib\\dokannp1.lib")
target_link_libraries(${PROJECT_NAME} PUBLIC "${DOKAN_LIB_PATH}\\lib\\dokanfuse1.lib")
install(FILES ${DOKAN_LIB_PATH}\\dokan1.dll ${DOKAN_LIB_PATH}\\dokanfuse1.dll
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_FIND_FRAMEWORK LAST)