TargetArch.cmake 591 B

123456789101112131415161718192021222324
  1. # Sets TARGET_ARCH to a normalized name (X86 or X86_64).
  2. # See https://github.com/axr/solar-cmake/blob/master/TargetArch.cmake
  3. include(CheckSymbolExists)
  4. # X86
  5. check_symbol_exists("_M_IX86" "" T_M_IX86)
  6. check_symbol_exists("__i386__" "" T_I386)
  7. if(T_M_IX86 OR T_I386)
  8. set(TARGET_ARCH "X86")
  9. return()
  10. endif()
  11. # X86_64
  12. check_symbol_exists("_M_AMD64" "" T_M_AMD64)
  13. check_symbol_exists("__x86_64__" "" T_X86_64)
  14. check_symbol_exists("__amd64__" "" T_AMD64)
  15. if(T_M_AMD64 OR T_X86_64 OR T_AMD64)
  16. set(TARGET_ARCH "X86_64")
  17. return()
  18. endif()
  19. message(FATAL_ERROR "Unknown target architecture")