MACRO(_check_cxx_flag _suffix)
IF("${DEAL_II_CXX_VERSION_FLAG}" STREQUAL "")
- CHECK_CXX_COMPILER_FLAG("-std=c++${_suffix}" DEAL_II_HAVE_FLAG_stdcxx${_suffix})
- IF(DEAL_II_HAVE_FLAG_stdcxx${_suffix})
- SET(DEAL_II_CXX_VERSION_FLAG "-std=c++${_suffix}")
- ENDIF()
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ CHECK_CXX_COMPILER_FLAG("/std:c++${_suffix}" DEAL_II_HAVE_FLAG_stdcxx${_suffix})
+ IF(DEAL_II_HAVE_FLAG_stdcxx${_suffix})
+ SET(DEAL_II_CXX_VERSION_FLAG "/std:c++${_suffix}")
+ ENDIF()
+ ELSE()
+ CHECK_CXX_COMPILER_FLAG("-std=c++${_suffix}" DEAL_II_HAVE_FLAG_stdcxx${_suffix})
+ IF(DEAL_II_HAVE_FLAG_stdcxx${_suffix})
+ SET(DEAL_II_CXX_VERSION_FLAG "-std=c++${_suffix}")
+ ENDIF()
+ ENDIF()
ENDIF()
ENDMACRO()
IF(NOT "${DEAL_II_CXX_VERSION_FLAG}" STREQUAL "")
# Set CMAKE_REQUIRED_FLAGS for the unit tests
MESSAGE(STATUS "Using C++ version flag \"${DEAL_II_CXX_VERSION_FLAG}\"")
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_VERSION_FLAG} -Werror")
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/WX /EHsc")
+ ELSE()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+ ENDIF()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_VERSION_FLAG}")
UNSET_IF_CHANGED(CHECK_CXX_FEATURES_FLAGS_CXX17_SAVED
"${CMAKE_REQUIRED_FLAGS}${DEAL_II_CXX_VERSION_FLAG}"
# try to avoid adding an extra flag by doing one last test:
#
RESET_CMAKE_REQUIRED()
+IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/Zc:__cplusplus")
+ENDIF()
CHECK_CXX_SOURCE_COMPILES(
"
#include <memory>
}
"
DEAL_II_COMPILER_DEFAULTS_TO_CXX11_OR_NEWER)
+ RESET_CMAKE_REQUIRED()
IF(_user_provided_cxx_version_flag OR
NOT DEAL_II_COMPILER_DEFAULTS_TO_CXX11_OR_NEWER OR
# possibilities here.
#
ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS}")
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror -Wno-unused-command-line-argument")
+IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/WX")
+ELSE()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror -Wno-unused-command-line-argument")
+ENDIF()
#
# first try the attribute [[fallthrough]]
#
# "warning #1292: unknown attribute "deprecated"" (icc)
# Hence, we treat warnings as errors:
ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_FLAGS}")
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror -Wno-unused-command-line-argument")
+IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/WX")
+ELSE()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror -Wno-unused-command-line-argument")
+ENDIF()
# first see if the compiler accepts the attribute
CHECK_CXX_SOURCE_COMPILES(
#
# - Matthias Maier, 2015
#
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/WX")
+ELSE()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+ENDIF()
CHECK_CXX_SOURCE_COMPILES(
"
_Pragma(\"GCC diagnostic push\")
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-diag-error warn")
ENDIF()
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror -fuse-ld=lld")
+IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/WX")
+ELSE()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+ENDIF()
+ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-fuse-ld=lld")
CHECK_CXX_SOURCE_COMPILES(
"
int main() { return 0; }
ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-diag-error warn")
ENDIF()
-ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror -fuse-ld=gold")
+IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/WX")
+ELSE()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+ENDIF()
+ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-fuse-ld=gold")
CHECK_CXX_SOURCE_COMPILES(
"
int main() { return 0; }
# Older boost versions can't know about this but provide a possibility to
# circumvent the issue. Hence, we just check ourselves.
ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${DEAL_II_CXX_VERSION_FLAG}")
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "/WX")
+ ELSE()
+ ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+ ENDIF()
CHECK_CXX_SOURCE_COMPILES(
"