CMake VS2019 编译VTK8.2.0启用C++17标准

CMakeList.txt中添加:(这里加在了project(VTK)之后)

if (MSVC_VERSION GREATER_EQUAL "1914")
    add_compile_options("/Zc:__cplusplus") 
endif()

if (MSVC_VERSION GREATER_EQUAL "1900")
    include(CheckCXXCompilerFlag)
    CHECK_CXX_COMPILER_FLAG("/std:c++17" _compiler_supports_cxx17)
    if (_compiler_supports_cxx17)
        add_compile_options("/std:c++17")
    endif()
endif()

 

如果是g++编译器:

if(CMAKE_COMPILER_IS_GNUCXX)
    include(CheckCXXCompilerFlag)
    CHECK_CXX_COMPILER_FLAG("-std=c++17" _compiler_supports_cxx17)
    if (_compiler_supports_cxx17)
        set(CMAKE_CXX_FLAGS "-std=c++17 ${CMAKE_CXX_FLAGS}")
        message(STATUS "optional:-std=c++17")  
    endif()
endif(CMAKE_COMPILER_IS_GNUCXX)

 

你可能感兴趣的:(图像处理之ITK_VTK)