CrayLinuxEnvironment.cmake 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # CrayLinuxEnvironment: loaded by users cross-compiling on a Cray front-end
  2. # node by specifying "-DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment" to cmake
  3. if(DEFINED ENV{CRAYOS_VERSION})
  4. set(CMAKE_SYSTEM_VERSION "$ENV{CRAYOS_VERSION}")
  5. elseif(DEFINED ENV{XTOS_VERSION})
  6. set(CMAKE_SYSTEM_VERSION "$ENV{XTOS_VERSION}")
  7. elseif(EXISTS /etc/opt/cray/release/cle-release)
  8. file(STRINGS /etc/opt/cray/release/cle-release release REGEX "^RELEASE=.*")
  9. string(REGEX REPLACE "^RELEASE=(.*)$" "\\1" CMAKE_SYSTEM_VERSION "${release}")
  10. unset(release)
  11. elseif(EXISTS /etc/opt/cray/release/clerelease)
  12. file(READ /etc/opt/cray/release/clerelease CMAKE_SYSTEM_VERSION)
  13. endif()
  14. # Guard against multiple messages
  15. if(NOT __CrayLinuxEnvironment_message)
  16. set(__CrayLinuxEnvironment_message 1 CACHE INTERNAL "")
  17. if(NOT CMAKE_SYSTEM_VERSION)
  18. message(STATUS "CrayLinuxEnvironment: Unable to determine CLE version. This platform file should only be used from inside the Cray Linux Environment for targeting compute nodes (NIDs).")
  19. else()
  20. message(STATUS "Cray Linux Environment ${CMAKE_SYSTEM_VERSION}")
  21. endif()
  22. endif()
  23. # All cray systems are x86 CPUs and have been for quite some time
  24. # Note: this may need to change in the future with 64-bit ARM
  25. set(CMAKE_SYSTEM_PROCESSOR "x86_64")
  26. # Don't override shared lib support if it's already been set and possibly
  27. # overridden elsewhere by the CrayPrgEnv module
  28. if(NOT CMAKE_FIND_LIBRARY_SUFFIXES)
  29. set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
  30. set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
  31. endif()
  32. # The rest of this file is based on UnixPaths.cmake, adjusted for Cray
  33. # add the install directory of the running cmake to the search directories
  34. # CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up
  35. get_filename_component(__cmake_install_dir "${CMAKE_ROOT}" PATH)
  36. get_filename_component(__cmake_install_dir "${__cmake_install_dir}" PATH)
  37. # Note: Some Cray's have the SYSROOT_DIR variable defined, pointing to a copy
  38. # of the NIDs userland. If so, then we'll use it. Otherwise, just assume
  39. # the userland from the login node is ok
  40. # List common installation prefixes. These will be used for all
  41. # search types.
  42. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  43. # Standard
  44. $ENV{SYSROOT_DIR}/usr/local $ENV{SYSROOT_DIR}/usr $ENV{SYSROOT_DIR}/
  45. # CMake install location
  46. "${__cmake_install_dir}"
  47. )
  48. if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
  49. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  50. # Project install destination.
  51. "${CMAKE_INSTALL_PREFIX}"
  52. )
  53. if(CMAKE_STAGING_PREFIX)
  54. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  55. # User-supplied staging prefix.
  56. "${CMAKE_STAGING_PREFIX}"
  57. )
  58. endif()
  59. endif()
  60. _cmake_record_install_prefix()
  61. list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
  62. $ENV{SYSROOT_DIR}/usr/include/X11
  63. )
  64. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  65. $ENV{SYSROOT_DIR}/usr/local/lib64
  66. $ENV{SYSROOT_DIR}/usr/lib64
  67. $ENV{SYSROOT_DIR}/lib64
  68. )
  69. list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
  70. $ENV{SYSROOT_DIR}/usr/local/lib64
  71. $ENV{SYSROOT_DIR}/usr/lib64
  72. $ENV{SYSROOT_DIR}/lib64
  73. )
  74. # Enable use of lib64 search path variants by default.
  75. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)