From 06499383ca1628c1ceeb4b2b786299093372de1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 13 Apr 2023 14:10:16 +0200 Subject: [PATCH] Use LANGUAGE OBJCXX rather than COMPILE_FLAGS "-x objective-c++" We sometimes use Objective-C++ code in files with a .cpp extension, to avoid the churn of adding a foo_mac.mm file. Instead of manually telling the compiler to build these files in Objective-C++ mode, we use CMake's intended mechanism, which means genex constructs such as $<$ will work for these files as well. Pick-to: 6.5 6.2 Change-Id: If295c3f34f6bee9f4d9f877f519c9c7770665fee Reviewed-by: Alexandru Croitor Reviewed-by: Timur Pocheptsov --- src/widgets/CMakeLists.txt | 2 +- tests/auto/corelib/io/qdebug/CMakeLists.txt | 2 +- tests/auto/corelib/io/qfileinfo/CMakeLists.txt | 2 +- tests/auto/gui/kernel/qwindow/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 39c197eeba4..aaa81286abe 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -693,7 +693,7 @@ if(QT_FEATURE_wizard) if(APPLE) set_source_files_properties(dialogs/qwizard.cpp PROPERTIES - COMPILE_FLAGS "-x objective-c++" + LANGUAGE OBJCXX SKIP_PRECOMPILE_HEADERS ON ) endif() diff --git a/tests/auto/corelib/io/qdebug/CMakeLists.txt b/tests/auto/corelib/io/qdebug/CMakeLists.txt index cef57a2186f..c9fd9c6df84 100644 --- a/tests/auto/corelib/io/qdebug/CMakeLists.txt +++ b/tests/auto/corelib/io/qdebug/CMakeLists.txt @@ -13,5 +13,5 @@ qt_internal_add_test(tst_qdebug ) if (APPLE) - target_compile_options(tst_qdebug PRIVATE -x objective-c++) + set_source_files_properties(tst_qdebug.cpp PROPERTIES LANGUAGE OBJCXX) endif() diff --git a/tests/auto/corelib/io/qfileinfo/CMakeLists.txt b/tests/auto/corelib/io/qfileinfo/CMakeLists.txt index 5fdc764e8a3..4da51ce219b 100644 --- a/tests/auto/corelib/io/qfileinfo/CMakeLists.txt +++ b/tests/auto/corelib/io/qfileinfo/CMakeLists.txt @@ -48,5 +48,5 @@ qt_internal_extend_target(tst_qfileinfo CONDITION WIN32 ) if (APPLE) - target_compile_options(tst_qfileinfo PRIVATE -x objective-c++) + set_source_files_properties(tst_qfileinfo.cpp PROPERTIES LANGUAGE OBJCXX) endif() diff --git a/tests/auto/gui/kernel/qwindow/CMakeLists.txt b/tests/auto/gui/kernel/qwindow/CMakeLists.txt index 605761622fd..5ddda80c2a1 100644 --- a/tests/auto/gui/kernel/qwindow/CMakeLists.txt +++ b/tests/auto/gui/kernel/qwindow/CMakeLists.txt @@ -25,7 +25,7 @@ if(APPLE OR WIN32) ) if(APPLE) - target_compile_options(tst_foreignwindow PRIVATE -x objective-c++) + set_source_files_properties(tst_foreignwindow.cpp PROPERTIES LANGUAGE OBJCXX) set_property(TARGET tst_foreignwindow PROPERTY PROPERTY MACOSX_BUNDLE TRUE) endif() endif()