Qt5ScriptConfig.cmake 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. if (CMAKE_VERSION VERSION_LESS 2.8.3)
  2. message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3")
  3. endif()
  4. if(NOT DEFINED OE_QMAKE_PATH_EXTERNAL_HOST_BINS)
  5. message(WARNING Skipping because OE_QMAKE_PATH_EXTERNAL_HOST_BINS is not defined)
  6. return()
  7. endif()
  8. get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
  9. # Use original install prefix when loaded through a
  10. # cross-prefix symbolic link such as /lib -> /usr/lib.
  11. get_filename_component(_realCurr "${_IMPORT_PREFIX}" REALPATH)
  12. get_filename_component(_realOrig "/usr/lib/cmake/Qt5Script" REALPATH)
  13. if(_realCurr STREQUAL _realOrig)
  14. get_filename_component(_qt5Script_install_prefix "/usr/lib/../" ABSOLUTE)
  15. else()
  16. get_filename_component(_qt5Script_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
  17. endif()
  18. unset(_realOrig)
  19. unset(_realCurr)
  20. unset(_IMPORT_PREFIX)
  21. # For backwards compatibility only. Use Qt5Script_VERSION instead.
  22. set(Qt5Script_VERSION_STRING 5.7.1)
  23. set(Qt5Script_LIBRARIES Qt5::Script)
  24. macro(_qt5_Script_check_file_exists file)
  25. if(NOT EXISTS "${file}" )
  26. message(FATAL_ERROR "The imported target \"Qt5::Script\" references the file
  27. \"${file}\"
  28. but this file does not exist. Possible reasons include:
  29. * The file was deleted, renamed, or moved to another location.
  30. * An install or uninstall procedure did not complete successfully.
  31. * The installation package was faulty and contained
  32. \"${CMAKE_CURRENT_LIST_FILE}\"
  33. but not all the files it references.
  34. ")
  35. endif()
  36. endmacro()
  37. macro(_populate_Script_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION)
  38. set_property(TARGET Qt5::Script APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
  39. set(imported_location "${_qt5Script_install_prefix}/lib/${LIB_LOCATION}")
  40. _qt5_Script_check_file_exists(${imported_location})
  41. set_target_properties(Qt5::Script PROPERTIES
  42. "INTERFACE_LINK_LIBRARIES" "${_Qt5Script_LIB_DEPENDENCIES}"
  43. "IMPORTED_LOCATION_${Configuration}" ${imported_location}
  44. "IMPORTED_SONAME_${Configuration}" "libQt5Script.so.5"
  45. # For backward compatibility with CMake < 2.8.12
  46. "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5Script_LIB_DEPENDENCIES}"
  47. )
  48. endmacro()
  49. if (NOT TARGET Qt5::Script)
  50. set(_Qt5Script_OWN_INCLUDE_DIRS "${_qt5Script_install_prefix}/include/qt5/" "${_qt5Script_install_prefix}/include/qt5/QtScript")
  51. set(Qt5Script_PRIVATE_INCLUDE_DIRS
  52. "${_qt5Script_install_prefix}/include/qt5/QtScript/5.7.1"
  53. "${_qt5Script_install_prefix}/include/qt5/QtScript/5.7.1/QtScript"
  54. )
  55. foreach(_dir ${_Qt5Script_OWN_INCLUDE_DIRS})
  56. _qt5_Script_check_file_exists(${_dir})
  57. endforeach()
  58. # Only check existence of private includes if the Private component is
  59. # specified.
  60. list(FIND Qt5Script_FIND_COMPONENTS Private _check_private)
  61. if (NOT _check_private STREQUAL -1)
  62. foreach(_dir ${Qt5Script_PRIVATE_INCLUDE_DIRS})
  63. _qt5_Script_check_file_exists(${_dir})
  64. endforeach()
  65. endif()
  66. set(Qt5Script_INCLUDE_DIRS ${_Qt5Script_OWN_INCLUDE_DIRS})
  67. set(Qt5Script_DEFINITIONS -DQT_SCRIPT_LIB)
  68. set(Qt5Script_COMPILE_DEFINITIONS QT_SCRIPT_LIB)
  69. set(_Qt5Script_MODULE_DEPENDENCIES "Core")
  70. set(_Qt5Script_FIND_DEPENDENCIES_REQUIRED)
  71. if (Qt5Script_FIND_REQUIRED)
  72. set(_Qt5Script_FIND_DEPENDENCIES_REQUIRED REQUIRED)
  73. endif()
  74. set(_Qt5Script_FIND_DEPENDENCIES_QUIET)
  75. if (Qt5Script_FIND_QUIETLY)
  76. set(_Qt5Script_DEPENDENCIES_FIND_QUIET QUIET)
  77. endif()
  78. set(_Qt5Script_FIND_VERSION_EXACT)
  79. if (Qt5Script_FIND_VERSION_EXACT)
  80. set(_Qt5Script_FIND_VERSION_EXACT EXACT)
  81. endif()
  82. set(Qt5Script_EXECUTABLE_COMPILE_FLAGS "")
  83. foreach(_module_dep ${_Qt5Script_MODULE_DEPENDENCIES})
  84. if (NOT Qt5${_module_dep}_FOUND)
  85. find_package(Qt5${_module_dep}
  86. 5.7.1 ${_Qt5Script_FIND_VERSION_EXACT}
  87. ${_Qt5Script_DEPENDENCIES_FIND_QUIET}
  88. ${_Qt5Script_FIND_DEPENDENCIES_REQUIRED}
  89. PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH
  90. )
  91. endif()
  92. if (NOT Qt5${_module_dep}_FOUND)
  93. set(Qt5Script_FOUND False)
  94. return()
  95. endif()
  96. list(APPEND Qt5Script_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}")
  97. list(APPEND Qt5Script_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}")
  98. list(APPEND Qt5Script_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS})
  99. list(APPEND Qt5Script_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS})
  100. list(APPEND Qt5Script_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS})
  101. endforeach()
  102. list(REMOVE_DUPLICATES Qt5Script_INCLUDE_DIRS)
  103. list(REMOVE_DUPLICATES Qt5Script_PRIVATE_INCLUDE_DIRS)
  104. list(REMOVE_DUPLICATES Qt5Script_DEFINITIONS)
  105. list(REMOVE_DUPLICATES Qt5Script_COMPILE_DEFINITIONS)
  106. list(REMOVE_DUPLICATES Qt5Script_EXECUTABLE_COMPILE_FLAGS)
  107. set(_Qt5Script_LIB_DEPENDENCIES "Qt5::Core")
  108. add_library(Qt5::Script SHARED IMPORTED)
  109. set_property(TARGET Qt5::Script PROPERTY
  110. INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Script_OWN_INCLUDE_DIRS})
  111. set_property(TARGET Qt5::Script PROPERTY
  112. INTERFACE_COMPILE_DEFINITIONS QT_SCRIPT_LIB)
  113. _populate_Script_target_properties(RELEASE "libQt5Script.so.5.7.1" "" )
  114. file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Script_*Plugin.cmake")
  115. macro(_populate_Script_plugin_properties Plugin Configuration PLUGIN_LOCATION)
  116. set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration})
  117. set(imported_location "${_qt5Script_install_prefix}/lib/qt5/plugins/${PLUGIN_LOCATION}")
  118. _qt5_Script_check_file_exists(${imported_location})
  119. set_target_properties(Qt5::${Plugin} PROPERTIES
  120. "IMPORTED_LOCATION_${Configuration}" ${imported_location}
  121. )
  122. endmacro()
  123. if (pluginTargets)
  124. foreach(pluginTarget ${pluginTargets})
  125. include(${pluginTarget})
  126. endforeach()
  127. endif()
  128. _qt5_Script_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5ScriptConfigVersion.cmake")
  129. endif()