CMake: Support configure tests of type 'compilerSupportsFlag'
Task-number: QTBUG-86155 Change-Id: Iaa5c48b6508870a0f6afdf9df66cd2e634fe19b3 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
45d3c75ab6
commit
df28355981
@ -1,4 +1,5 @@
|
|||||||
include(QtFeatureCommon)
|
include(QtFeatureCommon)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
function(qt_feature_module_begin)
|
function(qt_feature_module_begin)
|
||||||
qt_parse_all_arguments(arg "qt_feature_module_begin"
|
qt_parse_all_arguments(arg "qt_feature_module_begin"
|
||||||
@ -870,6 +871,16 @@ function(qt_config_compile_test_machine_tuple label)
|
|||||||
set(TEST_machine_tuple "${output}" CACHE INTERNAL "${label}")
|
set(TEST_machine_tuple "${output}" CACHE INTERNAL "${label}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(qt_config_compiler_supports_flag_test name)
|
||||||
|
if(DEFINED "TEST_${name}")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
cmake_parse_arguments(arg "" "LABEL;FLAG" "" ${ARGN})
|
||||||
|
check_cxx_compiler_flag("${arg_FLAG}" TEST_${name})
|
||||||
|
set(TEST_${name} "${TEST_${name}}" CACHE INTERNAL "${label}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
function(qt_make_features_available target)
|
function(qt_make_features_available target)
|
||||||
if(NOT "${target}" MATCHES "^${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*$")
|
if(NOT "${target}" MATCHES "^${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*$")
|
||||||
message(FATAL_ERROR "${target} does not match ${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*. INVALID NAME.")
|
message(FATAL_ERROR "${target} does not match ${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*. INVALID NAME.")
|
||||||
|
@ -96,6 +96,7 @@ defstub(qt_add_qmake_lib_dependency)
|
|||||||
defstub(qt_config_compile_test)
|
defstub(qt_config_compile_test)
|
||||||
defstub(qt_config_compile_test_machine_tuple)
|
defstub(qt_config_compile_test_machine_tuple)
|
||||||
defstub(qt_config_compile_test_x86simd)
|
defstub(qt_config_compile_test_x86simd)
|
||||||
|
defstub(qt_config_compiler_supports_flag_test)
|
||||||
defstub(qt_configure_add_report_entry)
|
defstub(qt_configure_add_report_entry)
|
||||||
defstub(qt_configure_add_summary_build_mode)
|
defstub(qt_configure_add_summary_build_mode)
|
||||||
defstub(qt_configure_add_summary_build_parts)
|
defstub(qt_configure_add_summary_build_parts)
|
||||||
|
@ -110,6 +110,26 @@ int main(int argc, char **argv)
|
|||||||
"# FIXME: qmake: ['CONFIG += precompile_header', 'PRECOMPILED_DIR = .pch', 'PRECOMPILED_HEADER = header.h']
|
"# FIXME: qmake: ['CONFIG += precompile_header', 'PRECOMPILED_DIR = .pch', 'PRECOMPILED_HEADER = header.h']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt_config_compiler_supports_flag_test(use_bfd_linker
|
||||||
|
LABEL "bfd linker"
|
||||||
|
FLAG "-fuse-ld=bfd"
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_config_compiler_supports_flag_test(use_gold_linker
|
||||||
|
LABEL "gold linker"
|
||||||
|
FLAG "-fuse-ld=gold"
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_config_compiler_supports_flag_test(use_lld_linker
|
||||||
|
LABEL "lld linker"
|
||||||
|
FLAG "-fuse-ld=lld"
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_config_compiler_supports_flag_test(optimize_debug
|
||||||
|
LABEL "-Og support"
|
||||||
|
FLAG "-Og"
|
||||||
|
)
|
||||||
|
|
||||||
# reduce_relocations
|
# reduce_relocations
|
||||||
qt_config_compile_test(reduce_relocations
|
qt_config_compile_test(reduce_relocations
|
||||||
LABEL "-Bsymbolic-functions support"
|
LABEL "-Bsymbolic-functions support"
|
||||||
@ -364,19 +384,19 @@ qt_feature("gc_binaries" PRIVATE
|
|||||||
qt_feature("use_bfd_linker"
|
qt_feature("use_bfd_linker"
|
||||||
LABEL "bfd"
|
LABEL "bfd"
|
||||||
AUTODETECT false
|
AUTODETECT false
|
||||||
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND tests.use_bfd_linker OR FIXME
|
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_bfd_linker
|
||||||
ENABLE INPUT_linker STREQUAL 'bfd'
|
ENABLE INPUT_linker STREQUAL 'bfd'
|
||||||
DISABLE INPUT_linker STREQUAL 'gold' OR INPUT_linker STREQUAL 'lld'
|
DISABLE INPUT_linker STREQUAL 'gold' OR INPUT_linker STREQUAL 'lld'
|
||||||
)
|
)
|
||||||
qt_feature_config("use_bfd_linker" QMAKE_PRIVATE_CONFIG)
|
qt_feature_config("use_bfd_linker" QMAKE_PRIVATE_CONFIG)
|
||||||
qt_feature("use_gold_linker_alias"
|
qt_feature("use_gold_linker_alias"
|
||||||
AUTODETECT false
|
AUTODETECT false
|
||||||
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND tests.use_gold_linker OR FIXME
|
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_gold_linker
|
||||||
)
|
)
|
||||||
qt_feature("use_lld_linker"
|
qt_feature("use_lld_linker"
|
||||||
LABEL "lld"
|
LABEL "lld"
|
||||||
AUTODETECT false
|
AUTODETECT false
|
||||||
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND tests.use_lld_linker OR FIXME
|
CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_lld_linker
|
||||||
ENABLE INPUT_linker STREQUAL 'lld'
|
ENABLE INPUT_linker STREQUAL 'lld'
|
||||||
DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold'
|
DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold'
|
||||||
)
|
)
|
||||||
|
@ -768,6 +768,15 @@ def write_compile_test(
|
|||||||
# "qmake": "unix:LIBS += -lpthread"
|
# "qmake": "unix:LIBS += -lpthread"
|
||||||
# }
|
# }
|
||||||
# },
|
# },
|
||||||
|
|
||||||
|
def write_compiler_supports_flag_test(
|
||||||
|
ctx, name, details, data, cm_fh, manual_library_list=None, is_library_test=False
|
||||||
|
):
|
||||||
|
cm_fh.write(f"qt_config_compiler_supports_flag_test({featureName(name)}\n")
|
||||||
|
cm_fh.write(lineify("LABEL", data.get("label", "")))
|
||||||
|
cm_fh.write(lineify("FLAG", data.get("flag", "")))
|
||||||
|
cm_fh.write(")\n\n")
|
||||||
|
|
||||||
def parseTest(ctx, test, data, cm_fh):
|
def parseTest(ctx, test, data, cm_fh):
|
||||||
skip_tests = {
|
skip_tests = {
|
||||||
"c11",
|
"c11",
|
||||||
@ -795,6 +804,16 @@ def parseTest(ctx, test, data, cm_fh):
|
|||||||
|
|
||||||
write_compile_test(ctx, test, details, data, cm_fh)
|
write_compile_test(ctx, test, details, data, cm_fh)
|
||||||
|
|
||||||
|
if data["type"] == "compilerSupportsFlag":
|
||||||
|
knownTests.add(test)
|
||||||
|
|
||||||
|
if "test" in data:
|
||||||
|
details = data["test"]
|
||||||
|
else:
|
||||||
|
details = test
|
||||||
|
|
||||||
|
write_compiler_supports_flag_test(ctx, test, details, data, cm_fh)
|
||||||
|
|
||||||
elif data["type"] == "libclang":
|
elif data["type"] == "libclang":
|
||||||
knownTests.add(test)
|
knownTests.add(test)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user