Skip to content

Commit 400ddcf

Browse files
authored
Add package target to create installers for different platforms
WiX/DialogOrder.wxs approved by CQ# 7693 Signed-off-by: Thijs Sassen <[email protected]>
1 parent 57cf949 commit 400ddcf

9 files changed

+266
-0
lines changed

.azure/templates/build-test.yml

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ steps:
100100
-DWERROR=on \
101101
${GENERATOR:+-G} "${GENERATOR}" -A "${PLATFORM}" -T "${TOOLSET}" ..
102102
${SCAN_BUILD} cmake --build . --config ${BUILD_TYPE} --target install -- ${BUILD_TOOL_OPTIONS}
103+
${SCAN_BUILD} cmake --build . --config ${BUILD_TYPE} --target package -- ${BUILD_TOOL_OPTIONS}
103104
name: script
104105
- bash: |
105106
set -e -x

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,5 @@ if(BUILD_IDLC AND BUILD_EXAMPLES)
298298
endif()
299299

300300
add_subdirectory(docs)
301+
302+
include(CmakeCPack.cmake)

CmakeCPack.cmake

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#
2+
# Copyright(c) 2020 ADLINK Technology Limited and others
3+
#
4+
# This program and the accompanying materials are made available under the
5+
# terms of the Eclipse Public License v. 2.0 which is available at
6+
# http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
7+
# v. 1.0 which is available at
8+
# http://www.eclipse.org/org/documents/edl-v10.php.
9+
#
10+
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11+
#
12+
if(CMAKECPACK_INCLUDED)
13+
return()
14+
endif()
15+
set(CMAKECPACK_INCLUDED true)
16+
17+
include(GNUInstallDirs)
18+
set(PROJECT_NAME_FULL "Eclipse Cyclone DDS")
19+
# Set some convenience variants of the project-name
20+
string(REPLACE " " "-" PROJECT_NAME_DASHED "${PROJECT_NAME_FULL}")
21+
22+
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
23+
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
24+
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
25+
set(CPACK_PACKAGE_VERSION_TWEAK ${PROJECT_VERSION_TWEAK})
26+
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
27+
28+
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
29+
set(CPACK_PACKAGE_VENDOR "Eclipse Cyclone DDS project")
30+
set(CPACK_PACKAGE_CONTACT "https://github.com/eclipse-cyclonedds/cyclonedds")
31+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Eclipse Cyclone DDS")
32+
33+
# WiX requires a .txt file extension for CPACK_RESOURCE_FILE_LICENSE
34+
file(COPY "${PROJECT_SOURCE_DIR}/LICENSE" DESTINATION "${CMAKE_BINARY_DIR}")
35+
file(RENAME "${CMAKE_BINARY_DIR}/LICENSE" "${CMAKE_BINARY_DIR}/license.txt")
36+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/license.txt")
37+
38+
# Packages could be generated on alien systems. e.g. Debian packages could be
39+
# created on Red Hat Enterprise Linux, but since packages also need to be
40+
# verified on the target platform, please refrain from doing so. Another
41+
# reason for building installer packages on the target platform is to ensure
42+
# the binaries are linked to the libc version shipped with that platform. To
43+
# support "generic" Linux distributions, eventually compressed tarballs will
44+
# be shipped.
45+
#
46+
# NOTE: Settings for different platforms are in separate control branches.
47+
# Although that does not make sense from a technical point-of-view, it
48+
# does help to clearify which settings are required for a platform.
49+
50+
set(CPACK_COMPONENTS_ALL dev lib)
51+
set(CPACK_COMPONENT_LIB_DISPLAY_NAME "${PROJECT_NAME_FULL} library")
52+
set(CPACK_COMPONENT_LIB_DESCRIPTION "Library used to run programs with ${PROJECT_NAME_FULL}")
53+
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "${PROJECT_NAME_FULL} development")
54+
set(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for use with ${PROJECT_NAME_FULL}")
55+
56+
if(WIN32 AND NOT UNIX)
57+
58+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
59+
set(__arch "win64")
60+
else()
61+
set(__arch "win32")
62+
endif()
63+
mark_as_advanced(__arch)
64+
65+
set(CPACK_GENERATOR "WIX;ZIP;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
66+
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}-${__arch}")
67+
set(WIX_DIR "${PROJECT_SOURCE_DIR}/WiX")
68+
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME_FULL}")
69+
set(CPACK_WIX_UI_REF "CustomUI_InstallDir")
70+
set(CPACK_WIX_PATCH_FILE "${WIX_DIR}/env.xml")
71+
set(CPACK_WIX_EXTRA_SOURCES "${WIX_DIR}/PathDlg.wxs"
72+
"${WIX_DIR}/DialogOrder.wxs")
73+
set(CPACK_WIX_CMAKE_PACKAGE_REGISTRY "${PROJECT_NAME}")
74+
set(CPACK_WIX_PRODUCT_ICON "${WIX_DIR}/icon.ico")
75+
set(CPACK_WIX_UI_BANNER "${WIX_DIR}/banner.png")
76+
set(CPACK_WIX_UI_DIALOG "${WIX_DIR}/dialog.png")
77+
# when updating the version number also generate a new GUID
78+
set(CPACK_WIX_UPGRADE_GUID "f619c294-0696-4f04-98ed-4cfa6ebba6a5")
79+
80+
include(InstallRequiredSystemLibraries)
81+
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
82+
83+
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
84+
set(CPACK_COMPONENTS_GROUPING "IGNORE")
85+
86+
if(EXISTS "/etc/redhat-release")
87+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
88+
set(__arch "x86_64")
89+
else()
90+
set(__arch "i686")
91+
endif()
92+
93+
set(CPACK_GENERATOR "RPM;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
94+
set(CPACK_RPM_PACKAGE_LICENSE "Eclipse Public License v2.0 http://www.eclipse.org/legal/epl-2.0")
95+
set(CPACK_RPM_COMPONENT_INSTALL ON)
96+
set(CPACK_RPM_PACKAGE_RELEASE 1)
97+
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
98+
set(CPACK_RPM_LIB_PACKAGE_NAME "${PROJECT_NAME_DASHED}")
99+
set(CPACK_RPM_LIB_FILE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}%{?dist}-${__arch}.rpm")
100+
set(CPACK_RPM_DEV_PACKAGE_NAME "${CPACK_RPM_LIB_PACKAGE_NAME}-devel")
101+
set(CPACK_RPM_DEV_FILE_NAME "${CPACK_RPM_DEV_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}%{?dist}-${__arch}.rpm")
102+
set(CPACK_RPM_DEV_PACKAGE_REQUIRES "${CPACK_RPM_LIB_PACKAGE_NAME} = ${CPACK_PACKAGE_VERSION}")
103+
elseif(EXISTS "/etc/debian_version")
104+
set(CPACK_DEB_COMPONENT_INSTALL ON)
105+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
106+
set(__arch "amd64")
107+
else()
108+
set(__arch "i386")
109+
endif()
110+
111+
set(CPACK_GENERATOR "DEB;TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
112+
113+
string(TOLOWER "${PROJECT_NAME_DASHED}" CPACK_DEBIAN_LIB_PACKAGE_NAME)
114+
set(CPACK_DEBIAN_LIB_FILE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
115+
set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS "${CPACK_DEBIAN_LIB_PACKAGE_NAME} (= ${CPACK_PACKAGE_VERSION}), libc6 (>= 2.23)")
116+
set(CPACK_DEBIAN_DEV_PACKAGE_NAME "${CPACK_DEBIAN_LIB_PACKAGE_NAME}-dev")
117+
set(CPACK_DEBIAN_DEV_FILE_NAME "${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${__arch}.deb")
118+
else()
119+
# Generic tgz package
120+
set(CPACK_GENERATOR "TGZ;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
121+
endif()
122+
else()
123+
# Fallback to zip package
124+
set(CPACK_GENERATOR "ZIP;${CPACK_GENERATOR}" CACHE STRING "List of package generators")
125+
endif()
126+
127+
# This must always be last!
128+
include(CPack)

WiX/DialogOrder.wxs

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
<copyright file="WixUI_InstallDir.wxs" company="Outercurve Foundation">
4+
Copyright (c) 2004, Outercurve Foundation.
5+
This software is released under Microsoft Reciprocal License (MS-RL).
6+
The license and further copyright text can be found in the file
7+
LICENSE.TXT at the root directory of the distribution.
8+
</copyright>
9+
-->
10+
<!--
11+
First-time install dialog sequence:
12+
- WixUI_WelcomeDlg
13+
- WixUI_LicenseAgreementDlg
14+
- WixUI_InstallDirDlg
15+
- WixUI_VerifyReadyDlg
16+
- WixUI_DiskCostDlg
17+
18+
Maintenance dialog sequence:
19+
- WixUI_MaintenanceWelcomeDlg
20+
- WixUI_MaintenanceTypeDlg
21+
- WixUI_InstallDirDlg
22+
- WixUI_VerifyReadyDlg
23+
24+
Patch dialog sequence:
25+
- WixUI_WelcomeDlg
26+
- WixUI_VerifyReadyDlg
27+
28+
-->
29+
30+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
31+
<Fragment>
32+
<UI Id="CustomUI_InstallDir">
33+
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
34+
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
35+
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
36+
37+
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
38+
<Property Id="WixUI_Mode" Value="InstallDir" />
39+
40+
<DialogRef Id="BrowseDlg" />
41+
<DialogRef Id="DiskCostDlg" />
42+
<DialogRef Id="ErrorDlg" />
43+
<DialogRef Id="FatalError" />
44+
<DialogRef Id="FilesInUse" />
45+
<DialogRef Id="MsiRMFilesInUse" />
46+
<DialogRef Id="PrepareDlg" />
47+
<DialogRef Id="ProgressDlg" />
48+
<DialogRef Id="ResumeDlg" />
49+
<DialogRef Id="UserExit" />
50+
51+
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
52+
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
53+
54+
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
55+
56+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
57+
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
58+
59+
<Publish Dialog="LicenseAgreementDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
60+
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetPathDlg">LicenseAccepted = "1"</Publish>
61+
62+
<Publish Dialog="SetPathDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">1</Publish>
63+
<Publish Dialog="SetPathDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
64+
65+
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
66+
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
67+
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
68+
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
69+
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
70+
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
71+
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
72+
73+
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg" Order="1">NOT Installed</Publish>
74+
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed AND NOT PATCH</Publish>
75+
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">Installed AND PATCH</Publish>
76+
77+
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>
78+
79+
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
80+
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
81+
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
82+
83+
<Property Id="ARPNOMODIFY" Value="1" />
84+
</UI>
85+
86+
<UIRef Id="WixUI_Common" />
87+
</Fragment>
88+
</Wix>

WiX/PathDlg.wxs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3+
<Fragment>
4+
<UI>
5+
<Property Id="ADDTOPATH" Value="None"/>
6+
<Dialog Id="SetPathDlg" Width="370" Height="270" Title="Install Options">
7+
8+
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)"/>
9+
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)"/>
10+
11+
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
12+
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
13+
</Control>
14+
15+
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Choose options for installing [ProductName] [ProductVersion]"/>
16+
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Install Options"/>
17+
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)"/>
18+
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0"/>
19+
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0"/>
20+
21+
<Control Id="Hint" Type="Text" X="26" Y="60" Width="250" Height="16" Transparent="yes" Text="By default [ProductName] does not add its directory to the system PATH."/>
22+
23+
<Control Id="ADD_CMAKE_TO_PATHOption" Type="RadioButtonGroup" X="26" Y="100" Width="305" Height="65" Property="ADDTOPATH">
24+
<RadioButtonGroup Property="ADDTOPATH">
25+
<RadioButton Value="None" X="0" Y="0" Width="295" Height="16" Text="Do not add [ProductName] to the system PATH"/>
26+
<RadioButton Value="System" X="0" Y="20" Width="295" Height="16" Text="Add [ProductName] to the system PATH for all users"/>
27+
<RadioButton Value="User" X="0" Y="40" Width="295" Height="16" Text="Add [ProductName] to the system PATH for the current user"/>
28+
</RadioButtonGroup>
29+
</Control>
30+
</Dialog>
31+
</UI>
32+
</Fragment>
33+
</Wix>

WiX/banner.png

2.47 KB
Loading

WiX/dialog.png

18.3 KB
Loading

WiX/env.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<CPackWiXPatch>
2+
<CPackWiXFragment Id="#PRODUCT">
3+
<Feature Description="This feature adds [PRODUCTNAME] to the windows PATH so libraries can be found." Id="Add_PATH" Title="Add libraries to the PATH variable">
4+
<Component Id="SetEnvSystem" Directory="TARGETDIR" Guid="">
5+
<Condition>ADDTOPATH = "System"</Condition>
6+
<Environment Action="set" Id="Path_System" Name="PATH" Part="last" Permanent="no" System="yes" Value="[INSTALL_ROOT]bin"/>
7+
</Component>
8+
<Component Id="SetEnvUser" Directory="TARGETDIR" Guid="">
9+
<Condition>ADDTOPATH = "User"</Condition>
10+
<Environment Action="set" Id="Path_User" Name="PATH" Part="last" Permanent="no" System="no" Value="[INSTALL_ROOT]bin"/>
11+
</Component>
12+
</Feature>
13+
</CPackWiXFragment>
14+
</CPackWiXPatch>

WiX/icon.ico

44.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)