diff --git a/Windows.MSVC.toolchain.cmake b/Windows.MSVC.toolchain.cmake index 6e1effc..fddde8e 100644 --- a/Windows.MSVC.toolchain.cmake +++ b/Windows.MSVC.toolchain.cmake @@ -152,21 +152,6 @@ set(VS_TOOLSET_PATH "${VS_INSTALLATION_PATH}/VC/Tools/MSVC/${CMAKE_VS_PLATFORM_T # Set the tooling variables, include_directories and link_directories # -function(getMsvcVersion COMPILER MSVC_VERSION_OUTPUT) - execute_process( - COMMAND "${COMPILER}" -Bv - ERROR_VARIABLE COMPILER_OUTPUT - OUTPUT_QUIET - ) - - if(COMPILER_OUTPUT MATCHES "cl\\.exe[^0-9]*(([0-9]+)\\.([0-9]+)\\.([0-9]+)(\\.([0-9]+))?)") - set(COMPILER_VERSION ${CMAKE_MATCH_1}) - set(COMPILER_VERSION_MAJOR ${CMAKE_MATCH_2}) - set(COMPILER_VERSION_MINOR ${CMAKE_MATCH_3}) - endif() - - set(${MSVC_VERSION_OUTPUT} "${COMPILER_VERSION_MAJOR}${COMPILER_VERSION_MINOR}" PARENT_SCOPE) -endfunction() # Map CMAKE_SYSTEM_PROCESSOR values to CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE that identifies the tools that should # be used to produce code for the CMAKE_SYSTEM_PROCESSOR. @@ -187,11 +172,6 @@ if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} /EHsc") endif() -getMsvcVersion(${CMAKE_CXX_COMPILER} MSVC_VERSION) -if(NOT MSVC_VERSION) - message(FATAL_ERROR "Unable to obtain the compiler version from: ${CMAKE_CXX_COMPILER}") -endif() - # Compiler foreach(LANG C CXX RC) list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${VS_TOOLSET_PATH}/ATLMFC/include") diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 8cb4b07..1e9afab 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -5,6 +5,11 @@ cmake_minimum_required(VERSION 3.20) project(WindowsToolchainExample) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + message(STATUS "MSVC_VERSION = ${MSVC_VERSION}") + message(STATUS "MSVC_TOOLSET_VERSION = ${MSVC_TOOLSET_VERSION}") +endif() + add_compile_definitions( UNICODE _UNICODE