compilerconfig.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # OBS CMake macOS compiler configuration module
  2. include_guard(GLOBAL)
  3. include(ccache)
  4. include(compiler_common)
  5. add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-fopenmp-simd>")
  6. # Enable selection between arm64 and x86_64 targets
  7. if(NOT CMAKE_OSX_ARCHITECTURES)
  8. set(CMAKE_OSX_ARCHITECTURES
  9. arm64
  10. CACHE STRING "Build architectures for macOS" FORCE)
  11. endif()
  12. set_property(CACHE CMAKE_OSX_ARCHITECTURES PROPERTY STRINGS arm64 x86_64)
  13. if(XCODE)
  14. # Enable dSYM generator for release builds
  15. string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
  16. string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
  17. else()
  18. option(ENABLE_COMPILER_TRACE "Enable clang time-trace (requires Ninja)" OFF)
  19. mark_as_advanced(ENABLE_COMPILER_TRACE)
  20. # clang options for ObjC
  21. set(_obs_clang_objc_options
  22. ${_obs_clang_common_options}
  23. -Wno-implicit-atomic-properties
  24. -Wno-objc-interface-ivars
  25. -Warc-repeated-use-of-weak
  26. -Wno-arc-maybe-repeated-use-of-weak
  27. -Wimplicit-retain-self
  28. -Wduplicate-method-match
  29. -Wshadow
  30. -Wfloat-conversion
  31. -Wobjc-literal-conversion
  32. -Wno-selector
  33. -Wno-strict-selector-match
  34. -Wundeclared-selector
  35. -Wdeprecated-implementations
  36. -Wprotocol
  37. -Werror=block-capture-autoreleasing
  38. -Wrange-loop-analysis)
  39. # clang options for ObjC++
  40. set(_obs_clang_objcxx_options ${_obs_clang_objc_options} -Wno-non-virtual-dtor)
  41. # cmake-format: off
  42. add_compile_options(
  43. "$<$<COMPILE_LANGUAGE:C>:${_obs_clang_c_options}>"
  44. "$<$<COMPILE_LANGUAGE:CXX>:${_obs_clang_cxx_options}>"
  45. "$<$<COMPILE_LANGUAGE:OBJC>:${_obs_clang_objc_options}>"
  46. "$<$<COMPILE_LANGUAGE:OBJCXX>:${_obs_clang_objcxx_options}>")
  47. # cmake-format: on
  48. # Enable stripping of dead symbols when not building for Debug configuration
  49. set(_release_configs RelWithDebInfo Release MinSizeRel)
  50. if(CMAKE_BUILD_TYPE IN_LIST _release_configs)
  51. add_link_options(LINKER:-dead_strip)
  52. endif()
  53. # Enable color diagnostics for AppleClang
  54. set(CMAKE_COLOR_DIAGNOSTICS ON)
  55. # Add time trace option to compiler, if enabled.
  56. if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja")
  57. add_compile_options($<$<NOT:$<COMPILE_LANGUAGE:Swift>>:-ftime-trace>)
  58. else()
  59. set(ENABLE_COMPILER_TRACE
  60. OFF
  61. CACHE BOOL "Enable clang time-trace (requires Ninja)" FORCE)
  62. endif()
  63. endif()
  64. add_compile_definitions(
  65. "$<$<NOT:$<COMPILE_LANGUAGE:Swift>>:$<$<CONFIG:DEBUG>:DEBUG>;$<$<CONFIG:DEBUG>:_DEBUG>;SIMDE_ENABLE_OPENMP>")