Repository: mesos Updated Branches: refs/heads/master cd4173059 -> 5518e4ad4
Add explicit compiler check for CMake Windows builds. MesosConfigure.cmake will currently allow users to try to compile Mesos with any compiler and any version on the Windows platform. But, the for now we will only support MSVC 1900 or later. Our solution is to remove the possibility of compiling on anything other than MSVC 1900. This commit will introduce explicit warnings when users attempt to compile with anything else. Review: https://reviews.apache.org/r/36964 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5518e4ad Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5518e4ad Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5518e4ad Branch: refs/heads/master Commit: 5518e4ad4bc19d7e364b3bc1baa5a0dc8fed82db Parents: cd41730 Author: Benjamin Hindman <[email protected]> Authored: Sat Aug 1 15:06:48 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Sat Aug 1 15:09:59 2015 -0700 ---------------------------------------------------------------------- cmake/MesosConfigure.cmake | 44 +++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/5518e4ad/cmake/MesosConfigure.cmake ---------------------------------------------------------------------- diff --git a/cmake/MesosConfigure.cmake b/cmake/MesosConfigure.cmake index ee47842..b530da4 100755 --- a/cmake/MesosConfigure.cmake +++ b/cmake/MesosConfigure.cmake @@ -47,16 +47,48 @@ if (_DEBUG) set(CMAKE_BUILD_TYPE Debug) endif (_DEBUG) -# Set CXX standard. A bit more verbose than it would be in CMake 3. +# Make sure C++ 11 features we need are supported. This is split into two +# cases: Windows and "other platforms". +# * For "other platforms", we simply check if the C++11 flags work +# * For Windows, it looks like (1) C++11 is enabled by default on MSVC 1900 or +# later, and (2) C++11 is totally broken for 1800 or earlier (i.e., Mesos +# will not compile on MSVC pre-1900). So, when in Windows, we just check the +# MSVC version, and don't try to check or pass in C++11 flags at all. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) -if (COMPILER_SUPPORTS_CXX11) +if (WIN32) + # Windows case first. + + # We don't support compilation against mingw headers (which, e.g., Clang on + # Windows does at this point), because this is likely to cost us more effort + # to support than it will be worth at least in the short term. + if (NOT CMAKE_CXX_COMPILER_ID MATCHES MSVC) + message( + WARNING + "Mesos does not support compiling on Windows with " + "${CMAKE_CXX_COMPILER_ID}. Please use MSVC.") + endif (NOT CMAKE_CXX_COMPILER_ID MATCHES MSVC) + + # MSVC 1900 supports C++11; earliser versions don't. So, warn if you try to + # use anything else. + if (${MSVC_VERSION} LESS 1900) + message( + WARNING + "Mesos does not support compiling on MSVC versions earlier than 1900. " + "Please use MSVC 1900 (included with Visual Studio 2015 or later).") + endif (${MSVC_VERSION} LESS 1900) + + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") +elseif (COMPILER_SUPPORTS_CXX11) + # Finally, on non-Windows platforms, we must check that the current compiler + # supports C++11. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -else (COMPILER_SUPPORTS_CXX11) +else (WIN32) message( FATAL_ERROR - "The compiler ${CMAKE_CXX_COMPILER} does not support the `-std=c++11` flag. " - "Please use a different C++ compiler.") -endif (COMPILER_SUPPORTS_CXX11) + "The compiler ${CMAKE_CXX_COMPILER} does not support the `-std=c++11` " + "flag. Please use a different C++ compiler.") +endif (WIN32) # Convenience flags to simplify Windows support in C++ source. if (MSVC)
