-
Notifications
You must be signed in to change notification settings - Fork 3
/
FindCsharp.cmake
83 lines (71 loc) · 2.67 KB
/
FindCsharp.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
FILE(TO_CMAKE_PATH "$ENV{WINDIR}" windir)
SET(framework_version "$ENV{FrameworkVersion}")
# Prefer v2 of the .NET Framework when both v2 and v3.5 are installed...:
# (older, wiser, more stable...)
#
SET(csc_search_paths
"${windir}/Microsoft.NET/Framework/v2.0.50727"
"${windir}/Microsoft.NET/Framework/v3.5"
"${windir}/Microsoft.NET/Framework/v3.0"
)
# ...if using the VS2008 generator, prefer v3.5:
#
IF(CMAKE_GENERATOR MATCHES "Visual Studio 9 2008")
SET(csc_search_paths
"${windir}/Microsoft.NET/Framework/v3.5"
"${windir}/Microsoft.NET/Framework/v3.0"
"${windir}/Microsoft.NET/Framework/v2.0.50727"
)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 9 2008")
# ...if using the VS2010 generator, prefer v4.0:
#
IF(CMAKE_GENERATOR MATCHES "Visual Studio 10")
SET(csc_search_paths
"${windir}/Microsoft.NET/Framework/v4.0.30128"
"${windir}/Microsoft.NET/Framework/v3.5"
"${windir}/Microsoft.NET/Framework/v3.0"
"${windir}/Microsoft.NET/Framework/v2.0.50727"
)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 10")
FIND_PROGRAM(csc_EXECUTABLE "csc"
${csc_search_paths}
"${windir}/Microsoft.NET/Framework/${framework_version}"
"${windir}/Microsoft.NET/Framework/v1.1.4322"
"${windir}/Microsoft.NET/Framework/v1.0.3705"
NO_DEFAULT_PATH
)
IF(NOT csc_EXECUTABLE)
FIND_PROGRAM(csc_EXECUTABLE NAMES "csc" "gmcs")
ENDIF(NOT csc_EXECUTABLE)
FIND_PROGRAM(mono_EXECUTABLE "mono")
GET_FILENAME_COMPONENT(csc_DIR "${csc_EXECUTABLE}" PATH)
SET(CSC_ACCEPTS_PLATFORM_FLAG 0)
SET(CSC_COMPILES_PARTIAL_CLASSES 0)
IF(csc_EXECUTABLE)
EXECUTE_PROCESS(COMMAND "${csc_EXECUTABLE}" "/?" OUTPUT_VARIABLE CSC_HELP)
IF("${CSC_HELP}" MATCHES "/platform:<string>")
SET(CSC_ACCEPTS_PLATFORM_FLAG 1)
SET(CSC_COMPILES_PARTIAL_CLASSES 1)
ENDIF("${CSC_HELP}" MATCHES "/platform:<string>")
ENDIF(csc_EXECUTABLE)
IF(NOT DEFINED CSC_PLATFORM_FLAG)
SET(CSC_PLATFORM_FLAG "")
IF(CSC_ACCEPTS_PLATFORM_FLAG)
SET(CSC_PLATFORM_FLAG "/platform:x86")
IF("${CMAKE_SIZEOF_VOID_P}" GREATER 4)
SET(CSC_PLATFORM_FLAG "/platform:x64")
ENDIF("${CMAKE_SIZEOF_VOID_P}" GREATER 4)
ENDIF(CSC_ACCEPTS_PLATFORM_FLAG)
ENDIF(NOT DEFINED CSC_PLATFORM_FLAG)
IF(NOT DEFINED CSC_DEBUG_FLAG)
SET(CSC_DEBUG_FLAG "")
IF("${CMAKE_BUILD_TYPE}" MATCHES "Debug|RelWithDebInfo")
SET(CSC_DEBUG_FLAG "/debug")
ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "Debug|RelWithDebInfo")
IF("${BUILDNAME}" MATCHES "Debug|RelWithDebInfo")
SET(CSC_DEBUG_FLAG "/debug")
ENDIF("${BUILDNAME}" MATCHES "Debug|RelWithDebInfo")
IF("${CMAKE_BINARY_DIR}" MATCHES "Debug|RelWithDebInfo")
SET(CSC_DEBUG_FLAG "/debug")
ENDIF("${CMAKE_BINARY_DIR}" MATCHES "Debug|RelWithDebInfo")
ENDIF(NOT DEFINED CSC_DEBUG_FLAG)