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
$<$<COMPILE_LANGUAGE:OBJCXX> will work for these files as well.

Pick-to: 6.5 6.2
Change-Id: If295c3f34f6bee9f4d9f877f519c9c7770665fee
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-04-13 14:10:16 +02:00
parent d953bc76bb
commit 06499383ca
4 changed files with 4 additions and 4 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()