1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
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
9 get_filename_component(CMAKE_BASE_NAME "${CMAKE_CSharp_COMPILER}" NAME_WE)
11 set(CMAKE_BUILD_TYPE_INIT Debug)
13 set(CMAKE_CSharp_FLAGS_INIT "/define:TRACE")
14 set(CMAKE_CSharp_FLAGS_DEBUG_INIT "/debug:full /optimize- /warn:3 /errorreport:prompt /define:DEBUG")
15 set(CMAKE_CSharp_FLAGS_RELEASE_INIT "/debug:none /optimize /warn:1 /errorreport:queue")
16 set(CMAKE_CSharp_FLAGS_RELWITHDEBINFO_INIT "/debug:full /optimize-")
17 set(CMAKE_CSharp_FLAGS_MINSIZEREL_INIT "/debug:none /optimize")
18 set(CMAKE_CSharp_LINKER_SUPPORTS_PDB ON)
20 set(CMAKE_CSharp_STANDARD_LIBRARIES_INIT "System")
22 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
23 set(CMAKE_CSharp_FLAGS_INIT "/platform:x86 ${CMAKE_CSharp_FLAGS_INIT}")
25 set(CMAKE_CSharp_FLAGS_INIT "/platform:x64 ${CMAKE_CSharp_FLAGS_INIT}")
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.
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
37 if(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})
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
46 set(CMAKE_CSharp_FLAGS_INIT "$ENV{CSFLAGS} ${CMAKE_CSharp_FLAGS_INIT}")
48 cmake_initialize_per_config_variable(CMAKE_CSharp_FLAGS "Flags used by the C# compiler")
50 if(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)
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
59 cmake_initialize_per_config_variable(CMAKE_EXE_LINKER_FLAGS "Flags used by the linker")
60 cmake_initialize_per_config_variable(CMAKE_SHARED_LINKER_FLAGS "Flags used by the linker during the creation of shared libraries")
62 set(CMAKE_CSharp_CREATE_SHARED_LIBRARY "CSharp_NO_CREATE_SHARED_LIBRARY")
63 set(CMAKE_CSharp_CREATE_SHARED_MODULE "CSharp_NO_CREATE_SHARED_MODULE")
64 set(CMAKE_CSharp_LINK_EXECUTABLE "CSharp_NO_LINK_EXECUTABLE")
66 set(CMAKE_CSharp_USE_RESPONSE_FILE_FOR_OBJECTS 1)
67 set(CMAKE_CSharp_INFORMATION_LOADED 1)