BlueGeneP-base.cmake 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #
  4. # BlueGeneP base platform file.
  5. #
  6. # NOTE: Do not set your platform to "BlueGeneP-base". This file is included
  7. # by the real platform files. Use one of these two platforms instead:
  8. #
  9. # BlueGeneP-dynamic For dynamically linked builds
  10. # BlueGeneP-static For statically linked builds
  11. #
  12. # This platform file tries its best to adhere to the behavior of the MPI
  13. # compiler wrappers included with the latest BG/P drivers.
  14. #
  15. #
  16. # For BGP builds, we're cross compiling, but we don't want to re-root things
  17. # (e.g. with CMAKE_FIND_ROOT_PATH) because users may have libraries anywhere on
  18. # the shared filesystems, and this may lie outside the root. Instead, we set the
  19. # system directories so that the various system BGP CNK library locations are
  20. # searched first. This is not the clearest thing in the world, given IBM's driver
  21. # layout, but this should cover all the standard ones.
  22. #
  23. set(CMAKE_SYSTEM_LIBRARY_PATH
  24. /bgsys/drivers/ppcfloor/comm/default/lib # default comm layer (used by mpi compiler wrappers)
  25. /bgsys/drivers/ppcfloor/comm/sys/lib # DCMF, other lower-level comm libraries
  26. /bgsys/drivers/ppcfloor/runtime/SPI # other low-level stuff
  27. /bgsys/drivers/ppcfloor/gnu-linux/lib # CNK python installation directory
  28. /bgsys/drivers/ppcfloor/gnu-linux/powerpc-bgp-linux/lib # CNK Linux image -- standard runtime libs, pthread, etc.
  29. )
  30. #
  31. # This adds directories that find commands should specifically ignore for cross compiles.
  32. # Most of these directories are the includeand lib directories for the frontend on BG/P systems.
  33. # Not ignoring these can cause things like FindX11 to find a frontend PPC version mistakenly.
  34. # We use this on BG instead of re-rooting because backend libraries are typically strewn about
  35. # the filesystem, and we can't re-root ALL backend libraries to a single place.
  36. #
  37. set(CMAKE_SYSTEM_IGNORE_PATH
  38. /lib /lib64 /include
  39. /usr/lib /usr/lib64 /usr/include
  40. /usr/local/lib /usr/local/lib64 /usr/local/include
  41. /usr/X11/lib /usr/X11/lib64 /usr/X11/include
  42. /usr/lib/X11 /usr/lib64/X11 /usr/include/X11
  43. /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/include
  44. /usr/X11R7/lib /usr/X11R7/lib64 /usr/X11R7/include
  45. )
  46. #
  47. # Indicate that this is a unix-like system
  48. #
  49. set(UNIX 1)
  50. #
  51. # Library prefixes, suffixes, extra libs.
  52. #
  53. set(CMAKE_LINK_LIBRARY_SUFFIX "")
  54. set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # lib
  55. set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") # .a
  56. set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib
  57. set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so
  58. set(CMAKE_EXECUTABLE_SUFFIX "") # .exe
  59. set(CMAKE_DL_LIBS "dl")
  60. #
  61. # This macro needs to be called for dynamic library support. Unfortunately on BGP,
  62. # We can't support both static and dynamic links in the same platform file. The
  63. # dynamic link platform file needs to call this explicitly to set up dynamic linking.
  64. #
  65. macro(__BlueGeneP_set_dynamic_flags compiler_id lang)
  66. if (${compiler_id} STREQUAL XL)
  67. # Flags for XL compilers if we explicitly detected XL
  68. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic")
  69. set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-qpie")
  70. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic")
  71. set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink")
  72. set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc")
  73. else()
  74. # Assume flags for GNU compilers (if the ID is GNU *or* anything else).
  75. set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
  76. set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
  77. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
  78. set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
  79. set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic")
  80. endif()
  81. # Both toolchains use the GNU linker on BG/P, so these options are shared.
  82. set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,")
  83. set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,")
  84. set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,")
  85. set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic")
  86. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib
  87. set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty
  88. set(BGP_${lang}_DEFAULT_EXE_FLAGS
  89. "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
  90. set(CMAKE_${lang}_LINK_EXECUTABLE
  91. "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGP_${lang}_DYNAMIC_EXE_FLAGS} ${BGP_${lang}_DEFAULT_EXE_FLAGS}")
  92. endmacro()
  93. #
  94. # This macro needs to be called for static builds. Right now it just adds -Wl,-relax
  95. # to the link line.
  96. #
  97. macro(__BlueGeneP_set_static_flags compiler_id lang)
  98. set(BGP_${lang}_DEFAULT_EXE_FLAGS
  99. "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
  100. set(CMAKE_${lang}_LINK_EXECUTABLE
  101. "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGP_${lang}_DEFAULT_EXE_FLAGS}")
  102. endmacro()