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