windeployqt fails to deploy plugins in qt5. #51973
|
I'm a beginner programmer and I'm on an osg-qt project.
Is it a bug or am i doing some wrong things? This is my CMakeLists.txt cmake_minimum_required (VERSION 4.3)
project ("MyAwesomeProject" VERSION 0.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 CONFIG COMPONENTS Widgets Core Gui REQUIRED)
find_package(OpenSceneGraph COMPONENTS osgDB osgViewer osgGA osg osgUtil osgText osgSim osgFX REQUIRED)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
find_library(OSGQOPENGL_LIB REQUIRED
NAMES osgQOpenGLd
PATHS
${CMAKE_PREFIX_PATH}/debug/lib
)
else()
find_library(OSGQOPENGL_LIB REQUIRED
NAMES osgQOpenGL
PATHS
${CMAKE_PREFIX_PATH}/lib
)
endif()
add_executable(main)
target_include_directories(main PRIVATE
${CMAKE_SOURCE_DIR}/src
${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include
)
file(GLOB_RECURSE SRC_FILES CONFIGURE_DEPENDS src/*.cpp)
target_sources(main PRIVATE
${SRC_FILES})
target_link_libraries(main PRIVATE
Qt5::Widgets Qt5::Core Qt5::Gui
${OPENSCENEGRAPH_LIBRARIES}
${OSGQOPENGL_LIB}
)
if(WIN32)
set_target_properties(main PROPERTIES
WIN32_EXECUTABLE "$<CONFIG:Release>"
)
find_program(WINDEPLOYQT windeployqt REQUIRED)
add_custom_command(
TARGET main POST_BUILD
COMMAND
${WINDEPLOYQT}
$<TARGET_FILE:main>
--no-translations
)
endif()and vcpkg.json {
"dependencies": [
"osg-qt",
"qt5-tools"
]
}and CMakePresets.json {
"version": 10,
"configurePresets": [
{
"name": "default",
"hidden": true,
"description": "基础配置",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_CXX_STANDARD": "17",
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_INSTALLED_DIR": "${sourceDir}/vcpkg_installed"
}
},
{
"name": "windows",
"hidden": true,
"description": "Windows 配置",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "debug",
"hidden": true,
"description": "debug 配置",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"hidden": true,
"description": "release 配置",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "windows-debug",
"displayName": "Windows Debug",
"description": "Windows平台Debug构建",
"inherits": ["default","windows","debug"]
},
{
"name": "windows-release",
"displayName": "Windows Release",
"description": "Windows平台Release构建",
"inherits": ["default","windows","release"]
}
],
"buildPresets": [
{
"name": "windows-debug",
"configurePreset": "windows-debug",
"displayName": "Windows Debug Build"
},
{
"name": "windows-release",
"configurePreset": "windows-release",
"displayName": "Windows Release Build"
}
]
} |
Replies: 1 comment 3 replies
|
This is probably not your C++ code. It is usually a Qt tool lookup problem: the With vcpkg/Qt, avoid calling a random A practical CMake shape is: find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets Core Gui)
if(WIN32)
get_target_property(QMAKE_EXE Qt5::qmake IMPORTED_LOCATION)
get_target_property(WINDEPLOYQT_EXE Qt5::windeployqt IMPORTED_LOCATION)
add_custom_command(TARGET main POST_BUILD
COMMAND "${WINDEPLOYQT_EXE}"
--qmake "${QMAKE_EXE}"
--no-translations
"$<TARGET_FILE:main>"
VERBATIM
)
endif()If message(STATUS "windeployqt=${WINDEPLOYQT}")and on Windows: where windeployqt
where qmakeThe important rule is that If this solves it, please mark the comment as the answer so others can find it faster. |
Thanks for your help, Serge Yudin (@yudin-s) .
I search the whole
vcpkg_installeddirectory and find 3windeployqt.exerespecitvely invcpkg_installed\x64-windows\tools\qt5-tools\bin,vcpkg_installed\x64-windows\tools\qt5\binandvcpkg_installed\x64-windows\tools\qt5\debug\binThe final solution is this: