From abb231a2f08514f0d4daf5219d3ac70a08e9f401 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 18 Jul 2024 18:33:50 +0200 Subject: [PATCH] CMake: Only build QtLibraryInfo if we are building tools It is a dependency for qmake and qtpaths. If neither of them are built, because building tools might be disabled, skip building the library as well. Task-number: QTBUG-127334 Change-Id: I0f7d5bc9d9a4539a6d25f7c2d841e9b8978a83a3 Reviewed-by: Alexey Edelev (cherry picked from commit 82b2c51c3aec148c890d732978ca4a881e5c6f82) Reviewed-by: Qt Cherry-pick Bot --- qmake/CMakeLists.txt | 84 +++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/qmake/CMakeLists.txt b/qmake/CMakeLists.txt index 28c91af6d31..9334ca72ab8 100644 --- a/qmake/CMakeLists.txt +++ b/qmake/CMakeLists.txt @@ -8,48 +8,57 @@ ##################################################################### # The common object library, that should be available regardless of the presence of qmake. -qt_add_library(QtLibraryInfo OBJECT - library/proitems.cpp library/proitems.h - library/qmake_global.h - property.cpp property.h - propertyprinter.cpp propertyprinter.h - qmakelibraryinfo.cpp qmakelibraryinfo.h -) -qt_internal_add_sbom(QtLibraryInfo - TYPE QT_MODULE - NO_INSTALL -) +if(QT_WILL_BUILD_TOOLS) + qt_add_library(QtLibraryInfo OBJECT + library/proitems.cpp library/proitems.h + library/qmake_global.h + property.cpp property.h + propertyprinter.cpp propertyprinter.h + qmakelibraryinfo.cpp qmakelibraryinfo.h + ) + qt_internal_add_sbom(QtLibraryInfo + TYPE QT_MODULE + NO_INSTALL + ) -# Make sure we use same parameters when building QtLibraryInfo and other Qt libraries, -# otherwise some compilers may have compilation errors, such as clang-cl. -target_link_libraries(QtLibraryInfo PUBLIC PlatformCommonInternal) + # Make sure we use same parameters when building QtLibraryInfo and other Qt libraries, + # otherwise some compilers may have compilation errors, such as clang-cl. + target_link_libraries(QtLibraryInfo PUBLIC PlatformCommonInternal) -target_link_libraries(QtLibraryInfo PUBLIC Qt::CorePrivate) + target_link_libraries(QtLibraryInfo PUBLIC Qt::CorePrivate) -qt_internal_add_sync_header_dependencies(QtLibraryInfo Core) + qt_internal_add_sync_header_dependencies(QtLibraryInfo Core) -target_include_directories(QtLibraryInfo PUBLIC - "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}/library" -) + target_include_directories(QtLibraryInfo PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/library" + ) -# Chop off the "/mkspecs" part of INSTALL_MKSPECSDIR -get_filename_component(hostdatadir "${INSTALL_MKSPECSDIR}" DIRECTORY) -if("${hostdatadir}" STREQUAL "") - set(hostdatadir ".") + # Chop off the "/mkspecs" part of INSTALL_MKSPECSDIR + get_filename_component(hostdatadir "${INSTALL_MKSPECSDIR}" DIRECTORY) + if("${hostdatadir}" STREQUAL "") + set(hostdatadir ".") + endif() + + target_compile_definitions(QtLibraryInfo PUBLIC + PROEVALUATOR_FULL + QT_BUILD_QMAKE + QT_USE_QSTRINGBUILDER + QT_HOST_MKSPEC="${QT_QMAKE_HOST_MKSPEC}" + QT_TARGET_MKSPEC="${QT_QMAKE_TARGET_MKSPEC}" + QT_HOST_DATADIR="${hostdatadir}" + ) + + qt_internal_set_exceptions_flags(QtLibraryInfo OFF) + + # Add QMAKE_VERSION_STR only if qmake is part of the build. + if(QT_FEATURE_qmake) + target_compile_definitions(QtLibraryInfo PUBLIC + QMAKE_VERSION_STR="3.1" + ) + endif() endif() -target_compile_definitions(QtLibraryInfo PUBLIC - PROEVALUATOR_FULL - QT_BUILD_QMAKE - QT_USE_QSTRINGBUILDER - QT_HOST_MKSPEC="${QT_QMAKE_HOST_MKSPEC}" - QT_TARGET_MKSPEC="${QT_QMAKE_TARGET_MKSPEC}" - QT_HOST_DATADIR="${hostdatadir}" -) - -qt_internal_set_exceptions_flags(QtLibraryInfo OFF) - if(NOT QT_FEATURE_qmake) return() endif() @@ -118,11 +127,6 @@ qt_internal_add_docs(qmake qt_internal_return_unless_building_tools() -# Add QMAKE_VERSION_STR only if qmake is part of the build. -target_compile_definitions(QtLibraryInfo PUBLIC - QMAKE_VERSION_STR="3.1" -) - #### Keys ignored in scope 1:.:.:qmake.pro:: # _OPTION = "host_build"