Skip to content

Commit

Permalink
CMake: remove tests for C++17 and C11 and earlier
Browse files Browse the repository at this point in the history
Qt requires them and will fail to build if it isn't met, so we don't
need to check for its support. These were public CMake and qmake
features, so to keep compatibility with existing they're hardcoded now
(only done for the C++ editions and for qmake only, as that's what Qt 5
did).

Change-Id: I7f354474adce419ca6c2fffd174814724f45f90b
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Joerg Bornemann <[email protected]>
  • Loading branch information
thiagomacieira committed Mar 21, 2023
1 parent a561d52 commit 205f8fb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 109 deletions.
87 changes: 1 addition & 86 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -204,51 +204,6 @@ endif()
# machineTuple
qt_config_compile_test_machine_tuple("machine tuple")

# cxx14
qt_config_compile_test(cxx14
LABEL "C++14 support"
CODE
"#if __cplusplus > 201103L
// Compiler claims to support C++14, trust it
#else
# error __cplusplus must be > 201103L (the value of C++11)
#endif
int main(void)
{
/* BEGIN TEST: */
/* END TEST: */
return 0;
}
"
CXX_STANDARD 14
)

# cxx17
qt_config_compile_test(cxx17
LABEL "C++17 support"
CODE
"#if __cplusplus > 201402L
// Compiler claims to support C++17, trust it
#else
# error __cplusplus must be > 201402L (the value for C++14)
#endif
#include <map> // https://bugs.llvm.org//show_bug.cgi?id=33117
#include <variant>
int main(void)
{
/* BEGIN TEST: */
std::variant<int> v(42);
int i = std::get<int>(v);
std::visit([](const auto &) { return 1; }, v);
/* END TEST: */
return 0;
}
"
CXX_STANDARD 17
)

# cxx20
qt_config_compile_test(cxx20
LABEL "C++20 support"
Expand Down Expand Up @@ -660,29 +615,10 @@ qt_feature_config("plugin-manifests" QMAKE_PUBLIC_CONFIG
NEGATE
NAME "no_plugin_manifest"
)
qt_feature("c++11" PUBLIC
LABEL "C++11"
)
qt_feature_config("c++11" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("c++14" PUBLIC
LABEL "C++14"
CONDITION QT_FEATURE_cxx11 AND TEST_cxx14
)
qt_feature_config("c++14" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("c++17" PUBLIC
LABEL "C++17"
CONDITION QT_FEATURE_cxx14 AND TEST_cxx17
)
qt_feature_config("c++17" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("c++1z" PUBLIC
LABEL "C++17"
CONDITION QT_FEATURE_cxx17
)
qt_feature_config("c++1z" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("c++20" PUBLIC
LABEL "C++20"
AUTODETECT OFF
CONDITION QT_FEATURE_cxx17 AND TEST_cxx20
CONDITION TEST_cxx20
)
qt_feature_config("c++20" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("c++2a" PUBLIC
Expand All @@ -700,17 +636,6 @@ qt_feature("c++2b" PUBLIC
AUTODETECT FALSE
CONDITION QT_FEATURE_cxx20 AND (CMAKE_VERSION VERSION_GREATER_EQUAL "3.20") AND TEST_cxx2b
)
qt_feature("c89"
LABEL "C89"
)
qt_feature("c99" PUBLIC
LABEL "C99"
CONDITION c_std_99 IN_LIST CMAKE_C_COMPILE_FEATURES
)
qt_feature("c11" PUBLIC
LABEL "C11"
CONDITION QT_FEATURE_c99 AND c_std_11 IN_LIST CMAKE_C_COMPILE_FEATURES
)
qt_feature("precompile_header"
LABEL "Using precompiled headers"
CONDITION BUILD_WITH_PCH AND TEST_precompile_header
Expand Down Expand Up @@ -1142,16 +1067,6 @@ qt_configure_add_summary_entry(
)
# special case end
qt_configure_add_summary_entry(ARGS "shared")
qt_configure_add_summary_entry(
TYPE "firstAvailableFeature"
ARGS "c11 c99 c89"
MESSAGE "Using C standard"
)
qt_configure_add_summary_entry(
TYPE "firstAvailableFeature"
ARGS "c++2b c++20 c++17 c++14 c++11"
MESSAGE "Using C++ standard"
)
qt_configure_add_summary_entry(
ARGS "ccache"
CONDITION UNIX
Expand Down
23 changes: 0 additions & 23 deletions mkspecs/features/mac/default_post.prf
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,6 @@ contains(TEMPLATE, .*app) {

!no_objective_c:CONFIG += objective_c

qt {
qtConfig(static) {
# C++11 support means using libc++ instead of libstd++. As the
# two libraries are incompatible we need to ensure the end user
# project is built using the same C++11 support/no support as Qt.
qtConfig(c++11) {
CONFIG += c++11
} else: c++11 {
warning("Qt was not built with C++11 enabled, disabling feature")
CONFIG -= c++11
}

!c++11 {
# Explicitly use libstdc++ if C++11 support is not enabled,
# as otherwise the compiler will choose the standard library
# based on the deployment target, which for iOS 7 and OS X 10.9
# is libc++, and we can't mix and match the two.
QMAKE_CXXFLAGS += -stdlib=libstdc++
QMAKE_LFLAGS += -stdlib=libstdc++
}
}
}

# Add the same default rpaths as Xcode does for new projects.
# This is especially important for iOS/tvOS/watchOS where no other option is possible.
!no_default_rpath {
Expand Down
3 changes: 3 additions & 0 deletions mkspecs/features/qt.prf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# due to required Qt modules being missing.
!isEmpty(QMAKE_FAILED_REQUIREMENTS): return()

# hardcoded defaults
QT_CONFIG *= c99 c11 c++11 c++14 c++1z c++17

qtConfig(thread): CONFIG *= thread

#handle defines
Expand Down

0 comments on commit 205f8fb

Please sign in to comment.