build: deploy Qt runtime for Windows builds
Run windeployqt as a post-build step for Schedule, copy MinGW runtime DLLs, and place Windows test binaries next to the deployed Qt runtime.
This commit is contained in:
@@ -50,6 +50,63 @@ if(WIN32 AND ELAWIDGETTOOLS_BUILD_STATIC_LIB)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
function(schedule_deploy_qt_runtime target)
|
||||
if(NOT WIN32)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(_qt_bin_dir "")
|
||||
if(TARGET Qt6::qmake)
|
||||
get_target_property(_qmake Qt6::qmake IMPORTED_LOCATION)
|
||||
if(_qmake)
|
||||
get_filename_component(_qt_bin_dir "${_qmake}" DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT _qt_bin_dir)
|
||||
get_filename_component(_qt_bin_dir "${Qt6_DIR}/../../../bin" ABSOLUTE)
|
||||
endif()
|
||||
|
||||
find_program(SCHEDULE_WINDEPLOYQT
|
||||
NAMES windeployqt
|
||||
HINTS "${_qt_bin_dir}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT SCHEDULE_WINDEPLOYQT)
|
||||
message(FATAL_ERROR "windeployqt not found under ${_qt_bin_dir}; check CMAKE_PREFIX_PATH")
|
||||
endif()
|
||||
|
||||
set(_deploy_args)
|
||||
if(MSVC)
|
||||
list(APPEND _deploy_args --compiler-runtime)
|
||||
endif()
|
||||
list(APPEND _deploy_args
|
||||
--dir "$<TARGET_FILE_DIR:${target}>"
|
||||
"$<TARGET_FILE:${target}>"
|
||||
)
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND "${SCHEDULE_WINDEPLOYQT}" ${_deploy_args}
|
||||
COMMENT "Deploying Qt runtime for ${target}"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
if(MINGW)
|
||||
get_filename_component(_mingw_bin_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
||||
file(GLOB _mingw_runtime
|
||||
"${_mingw_bin_dir}/libgcc_s_*.dll"
|
||||
"${_mingw_bin_dir}/libstdc++-6.dll"
|
||||
"${_mingw_bin_dir}/libwinpthread-1.dll"
|
||||
)
|
||||
if(_mingw_runtime)
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${_mingw_runtime} "$<TARGET_FILE_DIR:${target}>"
|
||||
COMMENT "Copying MinGW runtime for ${target}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
||||
|
||||
@@ -114,3 +114,7 @@ set_target_properties(Schedule PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
)
|
||||
target_link_libraries(Schedule PRIVATE schedule_ui schedule_sync)
|
||||
|
||||
if(WIN32)
|
||||
schedule_deploy_qt_runtime(Schedule)
|
||||
endif()
|
||||
|
||||
@@ -43,3 +43,11 @@ if(TARGET schedule-sync-server)
|
||||
ENVIRONMENT "SCHEDULE_SYNC_SERVER_BIN=${CMAKE_BINARY_DIR}/bin/schedule-sync-server${CMAKE_EXECUTABLE_SUFFIX}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(
|
||||
test_storage test_services test_grid test_mainwindow test_compactwindow
|
||||
test_config test_scheduler test_ai test_openai_provider test_sync_integration
|
||||
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user