1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])")
6 "C# is currently only supported for Microsoft Visual Studio 11 2012 and later.")
9 include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
10 #include(Platform/${CMAKE_SYSTEM_NAME}-Determine-CSharp OPTIONAL)
11 #include(Platform/${CMAKE_SYSTEM_NAME}-CSharp OPTIONAL)
12 if(NOT CMAKE_CSharp_COMPILER_NAMES)
13 set(CMAKE_CSharp_COMPILER_NAMES csc)
16 # Build a small source file to identify the compiler.
17 if(NOT CMAKE_CSharp_COMPILER_ID_RUN)
18 set(CMAKE_CSharp_COMPILER_ID_RUN 1)
20 # Try to identify the compiler.
21 set(CMAKE_CSharp_COMPILER_ID)
22 include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
23 CMAKE_DETERMINE_COMPILER_ID(CSharp CSFLAGS CMakeCSharpCompilerId.cs)
25 execute_process(COMMAND "${CMAKE_CSharp_COMPILER}" "/help /preferreduilang:en-US" OUTPUT_VARIABLE output)
26 string(REPLACE "\n" ";" output "${output}")
27 foreach(line ${output})
28 string(TOUPPER ${line} line)
29 string(REGEX REPLACE "^.*COMPILER.*VERSION[^\\.0-9]*([\\.0-9]+).*$" "\\1" version "${line}")
30 if(version AND NOT "x${line}" STREQUAL "x${version}")
31 set(CMAKE_CSharp_COMPILER_VERSION ${version})
35 message(STATUS "The CSharp compiler version is ${CMAKE_CSharp_COMPILER_VERSION}")
38 # configure variables set in this file for fast reload later on
39 configure_file(${CMAKE_ROOT}/Modules/CMakeCSharpCompiler.cmake.in
40 ${CMAKE_PLATFORM_INFO_DIR}/CMakeCSharpCompiler.cmake