compiler_flags.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. macro(compiler_flags TARGET)
  2. if (NOT ${TARGET} STREQUAL "" AND TARGET ${TARGET})
  3. # Note that simdjson automatically figures out which SIMD intrinsics to use at runtime based on
  4. # cpuid, meaning no architecture flags or other compile flags need to be passed.
  5. # See https://github.com/simdjson/simdjson/blob/master/doc/implementation-selection.md.
  6. if (MSVC)
  7. target_compile_options(${TARGET} PRIVATE /EHsc /utf-8 $<$<CONFIG:RELEASE>:/O2 /Ob3 /Ot>)
  8. if (MSVC_VERSION GREATER 1929)
  9. target_compile_options(${TARGET} PRIVATE /external:W0 /external:anglebrackets)
  10. endif()
  11. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  12. target_compile_options(${TARGET} PRIVATE $<$<CONFIG:RELEASE>:-O3>)
  13. # Issue with MinGW: https://github.com/simdjson/simdjson/issues/1963
  14. target_compile_options(${TARGET} PUBLIC $<$<CONFIG:DEBUG>:-Og>)
  15. # https://github.com/simdjson/simdjson/blob/master/doc/basics.md#performance-tips
  16. target_compile_options(${TARGET} PRIVATE $<$<CONFIG:RELEASE>:-DNDEBUG>)
  17. endif()
  18. endif()
  19. endmacro()
  20. macro(enable_debug_inlining TARGET)
  21. if (NOT ${TARGET} STREQUAL "" AND TARGET ${TARGET})
  22. if (MSVC)
  23. target_compile_options(${TARGET} PRIVATE $<$<CONFIG:DEBUG>:/Ob2>)
  24. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  25. target_compile_options(${TARGET} PRIVATE $<$<CONFIG:DEBUG>:-finline-functions>)
  26. endif()
  27. endif()
  28. endmacro()