Configurations_clang.cmake 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. include(cmake/Platform/Common/Configurations_common.cmake)
  9. # Exceptions are disabled by default. Use this to turn them on just for a specific target.
  10. # MSVC-Clang uses MSVC compiler option syntax (so /EHsc instead of -fexceptions)
  11. set(O3DE_COMPILE_OPTION_ENABLE_EXCEPTIONS PUBLIC /EHsc)
  12. # O3DE Sets visibility to hidden by default, requiring explicit export on non-windows platforms
  13. # But on MSVC or MS-Clang, these compilers use MSVC compiler options and behavior, which means
  14. # it is not necessary to set visibility to hidden as on MSVC, things behave similar to if
  15. # hidden by default. As such, there is no need to change compile options for 3rd Party Libraries
  16. # to cause them to export symbols. This is thus blank
  17. set(O3DE_COMPILE_OPTION_EXPORT_SYMBOLS "")
  18. # By default, O3DE sets warning level 4 and sets warnings as errors. If you're pulling in
  19. # external code (from 3rd Party libraries) you can't really control whether they generate
  20. # warnings or not, and its usually out of scope to fix them. Add this compile option to
  21. # those 3rd Party targets ONLY.
  22. set(O3DE_COMPILE_OPTION_DISABLE_WARNINGS PRIVATE /W0)
  23. ly_append_configurations_options(
  24. DEFINES_PROFILE
  25. _FORTIFY_SOURCE=2
  26. DEFINES_RELEASE
  27. _FORTIFY_SOURCE=2
  28. COMPILATION
  29. -Wno-reorder-ctor
  30. -Wno-logical-not-parentheses
  31. -Wno-logical-op-parentheses
  32. -Wno-switch
  33. -Wno-undefined-var-template
  34. -Wno-inconsistent-missing-override
  35. -Wno-parentheses
  36. -Wno-unused-parameter
  37. -Wno-sign-compare
  38. -Wno-ignored-qualifiers
  39. -Wno-missing-field-initializers
  40. # disable warning introduced by -fsized-deallocation, pybind11 used.
  41. -Wno-unknown-argument
  42. /fp:fast # allows the compiler to reorder, combine, or simplify floating-point operations to optimize floating-point code for speed and space
  43. /Gd # Use _cdecl calling convention for all functions
  44. /MP # Multicore compilation in Visual Studio
  45. /nologo # Suppress Copyright and version number message
  46. /W4 # Warning level 4
  47. /WX # Warnings as errors
  48. /permissive- # Conformance with standard
  49. /Zc:preprocessor # Forces preprocessor into conformance mode: https://docs.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-170
  50. /Zc:forScope # Force Conformance in for Loop Scope
  51. /diagnostics:caret # Compiler diagnostic options: includes the column where the issue was found and places a caret (^) under the location in the line of code where the issue was detected.
  52. /Zc:__cplusplus
  53. /bigobj # Increase number of sections in obj files. Profiling has shown no meaningful impact in memory nore build times
  54. /GS # Enable Buffer security check
  55. /sdl
  56. COMPILATION_DEBUG
  57. /MDd # defines _DEBUG, _MT, and _DLL and causes the application to use the debug multithread-specific and DLL-specific version of the run-time library.
  58. # It also causes the compiler to place the library name MSVCRTD.lib into the .obj file.
  59. /Ob0 # Disables inline expansions
  60. /Od # Disables optimization
  61. COMPILATION_PROFILE
  62. /GF # Enable string pooling
  63. /Gy # Function level linking
  64. /MD # Causes the application to use the multithread-specific and DLL-specific version of the run-time library. Defines _MT and _DLL and causes the compiler
  65. # to place the library name MSVCRT.lib into the .obj file.
  66. /O2 # Maximinize speed, equivalent to /Og /Oi /Ot /Oy /Ob2 /GF /Gy
  67. /Zc:inline # Removes unreferenced functions or data that are COMDATs or only have internal linkage
  68. /Zc:wchar_t # Use compiler native wchar_t
  69. /Zi # Generate debugging information (no Edit/Continue)
  70. COMPILATION_RELEASE
  71. /Ox # Full optimization
  72. /Ob2 # Inline any suitable function
  73. /Ot # Favor fast code over small code
  74. /Oi # Use Intrinsic Functions
  75. /Oy # Omit the frame pointer
  76. LINK
  77. /NOLOGO # Suppress Copyright and version number message
  78. /IGNORE:4099 # 3rdParty linking produces noise with LNK4099
  79. LINK_NON_STATIC_PROFILE
  80. /OPT:REF # Eliminates functions and data that are never referenced
  81. /OPT:ICF # Perform identical COMDAT folding. Redundant COMDATs can be removed from the linker output
  82. /INCREMENTAL:NO
  83. /DEBUG # Generate pdbs
  84. LINK_NON_STATIC_RELEASE
  85. /OPT:REF # Eliminates functions and data that are never referenced
  86. /OPT:ICF # Perform identical COMDAT folding. Redundant COMDATs can be removed from the linker output
  87. /INCREMENTAL:NO
  88. )
  89. if(LY_BUILD_WITH_ADDRESS_SANITIZER)
  90. ly_append_configurations_options(
  91. COMPILATION_DEBUG
  92. -fsanitize=address
  93. -fno-omit-frame-pointer
  94. LINK_NON_STATIC_DEBUG
  95. -shared-libsan
  96. -fsanitize=address
  97. )
  98. endif()
  99. include(cmake/Platform/Common/TargetIncludeSystemDirectories_supported.cmake)