CMake: Fix build with custom INSTALL_INCLUDEDIR

The include directory in Qt's build directory is always named
"include", no matter what the value of INSTALL_INCLUDEDIR is. The main
reason is that the name "include" is hard-coded in syncqt.

The INSTALL_INCLUDEDIR variable must only affect the installation
location of headers.

Fixes: QTBUG-85893
Change-Id: I5367bc589cba129eb41817e2b58d470f730bb5ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2020-08-06 09:56:58 +02:00
parent a95d4f68ee
commit 6c07e9f3bb
3 changed files with 13 additions and 14 deletions

View File

@ -4,7 +4,7 @@ add_library(Qt::Platform ALIAS Platform)
target_include_directories(Platform target_include_directories(Platform
INTERFACE INTERFACE
$<BUILD_INTERFACE:${QT_PLATFORM_DEFINITION_DIR_ABSOLUTE}> $<BUILD_INTERFACE:${QT_PLATFORM_DEFINITION_DIR_ABSOLUTE}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${QT_PLATFORM_DEFINITION_DIR}> $<INSTALL_INTERFACE:${QT_PLATFORM_DEFINITION_DIR}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>
) )
@ -276,8 +276,8 @@ qt_install(PROGRAMS "${QT_BUILD_DIR}/${INSTALL_BINDIR}/${__qt_cmake_install_scri
## files always lived in Qt::Core, so we keep it that way ## files always lived in Qt::Core, so we keep it that way
add_library(GlobalConfig INTERFACE) add_library(GlobalConfig INTERFACE)
target_include_directories(GlobalConfig INTERFACE target_include_directories(GlobalConfig INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INSTALL_INCLUDEDIR}> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INSTALL_INCLUDEDIR}/QtCore> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore> $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore>
) )
@ -308,8 +308,8 @@ add_library(Qt::GlobalConfig ALIAS GlobalConfig)
add_library(GlobalConfigPrivate INTERFACE) add_library(GlobalConfigPrivate INTERFACE)
target_link_libraries(GlobalConfigPrivate INTERFACE GlobalConfig) target_link_libraries(GlobalConfigPrivate INTERFACE GlobalConfig)
target_include_directories(GlobalConfigPrivate INTERFACE target_include_directories(GlobalConfigPrivate INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}/QtCore> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/QtCore/${PROJECT_VERSION}/QtCore>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}> $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}/QtCore> $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}/QtCore/${PROJECT_VERSION}/QtCore>
) )

View File

@ -1843,8 +1843,8 @@ function(qt_internal_module_info result target)
string(REPLACE "." "_" define "${define}") string(REPLACE "." "_" define "${define}")
set("${result}_upper" "${upper}" PARENT_SCOPE) set("${result}_upper" "${upper}" PARENT_SCOPE)
set("${result}_lower" "${lower}" PARENT_SCOPE) set("${result}_lower" "${lower}" PARENT_SCOPE)
set("${result}_repo_include_dir" "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}" PARENT_SCOPE) set("${result}_repo_include_dir" "${QT_BUILD_DIR}/include" PARENT_SCOPE)
set("${result}_include_dir" "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}/${module}" PARENT_SCOPE) set("${result}_include_dir" "${QT_BUILD_DIR}/include/${module}" PARENT_SCOPE)
set("${result}_define" "${define}" PARENT_SCOPE) set("${result}_define" "${define}" PARENT_SCOPE)
endfunction() endfunction()
@ -2184,7 +2184,7 @@ function(qt_install_injections target build_dir install_dir)
# ${qtbase_build_dir}. # ${qtbase_build_dir}.
# #
# In the code below, ${some_prefix} == ${build_dir}. # In the code below, ${some_prefix} == ${build_dir}.
set(lower_case_forwarding_header_path "${build_dir}/${INSTALL_INCLUDEDIR}/${module}") set(lower_case_forwarding_header_path "${build_dir}/include/${module}")
if(destinationdir) if(destinationdir)
string(APPEND lower_case_forwarding_header_path "/${destinationdir}") string(APPEND lower_case_forwarding_header_path "/${destinationdir}")
endif() endif()
@ -2219,7 +2219,7 @@ function(qt_install_injections target build_dir install_dir)
# Generate UpperCaseNamed forwarding headers (part 3). # Generate UpperCaseNamed forwarding headers (part 3).
foreach(fwd_hdr ${fwd_hdrs}) foreach(fwd_hdr ${fwd_hdrs})
set(upper_case_forwarding_header_path "${INSTALL_INCLUDEDIR}/${module}") set(upper_case_forwarding_header_path "include/${module}")
if(destinationdir) if(destinationdir)
string(APPEND upper_case_forwarding_header_path "/${destinationdir}") string(APPEND upper_case_forwarding_header_path "/${destinationdir}")
endif() endif()
@ -2234,8 +2234,7 @@ function(qt_install_injections target build_dir install_dir)
"${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}") "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}")
else() else()
# Install the forwarding header. # Install the forwarding header.
qt_path_join(install_destination qt_path_join(install_destination "${install_dir}" "${INSTALL_INCLUDEDIR}" ${module})
${install_dir} ${upper_case_forwarding_header_path})
qt_install(FILES "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}" qt_install(FILES "${build_dir}/${upper_case_forwarding_header_path}/${fwd_hdr}"
DESTINATION ${install_destination} OPTIONAL) DESTINATION ${install_destination} OPTIONAL)
endif() endif()
@ -2782,7 +2781,7 @@ function(qt_add_module target)
set_target_properties("${target}" PROPERTIES INTERFACE_MODULE_HAS_HEADERS ON) set_target_properties("${target}" PROPERTIES INTERFACE_MODULE_HAS_HEADERS ON)
### FIXME: Can we replace headers.pri? ### FIXME: Can we replace headers.pri?
set(module_include_dir "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}/${module_include_name}") set(module_include_dir "${QT_BUILD_DIR}/include/${module_include_name}")
qt_read_headers_pri("${module_include_dir}" "module_headers") qt_read_headers_pri("${module_include_dir}" "module_headers")
set(module_depends_header "${module_include_dir}/${module}Depends") set(module_depends_header "${module_include_dir}/${module}Depends")
if(is_framework) if(is_framework)
@ -4279,7 +4278,7 @@ function(qt_add_test name)
set(private_includes set(private_includes
"${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}"
"$<BUILD_INTERFACE:${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}>" "$<BUILD_INTERFACE:${QT_BUILD_DIR}/include>"
${arg_INCLUDE_DIRECTORIES} ${arg_INCLUDE_DIRECTORIES}
) )

View File

@ -1,5 +1,5 @@
function(qt_internal_write_depends_file module) function(qt_internal_write_depends_file module)
set(outfile "${QT_BUILD_DIR}/${INSTALL_INCLUDEDIR}/${module}/${module}Depends") set(outfile "${QT_BUILD_DIR}/include/${module}/${module}Depends")
set(contents "/* This file was generated by cmake with the info from ${module} target. */\n") set(contents "/* This file was generated by cmake with the info from ${module} target. */\n")
string(APPEND contents "#ifdef __cplusplus /* create empty PCH in C mode */\n") string(APPEND contents "#ifdef __cplusplus /* create empty PCH in C mode */\n")
foreach (m ${ARGN}) foreach (m ${ARGN})