forked from qt-creator/qt-creator
CMake: Add cpack packaging support
Tested on all desktop platforms like this: * Windows with cpack -G NSIS64|WIX|IFW * Ubuntu Linux with cpack -G DEB * macOS with cpack -G DragNDrop Fixes: QTCREATORBUG-28199 Change-Id: I5cd66aa387cc9677303ac3aece28eccb710d074f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -164,37 +164,14 @@ endif()
|
||||
|
||||
add_subdirectory(doc)
|
||||
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
if (NOT Python3_Interpreter_FOUND)
|
||||
message("No python interpreter found, skipping \"Dependencies\" install component.")
|
||||
else()
|
||||
get_target_property(_qmake_binary Qt5::qmake IMPORTED_LOCATION)
|
||||
set(_llvm_arg)
|
||||
if (LLVM_INSTALL_PREFIX)
|
||||
set(_llvm_arg "--llvm \"${LLVM_INSTALL_PREFIX}\"")
|
||||
endif()
|
||||
set(_elfutils_arg)
|
||||
if (ELFUTILS_INCLUDE_DIR)
|
||||
get_filename_component(_elfutils_path ${ELFUTILS_INCLUDE_DIR} DIRECTORY)
|
||||
set(_elfutils_arg "--elfutils \"${_elfutils_path}\"")
|
||||
endif()
|
||||
install(CODE "
|
||||
execute_process(COMMAND
|
||||
\"${Python3_EXECUTABLE}\"
|
||||
\"${CMAKE_CURRENT_LIST_DIR}/scripts/deployqt.py\"
|
||||
${_llvm_arg}
|
||||
${_elfutils_arg}
|
||||
\"\${CMAKE_INSTALL_PREFIX}/${IDE_APP_PATH}/${IDE_APP_TARGET}\"
|
||||
\"${_qmake_binary}\"
|
||||
COMMAND_ECHO STDOUT
|
||||
)
|
||||
"
|
||||
COMPONENT Dependencies
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
endif()
|
||||
setup_dependencies_component()
|
||||
|
||||
feature_summary(INCLUDE_QUIET_PACKAGES WHAT
|
||||
PACKAGES_FOUND PACKAGES_NOT_FOUND
|
||||
ENABLED_FEATURES DISABLED_FEATURES
|
||||
)
|
||||
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
# Only for non super repo builds
|
||||
add_subdirectory(packaging)
|
||||
endif()
|
||||
|
@@ -5,3 +5,46 @@ function (env_with_default envName varToSet default)
|
||||
set(${varToSet} ${default} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(setup_dependencies_component)
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
if (NOT Python3_Interpreter_FOUND)
|
||||
message("No python interpreter found, skipping \"Dependencies\" install component.")
|
||||
else()
|
||||
get_target_property(_qmake_binary Qt5::qmake IMPORTED_LOCATION)
|
||||
set(_llvm_arg)
|
||||
if (LLVM_INSTALL_PREFIX)
|
||||
set(_llvm_arg "--llvm \"${LLVM_INSTALL_PREFIX}\"")
|
||||
endif()
|
||||
set(_elfutils_arg)
|
||||
if (ELFUTILS_INCLUDE_DIR)
|
||||
get_filename_component(_elfutils_path ${ELFUTILS_INCLUDE_DIR} DIRECTORY)
|
||||
set(_elfutils_arg "--elfutils \"${_elfutils_path}\"")
|
||||
endif()
|
||||
install(CODE "
|
||||
set(_ide_app_target \"\${CMAKE_INSTALL_PREFIX}/${IDE_APP_PATH}/${IDE_APP_TARGET}${CMAKE_EXECUTABLE_SUFFIX}\")
|
||||
if (NOT EXISTS \"\${_ide_app_target}\")
|
||||
# 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
|
||||
string(REPLACE \"Dependencies\" \"${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}\" _ide_app_target \"\${_ide_app_target}\")
|
||||
endif()
|
||||
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
|
||||
# to point out to the IDE_APP_TARGET binary
|
||||
set(_ide_app_target \"\$ENV{DESTDIR}/\${CMAKE_INSTALL_PREFIX}/${IDE_APP_PATH}/${IDE_APP_TARGET}${CMAKE_EXECUTABLE_SUFFIX}\")
|
||||
endif()
|
||||
execute_process(COMMAND
|
||||
\"${Python3_EXECUTABLE}\"
|
||||
\"${CMAKE_CURRENT_LIST_DIR}/scripts/deployqt.py\"
|
||||
${_llvm_arg}
|
||||
${_elfutils_arg}
|
||||
\"\${_ide_app_target}\"
|
||||
\"${_qmake_binary}\"
|
||||
COMMAND_ECHO STDOUT
|
||||
)
|
||||
"
|
||||
COMPONENT Dependencies
|
||||
EXCLUDE_FROM_ALL
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
70
packaging/CMakeLists.txt
Normal file
70
packaging/CMakeLists.txt
Normal file
@@ -0,0 +1,70 @@
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/QtCreatorIDEBranding.cmake)
|
||||
|
||||
set(CPACK_PACKAGE_NAME ${IDE_CASED_ID})
|
||||
set(CPACK_PACKAGE_VENDOR "The Qt Company Ltd")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${IDE_DISPLAY_NAME})
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${IDE_ID})
|
||||
set(CPACK_VERBATIM_VARIABLES YES)
|
||||
|
||||
#set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_LIST_DIR}/Description.txt)
|
||||
#set(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_CURRENT_LIST_DIR}/Welcome.txt)
|
||||
#set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_LIST_DIR}/Readme.txt)
|
||||
|
||||
# WIX needs a license file ending with .txt
|
||||
file(COPY_FILE
|
||||
${CMAKE_CURRENT_LIST_DIR}/../LICENSE.GPL3-EXCEPT
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LICENSE.GPL3-EXCEPT.txt
|
||||
ONLY_IF_DIFFERENT)
|
||||
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_BINARY_DIR}/LICENSE.GPL3-EXCEPT.txt)
|
||||
|
||||
set(CPACK_PACKAGE_CONTACT "None")
|
||||
set(CPACK_THREADS 4)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
||||
set(CPACK_DEBIAN_COMPRESSION_TYPE lzma)
|
||||
|
||||
# Make CMAKE_INSTALL_DEFAULT_COMPONENT_NAME the first component to install
|
||||
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
|
||||
list(REMOVE_ITEM CPACK_COMPONENTS_ALL ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
|
||||
list(REMOVE_ITEM CPACK_COMPONENTS_ALL libraries) # empty component, breaks WIX
|
||||
list(PREPEND CPACK_COMPONENTS_ALL ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
|
||||
|
||||
set(CPACK_COMPONENT_Dependencies_HIDDEN TRUE)
|
||||
|
||||
if (APPLE)
|
||||
set(CPACK_INSTALL_PREFIX "/")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${IDE_ID}-${CMAKE_PROJECT_VERSION})
|
||||
else()
|
||||
set(CPACK_SET_DESTDIR ON)
|
||||
set(CPACK_STRIP_FILES ON)
|
||||
|
||||
if (NOT APPLE)
|
||||
set(CPACK_INSTALL_CMAKE_PROJECTS
|
||||
"${CMAKE_BINARY_DIR};${IDE_CASED_ID};ALL;/"
|
||||
"${CMAKE_BINARY_DIR};Dependencies;Dependencies;/"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# NSIS-specific configuration
|
||||
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_LIST_DIR}/../src/app/qtcreator.ico")
|
||||
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_LIST_DIR}/../src/app/qtcreator.ico")
|
||||
set(CPACK_NSIS_INSTALLED_ICON_NAME "${IDE_APP_PATH}\\${IDE_APP_TARGET}.exe")
|
||||
set(CPACK_NSIS_DISPLAY_NAME "${IDE_DISPLAY_NAME} ${CMAKE_PROJECT_VERSION}")
|
||||
set(CPACK_NSIS_PACKAGE_NAME "${IDE_DISPLAY_NAME} ${CMAKE_PROJECT_VERSION}")
|
||||
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma\n SetCompressorDictSize 64")
|
||||
set(CPACK_NSIS_INSTALL_ROOT "C:\\Qt")
|
||||
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${IDE_APP_TARGET}")
|
||||
set(CPACK_NSIS_CREATE_ICONS_EXTRA
|
||||
"CreateShortCut '$SMPROGRAMS\\$STARTMENU_FOLDER\\${IDE_DISPLAY_NAME} ${CMAKE_PROJECT_VERSION}.lnk' '$INSTDIR\\${IDE_APP_PATH}\\${IDE_APP_TARGET}.exe' "
|
||||
)
|
||||
set(CPACK_NSIS_MANIFEST_DPI_AWARE ON)
|
||||
|
||||
# WIX-specific configuration
|
||||
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_LIST_DIR}/../src/app/qtcreator.ico")
|
||||
set(CPACK_WIX_UPGRADE_GUID "E6A093A5-83DE-47FA-B669-1DE0102BE92A")
|
||||
set(CPACK_WIX_LIGHT_EXTRA_FLAGS "-dcl:high") # set high compression
|
||||
|
||||
include(CPack)
|
Reference in New Issue
Block a user