diff --git a/cmake/QtBuildOptionsHelpers.cmake b/cmake/QtBuildOptionsHelpers.cmake index 8a14060e5e4..1d5002bfd18 100644 --- a/cmake/QtBuildOptionsHelpers.cmake +++ b/cmake/QtBuildOptionsHelpers.cmake @@ -10,9 +10,11 @@ macro(qt_internal_set_default_build_type) # Try to detect if an explicit CMAKE_BUILD_TYPE was set by the user. # CMake sets CMAKE_BUILD_TYPE_INIT to Debug on most Windows platforms and doesn't set # anything for UNIXes. CMake assigns CMAKE_BUILD_TYPE_INIT to CMAKE_BUILD_TYPE during - # first project() if CMAKE_BUILD_TYPE has no previous value. + # the first project() call, if CMAKE_BUILD_TYPE had no previous value. # We use extra information about the state of CMAKE_BUILD_TYPE before the first - # project() call that's set in QtAutodetect. + # project() call that's set in QtAutoDetect.cmake or manually in a project via the + # __qt_internal_standalone_project_cmake_build_type_before_project_call variable (as done + # for the qtbase sqldrivers project). # STREQUAL check needs to have expanded variables because an undefined var is not equal # to an empty defined var. # See also qt_internal_force_set_cmake_build_type_conditionally which is used @@ -20,6 +22,7 @@ macro(qt_internal_set_default_build_type) if("${CMAKE_BUILD_TYPE}" STREQUAL "${CMAKE_BUILD_TYPE_INIT}" AND NOT __qt_auto_detect_cmake_build_type_before_project_call AND NOT __qt_build_internals_cmake_build_type + AND NOT __qt_internal_standalone_project_cmake_build_type_before_project_call AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${_default_build_type}' as none was specified.") set(CMAKE_BUILD_TYPE "${_default_build_type}" CACHE STRING "Choose the type of build." FORCE) diff --git a/src/plugins/sqldrivers/CMakeLists.txt b/src/plugins/sqldrivers/CMakeLists.txt index 7f44072da05..e3254a762de 100644 --- a/src/plugins/sqldrivers/CMakeLists.txt +++ b/src/plugins/sqldrivers/CMakeLists.txt @@ -4,6 +4,14 @@ cmake_minimum_required(VERSION 3.16) if (NOT CMAKE_PROJECT_NAME STREQUAL "QtBase" AND NOT CMAKE_PROJECT_NAME STREQUAL "Qt") include(.cmake.conf) + # Store initial build type (if any is specified) to be read by + # qt_internal_set_default_build_type(). + # See qt_internal_set_default_build_type() for details. + if(DEFINED CACHE{CMAKE_BUILD_TYPE}) + set(__qt_internal_standalone_project_cmake_build_type_before_project_call + "${CMAKE_BUILD_TYPE}") + endif() + project(QSQLiteDriverPlugins VERSION "${QT_REPO_MODULE_VERSION}" DESCRIPTION "Qt6 SQL driver plugins"