summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-07-05 13:28:58 +0200
committerAlexey Edelev <semlanik@gmail.com>2021-07-09 17:00:20 +0200
commit943b561c329f7a893cd09517a52ee9fbd004f420 (patch)
tree9a87ead5f490261226768d67e3886c1d882be510 /cmake
parent69c70ace059b497e81264722a3a3146a3c5f855e (diff)
Fix the detection of platform definitions directory
Platform definition directory is defined when building qtbase. Depending on the build type (prefixed/non-prefixed) it should point: - To the source directory when building prefixed qtbase. - To the installation directory of the prefixed qtbase when building consumer projects. - To the build directory of non-prefixed qtbase when building non-prefixed qtbase or consumer projects. TODO: It is desirable to move the logic asssociated with Qt platform definition to the qt_internal_setup_public_platform_target function. Fixes: QTBUG-94973 Change-Id: I8530613f9b2029834c66206bbdf02475528a4640 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 478f5fcde66a49b710c427447916a0ee0e4d9e0a)
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake38
-rw-r--r--cmake/QtPublicTargetsHelpers.cmake2
2 files changed, 24 insertions, 16 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 8547ff09d1..8ae9714fa1 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -331,21 +331,30 @@ else()
set(QT_QMAKE_HOST_MKSPEC "${QT_QMAKE_TARGET_MKSPEC}")
endif()
-# Platform definition dir provided by user on command line.
-# Derive the absolute one relative to the current source dir.
-if(QT_PLATFORM_DEFINITION_DIR)
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR "${QT_PLATFORM_DEFINITION_DIR}")
- get_filename_component(
- QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE
- "${QT_PLATFORM_DEFINITION_DIR}"
- ABSOLUTE)
-elseif(QT_QMAKE_TARGET_MKSPEC)
- # Used by consumers of prefix builds via INSTALL_INTERFACE (relative path).
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR "${INSTALL_MKSPECSDIR}/${QT_QMAKE_TARGET_MKSPEC}")
- # Used by qtbase itself and consumers of non-prefix builds via BUILD_INTERFACE (absolute path).
- set(QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE "${QT_MKSPECS_DIR}/${QT_QMAKE_TARGET_MKSPEC}")
+# Used by consumers of prefix builds via INSTALL_INTERFACE (relative path).
+set(QT_DEFAULT_PLATFORM_DEFINITION_DIR "${INSTALL_MKSPECSDIR}/${QT_QMAKE_TARGET_MKSPEC}")
+
+# Used by qtbase in prefix builds via BUILD_INTERFACE
+set(QT_PLATFORM_DEFINITION_BUILD_INTERFACE_BASE_DIR
+ "${CMAKE_CURRENT_LIST_DIR}/../mkspecs/"
+)
+
+# Used by qtbase and consumers in non-prefix builds via BUILD_INTERFACE
+if(NOT QT_WILL_INSTALL)
+ set(QT_PLATFORM_DEFINITION_BUILD_INTERFACE_BASE_DIR
+ "${CMAKE_BINARY_DIR}/${INSTALL_MKSPECSDIR}"
+ )
endif()
+get_filename_component(QT_PLATFORM_DEFINITION_BUILD_INTERFACE_DIR
+ "${QT_PLATFORM_DEFINITION_BUILD_INTERFACE_BASE_DIR}/${QT_QMAKE_TARGET_MKSPEC}"
+ ABSOLUTE
+)
+set(QT_PLATFORM_DEFINITION_BUILD_INTERFACE_DIR
+ "${QT_PLATFORM_DEFINITION_BUILD_INTERFACE_DIR}"
+ CACHE INTERNAL "Path to directory that contains qplatformdefs.h"
+)
+
if(NOT DEFINED QT_DEFAULT_PLATFORM_DEFINITIONS)
set(QT_DEFAULT_PLATFORM_DEFINITIONS "")
endif()
@@ -354,8 +363,7 @@ set(QT_PLATFORM_DEFINITIONS ${QT_DEFAULT_PLATFORM_DEFINITIONS}
CACHE STRING "Qt platform specific pre-processor defines")
set(QT_PLATFORM_DEFINITION_DIR "${QT_DEFAULT_PLATFORM_DEFINITION_DIR}"
CACHE PATH "Path to directory that contains qplatformdefs.h")
-set(QT_PLATFORM_DEFINITION_DIR_ABSOLUTE "${QT_DEFAULT_PLATFORM_DEFINITION_DIR_ABSOLUTE}"
- CACHE INTERNAL "Path to directory that contains qplatformdefs.h")
+
set(QT_NAMESPACE "" CACHE STRING "Qt Namespace")
if(QT_NAMESPACE STREQUAL "")
set(QT_HAS_NAMESPACE OFF)
diff --git a/cmake/QtPublicTargetsHelpers.cmake b/cmake/QtPublicTargetsHelpers.cmake
index 39ba11b260..82e7354b1a 100644
--- a/cmake/QtPublicTargetsHelpers.cmake
+++ b/cmake/QtPublicTargetsHelpers.cmake
@@ -7,7 +7,7 @@ function(qt_internal_setup_public_platform_target)
add_library(${INSTALL_CMAKE_NAMESPACE}::Platform ALIAS Platform)
target_include_directories(Platform
INTERFACE
- $<BUILD_INTERFACE:${QT_PLATFORM_DEFINITION_DIR_ABSOLUTE}>
+ $<BUILD_INTERFACE:${QT_PLATFORM_DEFINITION_BUILD_INTERFACE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${QT_PLATFORM_DEFINITION_DIR}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>