# packagePresets options in CMakePreset not taken in account

**URL:** https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908
**Category:** Usage
**Tags:** os:windows
**Created:** [September 8, 2023, 1:46pm UTC](https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908 "2023-09-08T13:46:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kingloxxy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kingloxxy/32/3800_2.png) [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)
#### Post date: [September 8, 2023, 1:46pm UTC](https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908/1 "2023-09-08T13:46:21Z")

</div>

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

```auto
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

```auto
{
    "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 😄

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [September 10, 2023, 4:00am UTC](https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908/2 "2023-09-10T04:00:52Z")

</div>

Are you sure your deploiment is ok?  
See [Qt's CMake deployment API](https://www.qt.io/blog/cmake-deployment-api)

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [September 10, 2023, 7:26am UTC](https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908/3 "2023-09-10T07:26:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kingloxxy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kingloxxy/32/3800_2.png) [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)
#### Post date: [September 10, 2023, 9:22am UTC](https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908/4 "2023-09-10T09:22:23Z")

</div>

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

Thanks !

---

<div class="post-metadata">

### Author: ![kingloxxy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kingloxxy/32/3800_2.png) [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)
#### Post date: [September 10, 2023, 9:29am UTC](https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908/5 "2023-09-10T09:29:03Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kingloxxy](https://discourse.cmake.org/user_avatar/discourse.cmake.org/kingloxxy/32/3800_2.png) [@kingloxxy](https://discourse.cmake.org/u/kingloxxy)
#### Post date: [September 10, 2023, 9:31am UTC](https://discourse.cmake.org/t/packagepresets-options-in-cmakepreset-not-taken-in-account/8908/6 "2023-09-10T09:31:32Z")

</div>

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

Here is my CMakeLists.txt

```auto
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

```auto
{
    "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 ?
