From 329f8f77ab1a9d0ca2edbbbf23ffbaacaf7b7345 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 9 Nov 2017 15:34:44 +0200 Subject: [PATCH] Fix broken private header detection --- CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a48be6ce2..800932c34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,6 +314,28 @@ if (USE_DBUS) else() endif (USE_DBUS) +############################################################################## + +function(check_private_headers_exist module private_includes_var) +message(STATUS "Checking whether private include directories for module ${module} exist") +foreach(_dir ${private_includes_var}) + if(NOT EXISTS "${_dir}") + message(FATAL_ERROR "The private include directory ${_dir} for module ${module} do not exist! Please make sure your Qt5 installation contains private headers.\nThe required directories:\n ${private_includes_var}") + endif() +endforeach() +endfunction() +function(check_private_header_exists _file _dirs) +set(_found FALSE) +foreach(_dir ${_dirs}) + if(EXISTS "${_dir}/${_file}") + set(_found TRUE) + endif() +endforeach() +if(NOT _found) + message(FATAL_ERROR "The private include file ${_file} was not found in directory ${_dirs}! Please make sure your Qt5 installation contains private headers.") +endif() +endfunction() + ############################################################################## ## Qt5 setup setup if (ENABLE_QT) @@ -323,7 +345,23 @@ if (ENABLE_QT) message(STATUS "Will enable Qt launcher GUI") message(STATUS " Qt5Widgets version: ${Qt5Widgets_VERSION_STRING}") message(STATUS " Qt5Widgets include dir: ${Qt5Widgets_INCLUDE_DIRS}") - message(STATUS " QtQuick private header: ${Qt5Quick_PRIVATE_INCLUDE_DIRS}") + + # copied from KDAB's GammaRay CMakeLists.txt + # Sanity checking, we need private includes for the following modules + + check_private_headers_exist("Qt5Gui" "${Qt5Gui_PRIVATE_INCLUDE_DIRS}") + + #HACK: CMake with broken Qt5Quick_PRIVATE_INCLUDE_DIRS + if (NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/") + string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}") + list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${Qt5Qml_PRIVATE_INCLUDE_DIRS}) + list(APPEND Qt5Quick_PRIVATE_INCLUDE_DIRS ${replaceme}) + list(REMOVE_DUPLICATES Qt5Quick_PRIVATE_INCLUDE_DIRS) + endif() + check_private_header_exists("private/qquickitem_p.h" "${Qt5Quick_PRIVATE_INCLUDE_DIRS}") + + message(STATUS " Qt5Quick private include dir: ${Qt5Quick_PRIVATE_INCLUDE_DIRS}") + set(HAVE_QT 1) else() # don't try to build FGQCanvas if Qt wasn't found correctly