Linux-Intel.cmake 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This module is shared by multiple languages; use include blocker.
  4. if(__LINUX_COMPILER_INTEL)
  5. return()
  6. endif()
  7. set(__LINUX_COMPILER_INTEL 1)
  8. if(NOT XIAR)
  9. set(_intel_xiar_hints)
  10. foreach(lang C CXX Fortran)
  11. if(IS_ABSOLUTE "${CMAKE_${lang}_COMPILER}")
  12. get_filename_component(_hint "${CMAKE_${lang}_COMPILER}" PATH)
  13. list(APPEND _intel_xiar_hints ${_hint})
  14. endif()
  15. endforeach()
  16. find_program(XIAR NAMES xiar HINTS ${_intel_xiar_hints})
  17. mark_as_advanced(XIAR)
  18. endif()
  19. macro(__linux_compiler_intel lang)
  20. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
  21. set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
  22. set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
  23. if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 13.0)
  24. set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
  25. set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
  26. set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
  27. endif()
  28. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
  29. set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
  30. # We pass this for historical reasons. Projects may have
  31. # executables that use dlopen but do not set ENABLE_EXPORTS.
  32. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
  33. set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,")
  34. set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",")
  35. # FIXME(#26157): compute CMAKE_<LANG>_COMPILER_LINKER* variables
  36. # in the meantime, enforce deactivation of push/pop state linker options
  37. # because xild front-end linker do not support these options even if the platform linker does...
  38. set(CMAKE_${lang}_LINKER_PUSHPOP_STATE_SUPPORTED FALSE)
  39. set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
  40. if(XIAR)
  41. # INTERPROCEDURAL_OPTIMIZATION
  42. set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo)
  43. set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO
  44. "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> "
  45. "${XIAR} -s <TARGET> ")
  46. set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
  47. set(_CMAKE_${lang}_IPO_LEGACY_BEHAVIOR YES)
  48. else()
  49. set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
  50. endif()
  51. if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
  52. set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
  53. endif()
  54. endmacro()