Linux-Intel.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #=============================================================================
  2. # Copyright 2002-2009 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # This module is shared by multiple languages; use include blocker.
  14. if(__LINUX_COMPILER_INTEL)
  15. return()
  16. endif()
  17. set(__LINUX_COMPILER_INTEL 1)
  18. if(NOT XIAR)
  19. set(_intel_xiar_hints)
  20. foreach(lang C CXX Fortran)
  21. if(IS_ABSOLUTE "${CMAKE_${lang}_COMPILER}")
  22. get_filename_component(_hint "${CMAKE_${lang}_COMPILER}" PATH)
  23. list(APPEND _intel_xiar_hints ${_hint})
  24. endif()
  25. endforeach()
  26. find_program(XIAR NAMES xiar HINTS ${_intel_xiar_hints})
  27. mark_as_advanced(XIAR)
  28. endif()
  29. macro(__linux_compiler_intel lang)
  30. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
  31. set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
  32. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
  33. set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
  34. # We pass this for historical reasons. Projects may have
  35. # executables that use dlopen but do not set ENABLE_EXPORTS.
  36. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
  37. if(XIAR)
  38. # INTERPROCEDURAL_OPTIMIZATION
  39. set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo)
  40. set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO
  41. "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> "
  42. "${XIAR} -s <TARGET> ")
  43. endif()
  44. endmacro()