mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 16:55:25 +08:00
qt 6.5.1 original
This commit is contained in:
51
cmake/tests/CMakeLists.txt
Normal file
51
cmake/tests/CMakeLists.txt
Normal file
@ -0,0 +1,51 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# These macros are inspired by ECM:
|
||||
|
||||
# a macro for tests that have a simple format where the name matches the
|
||||
# directory and project
|
||||
|
||||
# The following macros will produce tests that generate the build
|
||||
# system for the test project, build it and then run its tests.
|
||||
macro(add_cmake_test_generate_build_run_variant name base command)
|
||||
string(REPLACE "." "/" src_dir "${base}")
|
||||
string(REPLACE "." "/" build_dir "${name}")
|
||||
string(REGEX REPLACE "[^.]*\\." "" proj "${name}")
|
||||
add_test(NAME "cmake_${name}"
|
||||
COMMAND ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${build_dir}"
|
||||
--build-two-config
|
||||
--build-generator ${CMAKE_GENERATOR}
|
||||
--build-makeprogram ${CMAKE_MAKE_PROGRAM}
|
||||
--build-project ${proj}
|
||||
${${name}_EXTRA_OPTIONS}
|
||||
--test-command ${command} ${ARGN})
|
||||
endmacro()
|
||||
|
||||
macro(add_cmake_test_generate_build_run name)
|
||||
add_cmake_test_generate_build_run_variant("${name}" "${name}" ${ARGN})
|
||||
endmacro()
|
||||
|
||||
# The following macros will produce tests that just run cmake
|
||||
# to generate the build system for the test project.
|
||||
macro(add_cmake_test_generate_variant name base)
|
||||
string(REPLACE "." "/" src_dir "${base}")
|
||||
string(REPLACE "." "/" build_dir "${name}")
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}")
|
||||
add_test(NAME "cmake_${name}"
|
||||
COMMAND "${CMAKE_COMMAND}" "-G${CMAKE_GENERATOR}"
|
||||
"-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
|
||||
${${name}_EXTRA_OPTIONS}
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${src_dir}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${build_dir}")
|
||||
endmacro()
|
||||
|
||||
macro(add_cmake_test_generate name)
|
||||
add_cmake_test_generate_variant("${name}" "${name}")
|
||||
endmacro()
|
||||
|
||||
add_cmake_test_generate(features)
|
||||
add_cmake_test_generate(qt_make_output_file)
|
0
cmake/tests/empty.cpp
Normal file
0
cmake/tests/empty.cpp
Normal file
45
cmake/tests/features/CMakeLists.txt
Normal file
45
cmake/tests/features/CMakeLists.txt
Normal file
@ -0,0 +1,45 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(FeaturesTest
|
||||
VERSION 1.0.0
|
||||
DESCRIPTION "QtFeature test"
|
||||
HOMEPAGE_URL "https://qt.io/"
|
||||
LANGUAGES CXX C
|
||||
)
|
||||
|
||||
## Add some paths to check for cmake modules:
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/extra-cmake-modules/find-modules;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/kwin")
|
||||
|
||||
## Qt specific setup common for all modules:
|
||||
include(QtSetup)
|
||||
|
||||
## Library to hold global features:
|
||||
add_library(GlobalConfig INTERFACE)
|
||||
|
||||
qt_feature_module_begin(LIBRARY GlobalConfig
|
||||
PUBLIC_FILE src/corelib/global/qconfig.h
|
||||
PRIVATE_FILE src/corelib/global/qconfig_p.h
|
||||
)
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake")
|
||||
qt_feature_module_end(GlobalConfig)
|
||||
|
||||
assert(QT_FEATURE_top_a STREQUAL "ON")
|
||||
assert(QT_FEATURE_top_b STREQUAL "OFF")
|
||||
assert(QT_FEATURE_top_enabled STREQUAL "ON")
|
||||
assert(QT_FEATURE_top_disabled STREQUAL "OFF")
|
||||
assert(QT_FEATURE_top_disabled_enabled STREQUAL "OFF")
|
||||
assert(QT_FEATURE_top_not_emitted STREQUAL "OFF")
|
||||
|
||||
## Enable feature summary at the end of the configure run:
|
||||
include(FeatureSummary)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
## Delayed actions on some of the Qt targets:
|
||||
include(QtPostProcess)
|
||||
|
||||
## Print a feature summary:
|
||||
feature_summary(WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
|
38
cmake/tests/features/configure.cmake
Normal file
38
cmake/tests/features/configure.cmake
Normal file
@ -0,0 +1,38 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#### Features
|
||||
|
||||
# This belongs into gui, but the license check needs it here already.
|
||||
qt_feature("top_a" PRIVATE
|
||||
LABEL "top_a"
|
||||
CONDITION ON
|
||||
)
|
||||
qt_feature("top_b" PUBLIC PRIVATE
|
||||
LABEL "top_b"
|
||||
AUTODETECT OFF
|
||||
)
|
||||
qt_feature_definition("top_a" "top_defa")
|
||||
|
||||
qt_feature("top_enabled" PRIVATE
|
||||
LABEL "top_enabled"
|
||||
ENABLE ON
|
||||
)
|
||||
|
||||
qt_feature("top_disabled" PRIVATE
|
||||
LABEL "top_enabled"
|
||||
DISABLE ON
|
||||
)
|
||||
|
||||
qt_feature("top_disabled_enabled" PRIVATE
|
||||
LABEL "top_enabled_enabled"
|
||||
DISABLE ON
|
||||
ENABLE ON
|
||||
)
|
||||
|
||||
qt_feature("top_not_emitted" PRIVATE
|
||||
LABEL "top_not_emitted"
|
||||
EMIT_IF OFF
|
||||
)
|
||||
|
||||
qt_extra_definition("top_extra" "PUBLIC_FOO" PUBLIC)
|
10
cmake/tests/features/src/CMakeLists.txt
Normal file
10
cmake/tests/features/src/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
## Features from parent scope were inherited:
|
||||
assert(QT_FEATURE_top_a STREQUAL "ON")
|
||||
assert(QT_FEATURE_top_b STREQUAL "OFF")
|
||||
assert(QT_FEATURE_top_enabled STREQUAL "ON")
|
||||
assert(QT_FEATURE_top_disabled STREQUAL "OFF")
|
||||
assert(QT_FEATURE_top_disabled_enabled STREQUAL "OFF")
|
||||
assert(QT_FEATURE_top_not_emitted STREQUAL "OFF")
|
1
cmake/tests/main.cpp
Normal file
1
cmake/tests/main.cpp
Normal file
@ -0,0 +1 @@
|
||||
int main(int argc, char** argv) { return 0; }
|
25
cmake/tests/qt_make_output_file/CMakeLists.txt
Normal file
25
cmake/tests/qt_make_output_file/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(QtMakeOutputFileTest
|
||||
VERSION 1.0.0
|
||||
DESCRIPTION "qt_make_output_file test"
|
||||
HOMEPAGE_URL "https://qt.io/"
|
||||
LANGUAGES CXX C
|
||||
)
|
||||
|
||||
## Add some paths to check for cmake modules:
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/extra-cmake-modules/find-modules;${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/kwin")
|
||||
|
||||
include(QtBuild)
|
||||
|
||||
qt_make_output_file("foo.cpp" "" ".mapped" "/tmp/foo" "/tmp/bar" outfile)
|
||||
assert(outfile STREQUAL "/tmp/bar/foo.mapped")
|
||||
|
||||
qt_make_output_file("../foo.cpp" "prefix_" ".cpp" "/tmp/foo" "/tmp/bar" outfile)
|
||||
assert(outfile STREQUAL "/tmp/bar/__/prefix_foo.cpp")
|
||||
|
||||
qt_make_output_file("/tmp/bar/foo.cpp" "prefix_" ".cpp" "/tmp/foo" "/tmp/bar" outfile)
|
||||
assert(outfile STREQUAL "/tmp/bar/prefix_foo.cpp")
|
57
cmake/tests/test.cmake
Normal file
57
cmake/tests/test.cmake
Normal file
@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# FAKE moc-ing:
|
||||
set(QT_MOCSCANNER /usr/bin/true)
|
||||
|
||||
# Fake mocscanner run.
|
||||
# The files passed in after MOC will be reported to be in need of moc-ing,
|
||||
# but will not be built.
|
||||
# The files passed in after MOC_AND_BUILD will be reported to be in need
|
||||
# of moc-ing and should also be built by the target.
|
||||
function(fake_moc_results)
|
||||
cmake_parse_arguments(arg "" "" "MOC;MOC_AND_BUILD" ${ARGN})
|
||||
|
||||
string(REPLACE ";" "\n" arg_MOC "${arg_MOC}")
|
||||
string(REPLACE ";" "\n" arg_MOC_AND_BUILD "${arg_MOC_AND_BUILD}")
|
||||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/moc_files_included.txt" "${arg_MOC}")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/moc_files_to_build.txt" "${arg_MOC_AND_BUILD}")
|
||||
endfunction()
|
||||
|
||||
# Test whether a target has a file listed in its sources.
|
||||
# Tests with the BUILD flag set will require this file to be built,
|
||||
# while those without will require the file to not be built by
|
||||
# the target.
|
||||
function(test_source_file target file)
|
||||
cmake_parse_arguments(arg "BUILD" "" "" ${ARGN})
|
||||
|
||||
get_target_property(sources "${target}" SOURCES)
|
||||
list(FIND sources "${file}" source_pos)
|
||||
assert(NOT source_pos STREQUAL "-1")
|
||||
|
||||
get_source_file_property(prop "${file}" HEADER_FILE_ONLY)
|
||||
if (arg_BUILD)
|
||||
assert(NOT prop)
|
||||
else()
|
||||
assert(prop)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Test whether or not a target uses a header path
|
||||
# The test passes when the path is in the list of include directories.
|
||||
# Passing 'UNKNOWN' to this function reverses the test result.
|
||||
function(test_include_directory target path)
|
||||
cmake_parse_arguments(arg "UNKNOWN" "" "" ${ARGN})
|
||||
get_target_property(includes "${target}" INCLUDE_DIRECTORIES)
|
||||
list(FIND includes "${path}" include_pos)
|
||||
if(arg_UNKNOWN)
|
||||
assert(include_pos STREQUAL "-1")
|
||||
else()
|
||||
assert(NOT include_pos STREQUAL "-1")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Add Core and Qt::Core libraries:
|
||||
add_library(Core SHARED "${CMAKE_CURRENT_LIST_DIR}/empty.cpp")
|
||||
add_library(Qt::Core ALIAS Core)
|
Reference in New Issue
Block a user