Use the qt_build_repo() macros for building qtbase as well
To implement this, create a new Qt5BuildInternals package. All child Qt modules like qtsvg should use find_package(Qt5BuildInternals) or find_package(Qt5 COMPONENTS BuildInternals) in the their top level CMakeLists.txt. This will make the qt_build_repo() macros available. For qtbase we slightly cheat, and specify a CMAKE_PREFIX_PATH pointing to the source folder that contains the BuildInternals package. For the other modules we actually use a configured and installed package Config file. This change moves variables that used to be written into the QtCore Config file into the BuildInternals package. This way things that are relevant only for building additional Qt modules does not pollute the QtCore package. Task-number: QTBUG-75580 Change-Id: I5479adff2f7903c9c2862d28c05c7f485ce3e4eb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
c097256ee4
commit
9542e78525
@ -14,11 +14,13 @@ list(APPEND CMAKE_MODULE_PATH
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/3rdparty/kwin"
|
||||
)
|
||||
|
||||
## Qt specific setup common for all modules:
|
||||
include(QtSetup)
|
||||
## Find the build internals package.
|
||||
list(APPEND CMAKE_PREFIX_PATH
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
||||
)
|
||||
find_package(QtBuildInternals)
|
||||
|
||||
## Enable feature summary at the end of the configure run:
|
||||
include(FeatureSummary)
|
||||
qt_build_repo_begin(SKIP_CMAKE_MODULE_PATH_ADDITION)
|
||||
|
||||
## QtBase specific configure tests:
|
||||
include(QtBaseConfigureTests)
|
||||
@ -52,13 +54,4 @@ if (BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
## Delayed actions on some of the Qt targets:
|
||||
include(QtPostProcess)
|
||||
|
||||
## Print a feature summary:
|
||||
feature_summary(WHAT PACKAGES_FOUND
|
||||
REQUIRED_PACKAGES_NOT_FOUND
|
||||
RECOMMENDED_PACKAGES_NOT_FOUND
|
||||
OPTIONAL_PACKAGES_NOT_FOUND
|
||||
RUNTIME_PACKAGES_NOT_FOUND
|
||||
FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
qt_build_repo_end()
|
||||
|
@ -122,3 +122,21 @@ qt_copy_or_install(DIRECTORY cmake/
|
||||
PATTERN "tests" EXCLUDE
|
||||
PATTERN "3rdparty" EXCLUDE
|
||||
)
|
||||
|
||||
# Configure and install the QtBuildInternals package.
|
||||
set(__build_internals_path_suffix "${INSTALL_CMAKE_NAMESPACE}BuildInternals")
|
||||
qt_path_join(__build_internals_build_dir ${QT_CONFIG_BUILD_DIR} ${__build_internals_path_suffix})
|
||||
qt_path_join(__build_internals_install_dir ${QT_CONFIG_INSTALL_DIR}
|
||||
${__build_internals_path_suffix})
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake"
|
||||
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
qt_install(FILES
|
||||
"${__build_internals_build_dir}/${INSTALL_CMAKE_NAMESPACE}BuildInternalsConfig.cmake"
|
||||
"${__build_internals_build_dir}/QtBuildInternalsExtra.cmake"
|
||||
DESTINATION "${__build_internals_install_dir}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
|
@ -160,6 +160,10 @@ endif()
|
||||
string(APPEND QT_CONFIG_INSTALL_DIR ${__config_path_part})
|
||||
unset(__config_path_part)
|
||||
|
||||
# This is used to hold extra cmake code that should be put into QtBuildInternalsExtra.cmake file
|
||||
# at the QtPostProcess stage.
|
||||
set(QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "")
|
||||
|
||||
# Functions and macros:
|
||||
|
||||
# Wraps install() command. In a prefix build, simply passes along arguments to install().
|
||||
@ -926,25 +930,6 @@ function(add_qt_module target)
|
||||
list(APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake")
|
||||
endif()
|
||||
|
||||
set(extra_cmake_code "")
|
||||
|
||||
if(target STREQUAL Core)
|
||||
# Propagate common variables via QtCore package.
|
||||
string(APPEND extra_cmake_code "set(QT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})")
|
||||
string(APPEND extra_cmake_code "
|
||||
option(BUILD_SHARED_LIBS \"Build Qt statically or dynamically\" ${BUILD_SHARED_LIBS})")
|
||||
string(APPEND extra_cmake_code "
|
||||
set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})")
|
||||
string(APPEND extra_cmake_code "
|
||||
set(_qt_core_cmake_dir \${CMAKE_CURRENT_LIST_DIR})")
|
||||
|
||||
# Propagate developer builds to other modules via QtCore package.
|
||||
if(FEATURE_developer_build)
|
||||
string(APPEND extra_cmake_code "
|
||||
set(FEATURE_developer_build ON CACHE BOOL \"Developer build.\" FORCE)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
configure_package_config_file(
|
||||
"${QT_CMAKE_DIR}/QtModuleConfig.cmake.in"
|
||||
"${config_build_dir}/${INSTALL_CMAKE_NAMESPACE}${target}Config.cmake"
|
||||
|
40
cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
Normal file
40
cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
Normal file
@ -0,0 +1,40 @@
|
||||
if (CMAKE_VERSION VERSION_LESS 3.1.0)
|
||||
message(FATAL_ERROR "Qt requires at least CMake version 3.1.0")
|
||||
endif()
|
||||
|
||||
######################################
|
||||
#
|
||||
# Macros for building Qt modules
|
||||
#
|
||||
######################################
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake")
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/QtBuildInternalsExtra.cmake)
|
||||
endif()
|
||||
|
||||
macro(qt_build_repo_begin)
|
||||
if(${ARGC} EQUAL 1 AND "${ARGV0}" STREQUAL "SKIP_CMAKE_MODULE_PATH_ADDITION")
|
||||
# No-op.
|
||||
else()
|
||||
# Set up the paths for the modules.
|
||||
set(QT_CMAKE_MODULE_PATH "${QT_BUILD_INTERNALS_PATH}/../${QT_CMAKE_EXPORT_NAMESPACE}")
|
||||
list(APPEND CMAKE_MODULE_PATH ${QT_CMAKE_MODULE_PATH})
|
||||
endif()
|
||||
|
||||
# Qt specific setup common for all modules:
|
||||
include(QtSetup)
|
||||
include(FeatureSummary)
|
||||
endmacro()
|
||||
|
||||
macro(qt_build_repo_end)
|
||||
# Delayed actions on some of the Qt targets:
|
||||
include(QtPostProcess)
|
||||
|
||||
# Print a feature summary:
|
||||
feature_summary(WHAT PACKAGES_FOUND
|
||||
REQUIRED_PACKAGES_NOT_FOUND
|
||||
RECOMMENDED_PACKAGES_NOT_FOUND
|
||||
OPTIONAL_PACKAGES_NOT_FOUND
|
||||
RUNTIME_PACKAGES_NOT_FOUND
|
||||
FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
endmacro()
|
@ -5,10 +5,6 @@ include(CMakeFindDependencyMacro)
|
||||
get_filename_component(_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component(_import_prefix "${_import_prefix}" REALPATH)
|
||||
|
||||
# Extra cmake code begin
|
||||
@extra_cmake_code@
|
||||
# Extra cmake code end
|
||||
|
||||
# Find required dependencies, if any.
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
|
||||
|
@ -164,4 +164,31 @@ function(qt_internal_create_depends_files)
|
||||
|
||||
endfunction()
|
||||
|
||||
function(qt_generate_build_internals_extra_cmake_code)
|
||||
if(PROJECT_NAME STREQUAL "QtBase")
|
||||
# Propagate common variables via BuildInternals package.
|
||||
string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE
|
||||
"set(QT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})")
|
||||
string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "
|
||||
option(BUILD_SHARED_LIBS \"Build Qt statically or dynamically\" ${BUILD_SHARED_LIBS})")
|
||||
string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "
|
||||
set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})")
|
||||
string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "
|
||||
set(QT_BUILD_INTERNALS_PATH \"\${CMAKE_CURRENT_LIST_DIR}\")")
|
||||
|
||||
# Propagate developer builds to other modules via BuildInternals package.
|
||||
if(FEATURE_developer_build)
|
||||
string(APPEND QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE "
|
||||
set(FEATURE_developer_build ON CACHE BOOL \"Developer build.\" FORCE)")
|
||||
endif()
|
||||
|
||||
qt_path_join(extra_file_path
|
||||
${QT_CONFIG_BUILD_DIR}
|
||||
${INSTALL_CMAKE_NAMESPACE}BuildInternals/QtBuildInternalsExtra.cmake)
|
||||
file(GENERATE OUTPUT "${extra_file_path}"
|
||||
CONTENT "${QT_BUILD_INTERNALS_EXTRA_CMAKE_CODE}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
qt_internal_create_depends_files()
|
||||
qt_generate_build_internals_extra_cmake_code()
|
||||
|
@ -38,29 +38,6 @@
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
macro(qt_build_repo_begin)
|
||||
# Set up the paths for the modules.
|
||||
set(QT_CMAKE_MODULE_PATH "${_qt_core_cmake_dir}/../${QT_CMAKE_EXPORT_NAMESPACE}")
|
||||
list(APPEND CMAKE_MODULE_PATH ${QT_CMAKE_MODULE_PATH})
|
||||
|
||||
# Qt specific setup common for all modules:
|
||||
include(QtSetup)
|
||||
include(FeatureSummary)
|
||||
endmacro()
|
||||
|
||||
macro(qt_build_repo_end)
|
||||
# Delayed actions on some of the Qt targets:
|
||||
include(QtPostProcess)
|
||||
|
||||
# Print a feature summary:
|
||||
feature_summary(WHAT PACKAGES_FOUND
|
||||
REQUIRED_PACKAGES_NOT_FOUND
|
||||
RECOMMENDED_PACKAGES_NOT_FOUND
|
||||
OPTIONAL_PACKAGES_NOT_FOUND
|
||||
RUNTIME_PACKAGES_NOT_FOUND
|
||||
FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
||||
endmacro()
|
||||
|
||||
# macro used to create the names of output files preserving relative dirs
|
||||
macro(QT5_MAKE_OUTPUT_FILE infile prefix ext outfile )
|
||||
string(LENGTH ${CMAKE_CURRENT_BINARY_DIR} _binlength)
|
||||
|
Loading…
Reference in New Issue
Block a user