include_guard(DIRECTORY) function(_update_client_normalize_thirdparty_root) if(NOT UPDATE_CLIENT_THIRDPARTY_ROOT) message(FATAL_ERROR "UPDATE_CLIENT_THIRDPARTY_ROOT is empty. Set it to the project third-party " "root, normally /3rdparty." ) endif() cmake_path( ABSOLUTE_PATH UPDATE_CLIENT_THIRDPARTY_ROOT BASE_DIRECTORY "${UPDATE_CLIENT_SOURCE_DIR}" NORMALIZE OUTPUT_VARIABLE _absolute_root ) if(NOT IS_DIRECTORY "${_absolute_root}") message(FATAL_ERROR "UPDATE_CLIENT_THIRDPARTY_ROOT does not exist: ${_absolute_root}\n" "Provision the project dependencies or pass the correct project-relative root." ) endif() set( UPDATE_CLIENT_THIRDPARTY_ROOT "${_absolute_root}" CACHE PATH "Root directory for update-client third-party packages" FORCE ) set(UPDATE_CLIENT_THIRDPARTY_ROOT "${_absolute_root}" PARENT_SCOPE) endfunction() function(_update_client_assert_path_under_root candidate_path description root_path) if(candidate_path MATCHES "^\\$<") message(FATAL_ERROR "Strict third-party validation cannot verify ${description}: ${candidate_path}" ) endif() if(NOT EXISTS "${candidate_path}") message(FATAL_ERROR "${description} does not exist: ${candidate_path}") endif() file(REAL_PATH "${root_path}" _real_root) file(REAL_PATH "${candidate_path}" _real_candidate) set(_root_for_prefix_check "${_real_root}") cmake_path( IS_PREFIX _root_for_prefix_check "${_real_candidate}" NORMALIZE _is_under_root ) if(NOT _is_under_root) message(FATAL_ERROR "Strict third-party validation rejected ${description}:\n" " resolved path: ${_real_candidate}\n" " required root: ${_real_root}\n" "Provision OpenSSL under UPDATE_CLIENT_THIRDPARTY_ROOT or disable " "UPDATE_CLIENT_STRICT_THIRDPARTY only for local dependency diagnosis." ) endif() endfunction() function(_update_client_assert_openssl_target_under_root target_name root_path) set(_location_properties IMPORTED_LOCATION IMPORTED_IMPLIB) get_target_property(_imported_configurations "${target_name}" IMPORTED_CONFIGURATIONS) if(_imported_configurations AND NOT _imported_configurations MATCHES "-NOTFOUND$") foreach(_configuration IN LISTS _imported_configurations) string(TOUPPER "${_configuration}" _configuration_upper) list(APPEND _location_properties "IMPORTED_LOCATION_${_configuration_upper}" "IMPORTED_IMPLIB_${_configuration_upper}" ) endforeach() endif() set(_has_library_location OFF) foreach(_property IN LISTS _location_properties) get_target_property(_locations "${target_name}" "${_property}") if(NOT _locations OR _locations MATCHES "-NOTFOUND$") continue() endif() foreach(_location IN LISTS _locations) _update_client_assert_path_under_root( "${_location}" "${target_name} ${_property}" "${root_path}" ) set(_has_library_location ON) endforeach() endforeach() if(NOT _has_library_location) message(FATAL_ERROR "Strict third-party validation found no imported library location for ${target_name}." ) endif() get_target_property(_include_directories "${target_name}" INTERFACE_INCLUDE_DIRECTORIES) if(NOT _include_directories OR _include_directories MATCHES "-NOTFOUND$") message(FATAL_ERROR "Strict third-party validation found no imported include directory for ${target_name}." ) endif() foreach(_include_directory IN LISTS _include_directories) if(_include_directory MATCHES "^\\$$") set(_include_directory "${CMAKE_MATCH_1}") elseif(_include_directory MATCHES "^\\$/${_runtime_name}" COMMENT "Deploying ${_runtime_name} for ${target_name}" VERBATIM ) endforeach() endfunction() function(update_client_install_openssl_runtime destination) if(NOT WIN32) return() endif() set(_runtime_dlls) foreach(_openssl_target IN ITEMS OpenSSL::SSL OpenSSL::Crypto) get_target_property( _runtime_dll "${_openssl_target}" UPDATE_CLIENT_RUNTIME_DLL ) if(NOT _runtime_dll OR _runtime_dll MATCHES "-NOTFOUND$") message(FATAL_ERROR "${_openssl_target} has no validated runtime DLL for installation." ) endif() list(APPEND _runtime_dlls "${_runtime_dll}") endforeach() install(FILES ${_runtime_dlls} DESTINATION "${destination}") endfunction() function(update_client_enable_qt_deployment target_name) if(NOT TARGET "${target_name}") message(FATAL_ERROR "Unknown update-client target: ${target_name}") endif() if(NOT WIN32 OR NOT UPDATE_CLIENT_DEPLOY_QT_RUNTIME) return() endif() add_custom_command( TARGET "${target_name}" POST_BUILD COMMAND "${UPDATE_CLIENT_WINDEPLOYQT_EXECUTABLE}" "$,--debug,--release>" "$" COMMENT "Deploying Qt runtime for ${target_name}" VERBATIM ) endfunction()