packagePresets options in CMakePreset not taken in account

Hi,

I am using a CMakePresets.json in order to generate an artefact of my project.
I defined various options on the buildPresets step to custom my output artefact.
Nevertheless, some of the options set are not being taken in account (packageName and packageVersion).
My artefact is created with the default value for these options instead.

I might have missed something or misunderstood the behavior of the buildPreset step of the CMakePresets.json

Here is my CMakeLists.txt

cmake_minimum_required( VERSION 3.25 )

project( Test )

include( GNUInstallDirs )

file( GLOB HEADERS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Headers/*.h )
file( GLOB SOURCES_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Sources/*.cpp )
file( GLOB RESSOURCES_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Ressources/*.qrc )
file( GLOB UI_FILES ${CMAKE_CURRENT_SOURCE_DIR}/UI/*.ui )

set( CMAKE_DEBUG_POSTFIX d )

set( QtComponents Core Gui Widgets Network Multimedia )
set( CMAKE_AUTOMOC YES )
set( CMAKE_AUTOUIC YES )
set( CMAKE_AUTORCC YES )
set( CMAKE_AUTOUIC_SEARCH_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/UI )

source_group( "UI Files" REGULAR_EXPRESSION [[.*\.ui]] )

find_package( Qt5 REQUIRED COMPONENTS ${QtComponents} )

add_executable( ${PROJECT_NAME} ${HEADERS_FILES} ${SOURCES_FILES} ${RESSOURCES_FILES} ${UI_FILES} )

target_include_directories( ${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/Headers )
target_link_libraries( ${PROJECT_NAME} PRIVATE Qt5::$<JOIN:${QtComponents}, Qt5::> )

set_target_properties( ${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} )

add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND windeployqt ${CMAKE_BINARY_DIR}/$<CONFIG>/${PROJECT_NAME}$<$<CONFIG:Debug>:d>.exe )

install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/ DESTINATION . )

include( CPack )

Here is my CMakePresets.json

{
    "version": 6,

    "cmakeMinimumRequired":
    {
      "major": 3,
      "minor": 25,
      "patch": 0
    },

    "configurePresets":
    [
      {
        "name": "VS2022_x64",
        "generator": "Visual Studio 17 2022",
        "binaryDir": "${sourceDir}/build/",

        "architecture":
        {
          "value": "x64",
          "strategy": "set"
        }
      }
    ],

    "buildPresets":
    [
      {
        "name": "Release",
        "configurePreset": "VS2022_x64",
        "configuration": "Release"
      }
    ],

    "packagePresets":
    [
      {
        "name": "Packaging",
        "configurePreset": "VS2022_x64",
        "generators": [ "ZIP" ],
        "configurations": [ "Release" ],
        "packageName": "Test",
        "packageVersion": "2.0.0",
        "packageDirectory": "${sourceDir}/"
      }
    ],

    "workflowPresets":
    [
      {
        "name": "packaging",
        "steps":
        [
          {
            "type": "configure",
            "name": "VS2022_x64"
          },
          {
            "type": "build",
            "name": "Release"
          },
          {
            "type": "package",
            "name": "Packaging"
          }
        ]
      }
    ]
}

Thanks in advance for your support :smile:

Are you sure your deploiment is ok?
See Qt's CMake deployment API

This is unlikely to be the problem, but let’s eliminate it anyway. CMake defines a special target called test in some cases. You’ve used a project name and target name Test, which only differs by the upper/lowercase. Use a different target name, just in case you’re being bitten by some subtle logic that runs afoul of that. I expect this won’t change things for you, but we may as well eliminate that as a potential cause.

If the above makes no difference, then @kyle.edwards may want to take a closer look at why the package preset fields don’t seem to be getting honoured.

I used test as an example, i already tried with other target name with the same result. I’ll check @kyle.edwards link.

Thanks !

I deleted all code related with Qt on my app and got still the same result.

I created a minimal CMakeLists.txt and CMakePresets.json but still got the same result.

Here is my CMakeLists.txt

cmake_minimum_required( VERSION 3.25 )

project( AA )

add_executable( ${PROJECT_NAME} main.cpp )

install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/ DESTINATION . )

include( CPack )

and my CMakePresets.json

{
    "version": 6,

    "cmakeMinimumRequired":
    {
      "major": 3,
      "minor": 25,
      "patch": 0
    },

    "configurePresets":
    [
      {
        "name": "VS2022_x64",
        "generator": "Visual Studio 17 2022",
        "binaryDir": "${sourceDir}/build/",

        "architecture":
        {
          "value": "x64",
          "strategy": "set"
        }
      }
    ],

    "buildPresets":
    [
      {
        "name": "Release",
        "configurePreset": "VS2022_x64",
        "configuration": "Release"
      }
    ],

    "packagePresets":
    [
      {
        "name": "Packaging",
        "configurePreset": "VS2022_x64",
        "generators": [ "ZIP" ],
        "configurations": [ "Release" ],
        "packageName": "MYPKG",
        "packageVersion": "2.0.0",
        "packageDirectory": "${sourceDir}/"
      }
    ],

    "workflowPresets":
    [
      {
        "name": "packaging",
        "steps":
        [
          {
            "type": "configure",
            "name": "VS2022_x64"
          },
          {
            "type": "build",
            "name": "Release"
          },
          {
            "type": "package",
            "name": "Packaging"
          }
        ]
      }
    ]
}

Can we consider this as a bug ?