Это то, что я делаю для копирования
Код: Выделить всё
# removed above code for brevity
target_link_libraries(appScratchPad
PRIVATE
Qt6::Quick
Qt6::Svg
Qt6::QmlCompiler
Qt6::Qml
Qt6::Sql
Qt6::WebEngineQuick
${MD_LIBRARY}
)
## CPack
# Get link libraries of the target
get_target_property(link_libraries appScratchPad LINK_LIBRARIES)
# Initialize the variable to store library paths
set(LIB_LOCATIONS "")
# Iterate over each link entry
foreach (lib IN LISTS link_libraries)
# Check if the entry is a target and a library
if (TARGET ${lib})
# Obtain the full path to the library file
get_target_property(lib_location ${lib} LOCATION)
# Append the path to the LIB_LOCATIONS list
if (lib_location)
list(APPEND LIB_LOCATIONS ${lib_location})
message(STATUS "Added ${lib_location} to LIB_LOCATIONS")
else ()
message(WARNING "Location for ${lib} not found.")
endif ()
else ()
message(WARNING "Skipping ${lib} as it is not a target.")
endif ()
endforeach ()
# Output the collected library locations
message(STATUS "LIB_LOCATIONS: ${LIB_LOCATIONS}")
set(CPACK_PACKAGE_NAME "ScratchPad")
set(CPACK_PACKAGE_VENDOR "Gollahalli")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ScratchPad - A simple note taking app")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Gollahalli")
set(CPACK_PACKAGE_CONTACT "Akshay Raj Gollahalli ")
SET(CPACK_OUTPUT_FILE_PREFIX packages)
if (UNIX)
set(CPACK_GENERATOR "TGZ;DEB")
elseif (WIN32)
set(CPACK_GENERATOR "ZIP;NSIS")
endif ()
set(CPACK_COMPONENTS_ALL Runtime)
include(CPack)
include(InstallRequiredSystemLibraries)
include(GNUInstallDirs)
install(TARGETS appScratchPad
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Install Qt libraries
install(
FILES
${LIB_LOCATIONS}
DESTINATION
${CMAKE_INSTALL_LIBDIR}
COMPONENT Runtime
)
Подробнее здесь: https://stackoverflow.com/questions/784 ... with-cpack