compiler-specific.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Quite analogous to the Makefile.defs file This file is used to define the
  2. # common flags and options for the project The flags are defined as INTERFACE
  3. # properties of the common library The flags are then used by the other
  4. # libraries and executables
  5. cmake_minimum_required(VERSION 3.10)
  6. # Define the common flags and options for GCC
  7. option(PROFILE "Enable profiling" OFF)
  8. # Define the flags for the C compiler
  9. if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
  10. if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  11. target_compile_definitions(common INTERFACE CC_GCC_LIKE_ASM)
  12. target_compile_options(
  13. common INTERFACE -O0
  14. # <$<$<BOOL:${PROFILE}>:-pg>
  15. )
  16. target_compile_options(
  17. common
  18. INTERFACE -Wall -funroll-loops -Wcast-align
  19. -Werror=implicit-function-declaration -Werror=implicit-int
  20. )
  21. # If GCC version is greater than 4.2.0, enable the following flags
  22. if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.2.0)
  23. target_compile_options(
  24. common INTERFACE -m64 -minline-all-stringops -falign-loops
  25. -ftree-vectorize -fno-strict-overflow -mtune=generic
  26. )
  27. endif()
  28. elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
  29. target_compile_definitions(common INTERFACE CC_GCC_LIKE_ASM)
  30. target_compile_options(common INTERFACE -m64)
  31. target_link_options(common INTERFACE -m64)
  32. endif()
  33. elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
  34. if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
  35. target_compile_definitions(common INTERFACE CC_GCC_LIKE_ASM)
  36. # target_compile_options(common INTERFACE -O0 # <$<$<BOOL:${PROFILE}>:-pg> )
  37. # target_compile_options( common INTERFACE -marm -march=armv5t
  38. # -funroll-loops -fsigned-char )
  39. # # If GCC version is greater than 4.2.0, enable the following flags
  40. # if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.2.0) target_compile_options(
  41. # common INTERFACE -ftree-vectorize -fno-strict-overflow ) endif()
  42. endif()
  43. endif()