1+ project ( service_installer )
2+
3+ if (WIN32 )
4+
5+ add_custom_target (deploy)
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+ set (wixsrcpath "${CMAKE_CURRENT_SOURCE_DIR} " )
13+ set (wixoutputpath "installer" )
14+ message (STATUS "wixsrcpath: ${wixsrcpath} " )
15+
16+ #find libcrypto.dll file inside openssl installed folder
17+ if ("$ENV{OPENSSL_ROOT_DIR} " OR "${OPENSSL_ROOT_DIR} " STREQUAL "" )
18+ message (FATAL_ERROR "CANNOT FIND OPENSSL LIBRARY" )
19+ else ()
20+ set (openssl_path "${OPENSSL_ROOT_DIR} " )
21+ message (STATUS "OPENSSL PATH: ${openssl_path} " )
22+ file (GLOB_RECURSE globalcrypto FOLLOW_SYMLINKS ${OPENSSL_ROOT_DIR} /bin/libcrypto*.dll)
23+ list (GET globalcrypto 0 cryptolib)
24+ message (STATUS "FOUND LIBCRYPTO: ${cryptolib} " )
25+ endif ()
26+
27+ #set copy files to alias
28+ set ( PREBUILD_FILES
29+ "${wixsrcpath} /wix_app_entry.wxs"
30+ "${wixsrcpath} /service_manager.bat"
31+ "${wixsrcpath} /delete_service.bat"
32+ "${wixsrcpath} /license.rtf"
33+ "${wixsrcpath} /keychain_banner.jpg"
34+ "${wixsrcpath} /keychain_logo_maximal.ico"
35+ "${wixsrcpath} /keychain_logo_minimal.ico"
36+ "${wixsrcpath} /keychain_dialog_banner.jpg"
37+ ${cryptolib}
38+ )
39+
40+ message (STATUS "PREBUILD FILES: ${PREBUILD_FILES} " )
41+
42+ #copy files in build folder
43+ foreach ( file_to_copy ${PREBUILD_FILES} )
44+ add_custom_command (TARGET deploy PRE_BUILD COMMAND ${CMAKE_COMMAND}
45+ ARGS -E copy_if_different ${file_to_copy} "${wixoutputpath} " )
46+ endforeach ( file_to_copy )
47+
48+ #TODO
49+ #if keychain_common target will correctly build with clang-cl compiler
50+ #after that all chain of target builds will work properly
51+ #and next commands can be placed here target binary copy files
52+ #add_dependencies(deploy keychain_service_win keychain_pass_entry_app)
53+ #add_custom_command(TARGET keychain_pass_entry_app POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/debug/keychain_pass_entry_app.exe ../service_installer/installer/keychain_pass_entry_app.exe)
54+ #add_custom_command(TARGET keychain_service_win POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/debug/keychain_service_win.exe ${CMAKE_CURRENT_BINARY_DIR}/service_installer/installer/keychain_service_win.exe)
55+
56+ set (installerpath "${CMAKE_CURRENT_BINARY_DIR} /installer" )
57+
58+ message (STATUS "Deploy Path: ${CMAKE_CURRENT_BINARY_DIR} " )
59+ message (STATUS "Deploy installer Path: " )
60+ message (STATUS "WIX Path: ${WIX_PATH} " )
61+
62+ #-bf - flag causes all of the files to be bound int the resulting .wixout/.* file.
63+ #-out - flag tells the linker where to output the .wixout/.* file
64+ #-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
65+
66+ add_custom_command (TARGET deploy
67+ POST_BUILD
68+ COMMAND ${WIX_PATH} /candle.exe ${installerpath} /wix_app_entry.wxs -bf -xo -out ${installerpath} /wix_app_entry.wixobj
69+ COMMAND ${WIX_PATH} /light.exe -ext WixUIExtension ${installerpath} /wix_app_entry.wixobj -out ${installerpath} /${PROJECT_NAME} .msi
70+ VERBATIM )
71+
72+ endif ()
73+ endif ()
0 commit comments