diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-07-05 13:28:58 +0200 |
---|---|---|
committer | Alexey Edelev <semlanik@gmail.com> | 2021-07-06 13:22:57 +0200 |
commit | b33913318ba43addb28acf1c5326cbbf454b1bbe (patch) | |
tree | 18070ce5be5b30fe158e8979675376472f24c2c0 /cmake | |
parent | 7dc6d2b44afc20e09d5f9beddd49ad7eb1d60898 (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.cmake | 38 | ||||
-rw-r--r-- | cmake/QtPlatformTargetHelpers.cmake | 2 |
2 files changed, 24 insertions, 16 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 96d11196d9..7d8a6388d3 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -372,21 +372,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() @@ -395,8 +404,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") include(QtGlobalStateHelpers) diff --git a/cmake/QtPlatformTargetHelpers.cmake b/cmake/QtPlatformTargetHelpers.cmake index 0ff8761f33..b98894829f 100644 --- a/cmake/QtPlatformTargetHelpers.cmake +++ b/cmake/QtPlatformTargetHelpers.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}> |