diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-12-14 09:38:29 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-12-14 21:08:09 +0000 |
commit | dad004f0431de5519844238b9cde70083bab012f (patch) | |
tree | 848384a59b63a27c6f1a0a53749ad830b2fe706c /cmake | |
parent | 5ede0316c9377e82288cbc0dc5bff5a7e7e75ef8 (diff) |
Support configure -platform linux-clang-libc++
Detect libc++ config and add appropriate compiler and linker flags.
Change-Id: I9ec91b3ace987599d4e79e43b1b75aa67cd5caeb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit f370a4c49c686a54325efc5499449da8cdc4056e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtFeature.cmake | 14 | ||||
-rw-r--r-- | cmake/QtPlatformTargetHelpers.cmake | 5 | ||||
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 3 |
3 files changed, 22 insertions, 0 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index c5e882649c..09a1c8361c 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -943,6 +943,11 @@ function(qt_config_compile_test name) set(CMAKE_REQUIRED_FLAGS ${arg_COMPILE_OPTIONS}) + # Pass -stdlib=libc++ on if necessary + if (INPUT_stdlib_libcpp OR QT_FEATURE_stdlib_libcpp) + list(APPEND CMAKE_REQUIRED_FLAGS "-stdlib=libc++") + endif() + # For MSVC we need to explicitly pass -Zc:__cplusplus to get correct __cplusplus # define values. According to common/msvc-version.conf the flag is supported starting # with 1913. @@ -1003,6 +1008,15 @@ function(qt_get_platform_try_compile_vars out_var) list(APPEND flags "CMAKE_C_STANDARD") list(APPEND flags "CMAKE_CXX_STANDARD") + # Pass -stdlib=libc++ on if necessary + if (INPUT_stdlib_libcpp OR QT_FEATURE_stdlib_libcpp) + if(CMAKE_CXX_FLAGS) + string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++") + else() + set(CMAKE_CXX_FLAGS "-stdlib=libc++") + endif() + endif() + # Assemble the list with regular options. set(flags_cmd_line "") foreach(flag ${flags}) diff --git a/cmake/QtPlatformTargetHelpers.cmake b/cmake/QtPlatformTargetHelpers.cmake index 9c95c0883f..49bc558cec 100644 --- a/cmake/QtPlatformTargetHelpers.cmake +++ b/cmake/QtPlatformTargetHelpers.cmake @@ -26,6 +26,11 @@ function(qt_internal_setup_public_platform_target) target_link_libraries(Platform INTERFACE log) endif() + if (QT_FEATURE_stdlib_libcpp) + target_compile_options(Platform INTERFACE "-stdlib=libc++") + target_link_options(Platform INTERFACE "-stdlib=libc++") + endif() + qt_set_msvc_cplusplus_options(Platform INTERFACE) # Propagate minimum C++ 17 via Platform to Qt consumers (apps), after the global features diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 3c730d9444..6342df93bd 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -733,6 +733,9 @@ function(guess_compiler_from_mkspec) if(guess_cxx_compiler AND NOT cxx_compiler STREQUAL "") push("-DCMAKE_CXX_COMPILER=${cxx_compiler}") endif() + if(mkspec MATCHES "-libc\\+\\+$") + push("-DINPUT_stdlib_libcpp=ON") + endif() set(cmake_args "${cmake_args}" PARENT_SCOPE) endfunction() |