CrayLinuxEnvironment.cmake 3.1 KB

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