CMakeCSharpInformation.cmake 3.0 KB

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