build.py: Add option to call cpack

Adds --with-cpack option.

- macOS: does nothing (we already create a better, signed disk image)
- Linux: creates qtcreator.deb in build directory
- Windows: Checks for NSIS and WIX installation,
  creates qtcreator.exe and qtcreator.msi as appropriate

Change-Id: Ie7816d04cb2e01e90795481e1519b0a6645f5cd3
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2022-10-05 13:07:07 +02:00
parent fcb79ee810
commit c72a9197a4
3 changed files with 36 additions and 6 deletions

View File

@@ -22,16 +22,22 @@ function(setup_dependencies_component)
set(_elfutils_arg "--elfutils \"${_elfutils_path}\"") set(_elfutils_arg "--elfutils \"${_elfutils_path}\"")
endif() endif()
install(CODE " install(CODE "
set(_ide_app_target \"\${CMAKE_INSTALL_PREFIX}/${IDE_APP_PATH}/${IDE_APP_TARGET}${CMAKE_EXECUTABLE_SUFFIX}\") # DESTDIR is set for e.g. the cpack DEB generator, but is empty in other situations
if(DEFINED ENV{DESTDIR})
set(DESTDIR_WITH_SEP \"\$ENV{DESTDIR}/\")
else()
set(DESTDIR_WITH_SEP \"\")
endif()
set(_default_app_target \"\${DESTDIR_WITH_SEP}\${CMAKE_INSTALL_PREFIX}/${IDE_APP_PATH}/${IDE_APP_TARGET}${CMAKE_EXECUTABLE_SUFFIX}\")
set(_ide_app_target \"\${_default_app_target}\")
if (NOT EXISTS \"\${_ide_app_target}\") if (NOT EXISTS \"\${_ide_app_target}\")
# The component CPack generators (WIX, NSIS64, IFW) install every component with their own CMAKE_INSTALL_PREFIX # The component CPack generators (WIX, NSIS64, IFW) install every component with their own CMAKE_INSTALL_PREFIX
# directory and since deployqt.py needs the path to IDE_APP_TARGET the line below is needeed # directory and since deployqt.py needs the path to IDE_APP_TARGET the line below is needeed
string(REPLACE \"Dependencies\" \"${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}\" _ide_app_target \"\${_ide_app_target}\") string(REPLACE \"Dependencies\" \"${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}\" _ide_app_target \"\${_ide_app_target}\")
endif() endif()
if (NOT EXISTS \"\${_ide_app_target}\") if (NOT EXISTS \"\${_ide_app_target}\")
# On Linux with the DEB generator the CMAKE_INSTALL_PREFIX is relative and the DESTDIR environment variable is needed # something went wrong, reset to default and hope for the best
# to point out to the IDE_APP_TARGET binary set(_ide_app_target \"\${_default_app_target}\")
set(_ide_app_target \"\$ENV{DESTDIR}/\${CMAKE_INSTALL_PREFIX}/${IDE_APP_PATH}/${IDE_APP_TARGET}${CMAKE_EXECUTABLE_SUFFIX}\")
endif() endif()
execute_process(COMMAND execute_process(COMMAND
\"${Python3_EXECUTABLE}\" \"${Python3_EXECUTABLE}\"

View File

@@ -26,6 +26,7 @@ set(CPACK_DEBIAN_COMPRESSION_TYPE lzma)
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS) get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) list(REMOVE_ITEM CPACK_COMPONENTS_ALL ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
list(REMOVE_ITEM CPACK_COMPONENTS_ALL libraries) # empty component, breaks WIX list(REMOVE_ITEM CPACK_COMPONENTS_ALL libraries) # empty component, breaks WIX
list(REMOVE_ITEM CPACK_COMPONENTS_ALL DebugInfo) # exclude the huge debug info
list(PREPEND CPACK_COMPONENTS_ALL ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}) list(PREPEND CPACK_COMPONENTS_ALL ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
set(CPACK_COMPONENT_Dependencies_HIDDEN TRUE) set(CPACK_COMPONENT_Dependencies_HIDDEN TRUE)

View File

@@ -7,8 +7,8 @@ from __future__ import print_function
import argparse import argparse
import collections import collections
import glob
import os import os
import shutil
import common import common
@@ -70,6 +70,8 @@ def get_arguments():
action='store_true', default=False) action='store_true', default=False)
parser.add_argument('--with-pch', help='Enable building with PCH', parser.add_argument('--with-pch', help='Enable building with PCH',
action='store_true', default=False) action='store_true', default=False)
parser.add_argument('--with-cpack', help='Create packages with cpack',
action='store_true', default=False)
parser.add_argument('--add-path', help='Prepends a CMAKE_PREFIX_PATH to the build', parser.add_argument('--add-path', help='Prepends a CMAKE_PREFIX_PATH to the build',
action='append', dest='prefix_paths', default=[]) action='append', dest='prefix_paths', default=[])
parser.add_argument('--add-module-path', help='Prepends a CMAKE_MODULE_PATH to the build', parser.add_argument('--add-module-path', help='Prepends a CMAKE_MODULE_PATH to the build',
@@ -92,6 +94,23 @@ def get_arguments():
if not args.qt_path and not args.no_qtcreator: if not args.qt_path and not args.no_qtcreator:
parser.error("argument --qt-path is required if --no-qtcreator is not given") parser.error("argument --qt-path is required if --no-qtcreator is not given")
if args.with_cpack:
if common.is_mac_platform():
print('warning: --with-cpack is not supported on macOS, turning off')
args.with_cpack = False
elif common.is_linux_platform():
args.cpack_generators = ['DEB']
elif common.is_windows_platform():
args.cpack_generators = []
if shutil.which('makensis'):
args.cpack_generators += ['NSIS64']
if shutil.which('candle') and shutil.which('torch'):
args.cpack_generators += ['WIX']
else:
print('warning: could not find NSIS or WIX, turning cpack off')
args.with_cpack = False
return args return args
def common_cmake_arguments(args): def common_cmake_arguments(args):
@@ -149,7 +168,6 @@ def build_qtcreator(args, paths):
'-DBUILD_DEVELOPER_DOCS=' + cmake_option(not args.no_docs), '-DBUILD_DEVELOPER_DOCS=' + cmake_option(not args.no_docs),
'-DBUILD_EXECUTABLE_SDKTOOL=OFF', '-DBUILD_EXECUTABLE_SDKTOOL=OFF',
'-DQTC_FORCE_XCB=ON', '-DQTC_FORCE_XCB=ON',
'-DCMAKE_INSTALL_PREFIX=' + common.to_posix_path(paths.install),
'-DWITH_TESTS=' + cmake_option(args.with_tests)] '-DWITH_TESTS=' + cmake_option(args.with_tests)]
cmake_args += common_cmake_arguments(args) cmake_args += common_cmake_arguments(args)
@@ -168,6 +186,9 @@ def build_qtcreator(args, paths):
cmake_args += ['-DWITH_SANITIZE=ON', cmake_args += ['-DWITH_SANITIZE=ON',
'-DSANITIZE_FLAGS=' + ",".join(args.sanitize_flags)] '-DSANITIZE_FLAGS=' + ",".join(args.sanitize_flags)]
if args.with_cpack:
cmake_args += ['-DCPACK_PACKAGE_FILE_NAME=qtcreator' + args.zip_infix]
cmake_args += args.config_args cmake_args += args.config_args
common.check_print_call(cmake_args + [paths.src], paths.build) common.check_print_call(cmake_args + [paths.src], paths.build)
@@ -288,6 +309,8 @@ def package_qtcreator(args, paths):
paths.src, paths.src,
paths.install], paths.install],
paths.result) paths.result)
if args.with_cpack and args.cpack_generators:
common.check_print_call(['cpack', '-G', ';'.join(args.cpack_generators)], paths.build)
def get_paths(args): def get_paths(args):