summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <ske@ableton.com>2016-01-13 11:46:18 +0100
committerStephen Kelly <ske@ableton.com>2016-01-19 14:40:04 +0000
commit71be92c1d0aad7d86b53de37cd2df021b736cb4e (patch)
tree9bef86552c9568281a9ac74e1a6bfe0026c39576
parentc5f7d15765597052983052805e0b4738497c0b5c (diff)
CMake: Pass -std=gnu++0x to generated tests in CI.
Add -stdlib=libc++ when using AppleClang. If CMP0025 is OLD, the compiler id is 'Clang' for backward compatibility. So, if on a CI machine running 'Clang', and on APPLE, use the -stdlib=libc++ flag too. Change-Id: I4910000ce08bae1201f7fa0e0eb46622bedd5c4f Reviewed-by: Kevin Funk <kfunk@kde.org> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/corelib/Qt5CTestMacros.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/corelib/Qt5CTestMacros.cmake b/src/corelib/Qt5CTestMacros.cmake
index 6451f65b55..40106fe919 100644
--- a/src/corelib/Qt5CTestMacros.cmake
+++ b/src/corelib/Qt5CTestMacros.cmake
@@ -46,6 +46,20 @@ if (NO_DBUS)
list(APPEND BUILD_OPTIONS_LIST "-DNO_DBUS=True")
endif()
+# Qt requires C++11 features in header files, which means
+# the buildsystem needs to add a -std flag for certain compilers
+# CMake adds the flag automatically in most cases, but notably not
+# on Windows prior to CMake 3.3
+if (CMAKE_VERSION VERSION_LESS 3.3)
+ if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang
+ OR (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang))
+ list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_CXX_FLAGS=-std=gnu++0x -stdlib=libc++")
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU
+ OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
+ list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_CXX_FLAGS=-std=gnu++0x")
+ endif()
+endif()
+
foreach(module ${CMAKE_MODULES_UNDER_TEST})
list(APPEND BUILD_OPTIONS_LIST
"-DCMAKE_${module}_MODULE_MAJOR_VERSION=${CMAKE_${module}_MODULE_MAJOR_VERSION}"
@@ -166,6 +180,15 @@ function(test_module_includes)
${packages_string}
set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} \${Qt5Core_EXECUTABLE_COMPILE_FLAGS}\")
+ if (CMAKE_VERSION VERSION_LESS 3.3)
+ if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang
+ OR (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang))
+ set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} -std=gnu++0x -stdlib=libc++\")
+ elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU
+ OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
+ set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} -std=gnu++0x\")
+ endif()
+ endif()
add_executable(module_includes_exe \"\${CMAKE_CURRENT_SOURCE_DIR}/main.cpp\")
target_link_libraries(module_includes_exe ${libraries_string})\n"