Skip to content

Commit

Permalink
Merge pull request ericniebler#1275 from CaseyCarter/msvc
Browse files Browse the repository at this point in the history
Try to reduce issue reports from MSVC users
  • Loading branch information
CaseyCarter authored Aug 23, 2019
2 parents 9cc9afd + 93b9593 commit 94f9516
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
add_library(meta INTERFACE)
target_include_directories(meta INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(meta SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
target_compile_options(meta INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/permissive->)

add_library(concepts INTERFACE)
target_include_directories(concepts INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(concepts SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
target_compile_options(concepts INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/permissive- /experimental:preprocessor /wd5105>)
target_link_libraries(concepts INTERFACE meta)

add_library(range-v3 INTERFACE)
target_include_directories(range-v3 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(range-v3 SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
target_compile_options(range-v3 INTERFACE $<$<CXX_COMPILER_ID:MSVC>:/permissive->)
target_link_libraries(range-v3 INTERFACE concepts meta)

function(rv3_add_test TESTNAME EXENAME FIRSTSOURCE)
Expand Down
13 changes: 4 additions & 9 deletions cmake/ranges_env.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,11 @@ else()
message(WARNING "[range-v3 warning]: unknown system ${CMAKE_SYSTEM_NAME} !")
endif()

if (RANGES_CXX_COMPILER_CLANGCL OR RANGES_CXX_COMPILER_MSVC)
# Clang-CL will blow up in the standard library if compiling with less than
# C++14, and MSVC doesn't support less than C++14 at all.
if (RANGES_CXX_STD LESS 14)
set(RANGES_CXX_STD 14)
endif()
if (RANGES_CXX_COMPILER_MSVC AND RANGES_CXX_STD LESS 17)
# MSVC is currently supported only in 17+ mode
if (RANGES_CXX_COMPILER_MSVC AND RANGES_CXX_STD LESS 17)
set(RANGES_CXX_STD 17)
endif()
set(RANGES_CXX_STD 17)
elseif(RANGES_CXX_STD LESS 14)
set(RANGES_CXX_STD 14)
endif()

# Build type
Expand Down
6 changes: 0 additions & 6 deletions cmake/ranges_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@ message(STATUS "[range-v3]: C++ std=${RANGES_CXX_STD}")
if (RANGES_CXX_COMPILER_CLANGCL OR RANGES_CXX_COMPILER_MSVC)
ranges_append_flag(RANGES_HAS_CXXSTDCOLON "/std:c++${RANGES_CXX_STD}")
set(RANGES_STD_FLAG "/std:c++${RANGES_CXX_STD}")
# Enable strict mode
ranges_append_flag(RANGES_HAS_PERMISSIVEMINUS "/permissive-")
if (RANGES_CXX_COMPILER_CLANGCL)
ranges_append_flag(RANGES_HAS_FNO_MS_COMPATIBIILITY "-fno-ms-compatibility")
ranges_append_flag(RANGES_HAS_FNO_DELAYED_TEMPLATE_PARSING "-fno-delayed-template-parsing")
endif()
# Enable "normal" warnings and make them errors:
ranges_append_flag(RANGES_HAS_W3 /W3)
ranges_append_flag(RANGES_HAS_WX /WX)
# range-v3 needs MSVC's experimental actually-conforming preprocessor...
ranges_append_flag(RANGES_HAS_EXPERIMENTAL_PREPROCESSOR /experimental:preprocessor)
# ...which warns about UB in macros in the UCRT headers =(
ranges_append_flag(RANGES_HAS_WD5105 /wd5105)
else()
ranges_append_flag(RANGES_HAS_CXXSTD "-std=c++${RANGES_CXX_STD}")
set(RANGES_STD_FLAG "-std=c++${RANGES_CXX_STD}")
Expand Down
4 changes: 4 additions & 0 deletions include/range/v3/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ namespace ranges

#define RANGES_CXX_VER _MSVC_LANG

#if _MSC_VER < 1920 || _MSVC_LANG < 201703L || !defined(_MSVC_TRADITIONAL) || _MSVC_TRADITIONAL != 0
#error range-v3 requires Visual Studio 2019 with the /std:c++17 (or /std:c++latest) /permissive- and /experimental:preprocessor options.
#endif

#if _MSC_VER < 1923
#define RANGES_WORKAROUND_MSVC_934330 // Deduction guide not correctly preferred to copy
// deduction candidate [No workaround]
Expand Down
1 change: 0 additions & 1 deletion test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ add_executable(example example.cpp)
target_link_libraries(example ${CONAN_LIBS})

set_property(TARGET example PROPERTY CXX_STANDARD 17)
target_compile_options(example PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/experimental:preprocessor /wd5105>)

0 comments on commit 94f9516

Please sign in to comment.