1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4# This file sets the basic flags for the C# language in CMake.
5# It also loads the available platform file for the system-compiler
6# if it exists.
7
8set(CMAKE_BASE_NAME)
9get_filename_component(CMAKE_BASE_NAME "${CMAKE_CSharp_COMPILER}" NAME_WE)
10
11set(CMAKE_BUILD_TYPE_INIT Debug)
12
13set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE")
14set(CMAKE_CSharp_FLAGS_DEBUG_INIT "/debug:full /optimize- /warn:3 /errorreport:prompt /define:DEBUG")
15set(CMAKE_CSharp_FLAGS_RELEASE_INIT "/debug:none /optimize  /warn:1  /errorreport:queue")
16set(CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT "/debug:full /optimize-")
17set(CMAKE_CSharp_FLAGS_MINSIZEREL_INIT "/debug:none /optimize")
18set(CMAKE_CSharp_LINKER_SUPPORTS_PDB ON)
19
20set(CMAKE_CSharp_STANDARD_LIBRARIES_INIT "System")
21
22if(CMAKE_SIZEOF_VOID_P EQUAL 4)
23  set(CMAKE_CSharp_FLAGS_INIT "/platform:x86 ${CMAKE_CSharp_FLAGS_INIT}")
24else()
25  set(CMAKE_CSharp_FLAGS_INIT "/platform:x64 ${CMAKE_CSharp_FLAGS_INIT}")
26endif()
27
28# This should be included before the _INIT variables are
29# used to initialize the cache.  Since the rule variables
30# have if blocks on them, users can still define them here.
31# But, it should still be after the platform file so changes can
32# be made to those values.
33
34# for most systems a module is the same as a shared library
35# so unless the variable CMAKE_MODULE_EXISTS is set just
36# copy the values from the LIBRARY variables
37if(NOT CMAKE_MODULE_EXISTS)
38  set(CMAKE_SHARED_MODULE_CSharp_FLAGS ${CMAKE_SHARED_LIBRARY_CSharp_FLAGS})
39  set(CMAKE_SHARED_MODULE_CREATE_CSharp_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CSharp_FLAGS})
40endif()
41
42# add the flags to the cache based
43# on the initial values computed in the platform/*.cmake files
44# use _INIT variables so that this only happens the first time
45# and you can set these flags in the cmake cache
46set(CMAKE_CSharp_FLAGS_INIT "$ENV{CSFLAGS} ${CMAKE_CSharp_FLAGS_INIT}")
47
48cmake_initialize_per_config_variable(CMAKE_CSharp_FLAGS "Flags used by the C# compiler")
49
50if(CMAKE_CSharp_STANDARD_LIBRARIES_INIT)
51  set(CMAKE_CSharp_STANDARD_LIBRARIES "${CMAKE_CSharp_STANDARD_LIBRARIES_INIT}"
52    CACHE STRING "Libraries linked by default with all C# applications.")
53  mark_as_advanced(CMAKE_CSharp_STANDARD_LIBRARIES)
54endif()
55
56# set missing flags (if they are not defined). This is needed in the
57# unlikely case that you have only C# and no C/C++ targets in your
58# project.
59cmake_initialize_per_config_variable(CMAKE_EXE_LINKER_FLAGS    "Flags used by the linker")
60cmake_initialize_per_config_variable(CMAKE_SHARED_LINKER_FLAGS "Flags used by the linker during the creation of shared libraries")
61
62set(CMAKE_CSharp_CREATE_SHARED_LIBRARY "CSharp_NO_CREATE_SHARED_LIBRARY")
63set(CMAKE_CSharp_CREATE_SHARED_MODULE "CSharp_NO_CREATE_SHARED_MODULE")
64set(CMAKE_CSharp_LINK_EXECUTABLE "CSharp_NO_LINK_EXECUTABLE")
65
66set(CMAKE_CSharp_USE_RESPONSE_FILE_FOR_OBJECTS 1)
67set(CMAKE_CSharp_INFORMATION_LOADED 1)
68