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