Linux-Intel.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
  36. if(XIAR)
  37. # INTERPROCEDURAL_OPTIMIZATION
  38. set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo)
  39. set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO
  40. "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> "
  41. "${XIAR} -s <TARGET> ")
  42. set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)
  43. set(_CMAKE_${lang}_IPO_LEGACY_BEHAVIOR YES)
  44. else()
  45. set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO)
  46. endif()
  47. if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0)
  48. set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
  49. endif()
  50. endmacro()