Commit b852bf83 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

adding CPackWixConfig

parent f68e8aa8
IF(ESSENTIALS)
MESSAGE("Essentials!")
SET(CPACK_COMPONENTS_USED "Server;Client;DataFiles")
SET(CPACK_WIX_UI "WixUI_InstallDir")
MATH(EXPR bits ${CMAKE_SIZEOF_VOID_P}*8)
SET(CPACK_PACKAGE_FILE_NAME "mysql-essentials-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH}-win${bits}")
ELSE()
SET(CPACK_COMPONENTS_USED
"Server;Client;DataFiles;Development;SharedLibraries;Embedded;Debuginfo;Documentation;IniFiles;Readme;Server_Scripts")
ENDIF()
# Some components like Embedded are optional
# We will build MSI without embedded if it was not selected for build
#(need to modify CPACK_COMPONENTS_ALL for that)
SET(CPACK_ALL)
FOREACH(comp1 ${CPACK_COMPONENTS_USED})
SET(found)
FOREACH(comp2 ${CPACK_COMPONENTS_ALL})
IF(comp1 STREQUAL comp2)
SET(found 1)
BREAK()
ENDIF()
ENDFOREACH()
IF(found)
SET(CPACK_ALL ${CPACK_ALL} ${comp1})
ENDIF()
ENDFOREACH()
SET(CPACK_COMPONENTS_ALL ${CPACK_ALL})
# Always install (hidden), includes Readme files
SET(CPACK_COMPONENT_GROUP_ALWAYSINSTALL_HIDDEN 1)
SET(CPACK_COMPONENT_README_GROUP "AlwaysInstall")
# Feature MySQL Server
SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DISPLAY_NAME "MySQL Server")
SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_EXPANDED "1")
SET(CPACK_COMPONENT_GROUP_MYSQLSERVER_DESCRIPTION "Install MySQL Server")
# Subfeature "Server" (hidden)
SET(CPACK_COMPONENT_SERVER_GROUP "MySQLServer")
SET(CPACK_COMPONENT_SERVER_HIDDEN 1)
# Subfeature "Client"
SET(CPACK_COMPONENT_CLIENT_GROUP "MySQLServer")
SET(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Client Programs")
SET(CPACK_COMPONENT_CLIENT_DESCRIPTION
"Various helpful (commandline) tools including the mysql command line client" )
#Subfeature "Data Files"
SET(CPACK_COMPONENT_DATAFILES_GROUP "MySQLServer")
SET(CPACK_COMPONENT_DATAFILES_DISPLAY_NAME "Server data files")
SET(CPACK_COMPONENT_DATAFILES_DESCRIPTION "Server data files" )
#Feature "Devel"
SET(CPACK_COMPONENT_GROUP_DEVEL_DISPLAY_NAME "Development Components")
SET(CPACK_COMPONENT_GROUP_DEVEL_DESCRIPTION "Installs C/C++ header files and libraries")
#Subfeature "Development"
SET(CPACK_COMPONENT_DEVELOPMENT_GROUP "Devel")
SET(CPACK_COMPONENT_DEVELOPMENT_HIDDEN 1)
#Subfeature "Shared libraries"
SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "Devel")
SET(CPACK_COMPONENT_SHAREDLIBRARIES_DISPLAY_NAME "Client C API library (shared)")
SET(CPACK_COMPONENT_SHAREDLIBRARIES_DESCRIPTION "Installs shared client library")
#Subfeature "Embedded"
SET(CPACK_COMPONENT_EMBEDDED_GROUP "Devel")
SET(CPACK_COMPONENT_EMBEDDED_DISPLAY_NAME "Embedded server library")
SET(CPACK_COMPONENT_EMBEDDED_DESCRIPTION "Installs embedded server library")
SET(CPACK_COMPONENT_EMBEDDED_WIX_LEVEL 2)
#Feature Debug Symbols
SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DISPLAY_NAME "Debug Symbols")
SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_DESCRIPTION "Installs Debug Symbols")
SET(CPACK_COMPONENT_GROUP_DEBUGSYMBOLS_WIX_LEVEL 2)
SET(CPACK_COMPONENT_DEBUGINFO_GROUP "DebugSymbols")
SET(CPACK_COMPONENT_DEBUGINFO_HIDDEN 1)
#Feature Documentation
SET(CPACK_COMPONENT_DOCUMENTATION_DISPLAY_NAME "Documentation")
SET(CPACK_COMPONENT_DOCUMENTATION_DESCRIPTION "Installs documentation")
SET(CPACK_COMPONENT_DOCUMENTATION_WIX_LEVEL 2)
#Feature tests
SET(CPACK_COMPONENT_TEST_DISPLAY_NAME "Tests")
SET(CPACK_COMPONENT_TEST_DESCRIPTION "Installs unittests (requires Perl to run)")
SET(CPACK_COMPONENT_TEST_WIX_LEVEL 2)
#Feature Misc (hidden, installs only if everything is installed)
SET(CPACK_COMPONENT_GROUP_MISC_HIDDEN 1)
SET(CPACK_COMPONENT_GROUP_MISC_WIX_LEVEL 100)
SET(CPACK_COMPONENT_INIFILES_GROUP "Misc")
SET(CPACK_COMPONENT_SERVER_SCRIPTS_GROUP "Misc")
INCLUDE(${CMAKE_BINARY_DIR}/CPackConfig)
FOREACH(comp ${COMPS})
SET(CMDS ${CMDS}
COMMAND set DESTDIR=testinstall/${comp}
COMMAND ${CMAKE_COMMAND}
-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}
-DCMAKE_INSTALL_COMPONENT=${comp}
-DCMAKE_INSTALL_PREFIX=
-P ${CMAKE_BINARY_DIR}/cmake_install.cmake
)
ENDFOREACH()
SET(INC 0)
MACRO(MAKE_WIX_IDENTIFIER str varname)
STRING(REPLACE "/" "." ret "${str}")
STRING(REPLACE "-" "_" ret "${ret}}")
STRING(LENGTH l "${ret}")
IF(l GREATER 65)
STRING(SUBSTRING "${ret}" 0 64 ret)
MATH(EXPR INC ${INC}+1)
SET(ret "${ret}${INC})
ENDIF()
SET(${varname} ${ret})
ENDMACRO()
MACRO(GENERATE_GUID VarName)
EXECUTE_PROCESS(COMMAND uuidgen -c OUTPUT_VARIABLE ${VarName} OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDMACRO()
FUNCTION(TRAVERSE_FILES dir topdir file file_comp dir_root)
FILE(GLOB all_files ${dir}/*)
IF(NOT all_files)
RETURN()
ENDIF()
FILE(RELATIVE_PATH dir_rel ${topdir} ${dir})
IF(dir_rel)
MAKE_DIRECTORY(${dir_root}/${dir_rel})
MAKE_WIX_IDENTIFIER("${dir_rel}" dir_id)
ELSE()
FILE(APPEND ${file} "<DirectoryRef Id='INSTALLDIR'>\n")
ENDIF()
FILE(APPEND ${file} "<DirectoryRef Id='D.${dir_id}'>\n")
SET(NONEXEFILES)
FOREACH(f ${all_files})
IF(NOT IS_DIRECTORY ${f})
GET_FILENAME_COMPONENT(ext "${f}" EXT)
FILE(TO_NATIVE_PATH ${f} f_native)
FILE(RELATIVE_PATH rel ${topdir} ${f})
MAKE_WIX_IDENTIFIER("${rel}" id)
IF(ext MATCHES ".dll" OR ext MATCHES ".exe")
FILE(APPEND ${file} " <Component Id='C.${id}' Guid='*'>\n")
FILE(APPEND ${file} " <File Id='file.${id}' KeyPath='yes' Source='${f_native}'/>\n")
FILE(APPEND ${file} " </Component>\n")
FILE(APPEND ${file_comp} " <ComponentRef Id='C.${id}'/>\n")
ELSE()
# Collect nonexe files into a single component to reduce number of components
SET(NONEXEFILES "${NONEXEFILES} <File Id='file.${id}' Source='${f_native}'/>\n")
ENDIF()
ENDIF()
ENDFOREACH()
IF(NONEXEFILES)
GENERATE_GUID(guid)
FILE(APPEND ${file} " <Component Id='C.${d_name}.${dir_id}.nonexefiles' Id='${guid}>\n${NONEXEFILES}</Component>"
ENDIF()
FILE(APPEND ${file} "</DirectoryRef>\n")
FOREACH(f ${all_files})
IF(IS_DIRECTORY ${f})
TRAVERSE_FILES(${f} ${topdir} ${file} ${file_comp} ${dir_root})
ENDIF()
ENDFOREACH()
ENDFUNCTION()
FUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix)
FILE(RELATIVE_PATH rel ${topdir} ${dir})
IF(rel)
MAKE_WIX_IDENTIFIER("${rel}" id)
GET_FILENAME_COMPONENT(name ${dir} NAME)
FILE(APPEND ${file} "${prefix}<Directory Id='D.${id}' Name='${name}'>\n")
ENDIF()
FILE(GLOB all_files ${dir}/*)
FOREACH(f ${all_files})
IF(IS_DIRECTORY ${f})
TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} "${prefix} ")
ENDIF()
ENDFOREACH()
IF(rel)
FILE(APPEND ${file} "</Directory>\n")
ENDIF()
ENDFUNCTION()
GET_FILENAME_COMPONENT(abs . ABSOLUTE)
FOREACH(d ${DIRS})
GET_FILENAME_COMPONENT(d ${d} ABSOLUTE)
GET_FILENAME_COMPONENT(d_name ${d} NAME)
FILE(WRITE
${abs}/${d_name}.wxs "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\n<Fragment>\n")
FILE(WRITE
${abs}/${d_name}_component_group.wxs "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\n<Fragment>\n<ComponentGroup Id='componentgroup.${d_name}'>\n")
TRAVERSE_FILES(${d} ${d} ${abs}/${d_name}.wxs ${abs}/${d_name}_component_group.wxs "${abs}/dirs")
FILE(APPEND ${abs}/${d_name}.wxs " </Fragment>\n</Wix>")
FILE(APPEND ${abs}/${d_name}_component_group.wxs "</ComponentGroup>\n</Fragment>\n</Wix>")
ENDFOREACH()
FILE(WRITE directories.wxs "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>\n<Fragment>\n<DirectoryRef Id='INSTALLDIR'>\n")
TRAVERSE_DIRECTORIES(${abs}/dirs ${abs}/dirs directories.wxs "")
FILE(APPEND directories.wxs "</DirectoryRef>\n</Fragment>\n</Wix>\n")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment