QtTWAINCommon.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. function(extract_qt_variable VARIABLE)
  2. if(NOT DEFINED QT_QMAKE_EXECUTABLE)
  3. find_program(QT_QMAKE_EXECUTABLE "qmake")
  4. if(QT_QMAKE_EXECUTABLE STREQUAL QT_QMAKE_EXECUTABLE-NOTFOUND)
  5. message(FATAL_ERROR "Could not find qmake executable")
  6. endif()
  7. endif()
  8. execute_process(
  9. COMMAND ${QT_QMAKE_EXECUTABLE} -query ${VARIABLE}
  10. OUTPUT_VARIABLE ${VARIABLE}
  11. OUTPUT_STRIP_TRAILING_WHITESPACE
  12. )
  13. set(${VARIABLE} ${${VARIABLE}} PARENT_SCOPE)
  14. endfunction()
  15. function(add_target_windeployqt)
  16. if(WIN32)
  17. set(options)
  18. set(oneValueArgs QML_DIR TARGET)
  19. set(multiValueArgs)
  20. cmake_parse_arguments(add_target_windeployqt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  21. find_program(WINDEPLOYQT_EXECUTABLE "windeployqt" PATHS ${PATH})
  22. if(WINDEPLOYQT_EXECUTABLE STREQUAL WINDEPLOYQT_EXECUTABLE-NOTFOUND)
  23. message(WARNING "windeployqt is not found in specified PATH! Please, copy dependencies manually")
  24. else()
  25. if(DEFINED add_target_windeployqt_QML_DIR)
  26. set(QML_DIR --qmldir ${add_target_windeployqt_QML_DIR})
  27. endif()
  28. add_custom_command(TARGET ${add_target_windeployqt_TARGET} POST_BUILD
  29. COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:QtTWAIN> $<TARGET_FILE_DIR:${add_target_windeployqt_TARGET}>
  30. COMMAND ${WINDEPLOYQT_EXECUTABLE} ${QML_DIR} $<TARGET_FILE_DIR:${add_target_windeployqt_TARGET}>)
  31. endif()
  32. endif()
  33. endfunction()