1
+ project ( wsservice_installer )
2
+
3
+ if (WIN32 )
4
+
5
+ add_custom_target (wssdeploy)
6
+ find_path (WIX_PATH candle.exe)
7
+
8
+ if (NOT WIX_PATH)
9
+ message (FATAL_ERROR "Unable to find WiX in the PATH. The WiX installer will be disabled." )
10
+ else (WIX_PATH)
11
+
12
+ add_dependencies (wssdeploy keychain keychain_win_gui)
13
+
14
+ set (outputdir "${CMAKE_CURRENT_BINARY_DIR} /wsservice" )
15
+ file (MAKE_DIRECTORY "${outputdir} " )
16
+ set (wixsrcpath "${CMAKE_CURRENT_SOURCE_DIR} " )
17
+ set (wixoutputpath "wsservice" )
18
+ message (STATUS "wixsrcpath: ${wixsrcpath} " )
19
+
20
+ #find libcrypto.dll file inside openssl installed folder
21
+ if ("$ENV{OPENSSL_ROOT_DIR} " OR "${OPENSSL_ROOT_DIR} " STREQUAL "" )
22
+ message (FATAL_ERROR "CANNOT FIND OPENSSL LIBRARY" )
23
+ else ()
24
+ set (openssl_path "${OPENSSL_ROOT_DIR} " )
25
+ message (STATUS "OPENSSL PATH: ${openssl_path} " )
26
+ file (GLOB_RECURSE globalcrypto FOLLOW_SYMLINKS ${OPENSSL_ROOT_DIR} /bin/libcrypto-1_1-x64.dll)
27
+ list (GET globalcrypto 0 cryptolib)
28
+ if (globalcrypto)
29
+ message (STATUS "FOUND LIBCRYPTO: ${cryptolib} " )
30
+ else ()
31
+ message (FATAL_ERROR "CANNOT FIND OPENSSL DYNAMIC LIBRARY" )
32
+ endif ()
33
+ endif ()
34
+
35
+ #find Qt 5 dll files to link and build finally with msi
36
+ set (CMAKE_AUTOMOC ON )
37
+ set (CMAKE_INCLUDE_CURRENT_DIR ON )
38
+ find_package (Qt5 COMPONENTS Core Gui Widgets Qml Xml Svg REQUIRED)
39
+ get_target_property (Qt5_CoreLocation Qt5::Core LOCATION )
40
+
41
+ message (STATUS "QT5: ${Qt5_CoreLocation} " )
42
+
43
+ if ("$ENV{Qt5_CoreLocation} " OR "${Qt5_CoreLocation} " STREQUAL "" )
44
+ message (FATAL_ERROR "CANNOT FIND QT5 LIBRARY" )
45
+ else ()
46
+ add_custom_command (TARGET wssdeploy POST_BUILD
47
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Core> ${CMAKE_CURRENT_BINARY_DIR} /wsservice
48
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Gui> ${CMAKE_CURRENT_BINARY_DIR} /wsservice
49
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Widgets> ${CMAKE_CURRENT_BINARY_DIR} /wsservice
50
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Qml> ${CMAKE_CURRENT_BINARY_DIR} /wsservice
51
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Xml> ${CMAKE_CURRENT_BINARY_DIR} /wsservice
52
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Qt5::Svg> ${CMAKE_CURRENT_BINARY_DIR} /wsservice
53
+ )
54
+ file (GLOB_RECURSE qtlinkplatforms FOLLOW_SYMLINKS ${Qt5_CoreLocation} /../../plugins/platforms/*.dll)
55
+ file (GLOB_RECURSE qtlinkimageformats FOLLOW_SYMLINKS ${Qt5_CoreLocation} /../../plugins/imageformats/*.dll)
56
+ file (GLOB_RECURSE qtlinkstyles FOLLOW_SYMLINKS ${Qt5_CoreLocation} /../../plugins/styles/*.dll)
57
+ message (STATUS "QT PLATFORM FILES: ${qtlinkplatforms} " )
58
+ message (STATUS "QT IMAGE FORMATS FILES: ${qtlinkimageformats} " )
59
+ message (STATUS "QT STYLES FILES: ${qtlinkstyles} " )
60
+ endif ()
61
+
62
+ #set copy files to alias
63
+ set ( PREBUILD_FILES
64
+ "${wixsrcpath} /check_service.bat"
65
+ "${wixsrcpath} /websocketwrapper.exe"
66
+ "${wixsrcpath} /servicewrapper.exe"
67
+ "${wixsrcpath} /servicewrapper.xml"
68
+ "${wixsrcpath} /wix_wssapp_entry.wxs"
69
+ "${wixsrcpath} /CustomWixUI_Mondo.wxs"
70
+ "${wixsrcpath} /CustomInstallDirDlg.wxs"
71
+ "${wixsrcpath} /CustomVerifyReadyDlg.wxs"
72
+ "${wixsrcpath} /CustomLicenseAgreementDlg.wxs"
73
+ "${wixsrcpath} /en-us.wxl"
74
+ "${wixsrcpath} /wsservice_manager.bat"
75
+ "${wixsrcpath} /delete_wsservice.bat"
76
+ "${wixsrcpath} /wsservicerunner.bat"
77
+ "${wixsrcpath} /license.rtf"
78
+ "${wixsrcpath} /keychain_banner.jpg"
79
+ "${wixsrcpath} /keychain_logo_maximal.ico"
80
+ "${wixsrcpath} /keychain_logo_minimal.ico"
81
+ "${wixsrcpath} /keychain_dialog_banner.jpg"
82
+ ${cryptolib}
83
+ )
84
+
85
+ message (STATUS "PREBUILD FILES: ${PREBUILD_FILES} " )
86
+
87
+ #set alias to demo files
88
+ set ( DEMO_FILES
89
+ ${CMAKE_CURRENT_SOURCE_DIR} /demo/index.html
90
+ ${CMAKE_CURRENT_SOURCE_DIR} /demo/logo.png
91
+ ${CMAKE_CURRENT_SOURCE_DIR} /demo/spectre.min.css
92
+ ${CMAKE_CURRENT_SOURCE_DIR} /demo/keychain.js)
93
+
94
+ #copy demo files to installer folder
95
+ file (COPY ${DEMO_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} /wsservice/demo/)
96
+ #copy qt platform files to installer folder
97
+ file (COPY ${qtlinkplatforms} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} /wsservice/platforms/)
98
+ #copy qt image formats files to installer folder
99
+ file (COPY ${qtlinkimageformats} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} /wsservice/imageformats/)
100
+ #copy qt styles files to installer folder
101
+ file (COPY ${qtlinkstyles} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} /wsservice/styles/)
102
+
103
+ #copy files in build folder
104
+ foreach ( file_to_copy ${PREBUILD_FILES} )
105
+ add_custom_command (TARGET wssdeploy PRE_BUILD COMMAND ${CMAKE_COMMAND}
106
+ ARGS -E copy_if_different ${file_to_copy} "${wixoutputpath} " )
107
+ endforeach ( file_to_copy )
108
+
109
+ set (installerpath "${CMAKE_CURRENT_BINARY_DIR} /wsservice" )
110
+
111
+ message (STATUS "WSSDeploy Path: ${CMAKE_CURRENT_BINARY_DIR} " )
112
+ message (STATUS "WSSDeploy installer Path: ${wixoutputpath} " )
113
+ message (STATUS "WIX Path: ${WIX_PATH} " )
114
+
115
+ # check if you already have a correctly defined PROCESSOR_ARCHITECTURE enviroment variable_requires
116
+ #like:
117
+ #Intel - 32-bit x86
118
+ #Intel64 - Itanium family
119
+ #AMD64 - 64-bit x86, deprecated
120
+ #x64 - 64-bit x86
121
+
122
+ #get specific platform version to detect vcredist type
123
+ set (TARGET_PLATFORM $ENV{PROCESSOR_ARCHITECTURE} )
124
+ message (STATUS "TARGET PLATFORM: ${TARGET_PLATFORM} " )
125
+
126
+ #set installer version
127
+ list ( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /git_version_gen" )
128
+ include ( GetGitRevisionDescription )
129
+ git_describe(KEYCHAIN_COMMON_GIT_REVISION_DESCRIPTION --tags)
130
+ SET (VERSION_REGEXP "^[0-9]+\\ .[0-9]+\\ -[0-9]+" )
131
+ string (REGEX MATCH ${VERSION_REGEXP} VERSION_STRING_GIT ${KEYCHAIN_COMMON_GIT_REVISION_DESCRIPTION} )
132
+ string (REGEX REPLACE "\\ -" "." VERSION_STRING ${VERSION_STRING_GIT} )
133
+ set (installerversion ${VERSION_STRING} )
134
+
135
+ #-bf - flag causes all of the files to be bound int the resulting .wixout/.* file.
136
+ #-out - flag tells the linker where to output the .wixout/.* file
137
+ #-xo - this flag tells the linker to output an XML representation of the MSI, instead of the actual MSI, required to use the -bf switch
138
+ add_custom_command (TARGET wssdeploy
139
+ POST_BUILD
140
+ COMMAND ${WIX_PATH} /candle.exe
141
+ ${installerpath} /wix_wssapp_entry.wxs
142
+ ${installerpath} /CustomLicenseAgreementDlg.wxs
143
+ ${installerpath} /CustomInstallDirDlg.wxs
144
+ ${installerpath} /CustomWixUI_Mondo.wxs
145
+ ${installerpath} /CustomVerifyReadyDlg.wxs
146
+ -dProcessorArchitecture=${TARGET_PLATFORM}
147
+ -dvcrpath=${VCR_PATH}
148
+ -dproductversion=${installerversion}
149
+ -bf -xo -out ${installerpath} /
150
+ COMMAND ${WIX_PATH} /light.exe
151
+ -sice:ICE20
152
+ -ext WixUtilExtension
153
+ -ext WixUIExtension
154
+ -ext WixNetfxExtension
155
+ ${installerpath} /wix_wssapp_entry.wixobj
156
+ ${installerpath} /CustomLicenseAgreementDlg.wixobj
157
+ ${installerpath} /CustomInstallDirDlg.wixobj
158
+ ${installerpath} /CustomWixUI_Mondo.wixobj
159
+ ${installerpath} /CustomVerifyReadyDlg.wixobj
160
+ -cultures:en-us -loc ${installerpath} /en-us.wxl
161
+ -out ${installerpath} /${PROJECT_NAME} .msi
162
+ VERBATIM )
163
+ endif ()
164
+ endif ()
0 commit comments