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# Blue Gene/Q base platform file. 7# 8# NOTE: Do not set your platform to "BlueGeneQ-base". This file is 9# included by the real platform files. Use one of these two platforms 10# instead: 11# 12# BlueGeneQ-dynamic For dynamically linked executables 13# BlueGeneQ-static For statically linked executables 14# 15# The platform you choose doesn't affect whether or not you can build 16# shared or static libraries -- it ONLY changs whether exeuatbles are linked 17# statically or dynamically. 18# 19# This platform file tries its best to adhere to the behavior of the MPI 20# compiler wrappers included with the latest BG/P drivers. 21# 22 23# 24# This adds directories that find commands should specifically ignore 25# for cross compiles. Most of these directories are the includeand 26# lib directories for the frontend on BG/P systems. Not ignoring 27# these can cause things like FindX11 to find a frontend PPC version 28# mistakenly. We use this on BG instead of re-rooting because backend 29# libraries are typically strewn about the filesystem, and we can't 30# re-root ALL backend libraries to a single place. 31# 32set(CMAKE_SYSTEM_IGNORE_PATH 33 /lib /lib64 /include 34 /usr/lib /usr/lib64 /usr/include 35 /usr/local/lib /usr/local/lib64 /usr/local/include 36 /usr/X11/lib /usr/X11/lib64 /usr/X11/include 37 /usr/lib/X11 /usr/lib64/X11 /usr/include/X11 38 /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/include 39 /usr/X11R7/lib /usr/X11R7/lib64 /usr/X11R7/include 40) 41 42# 43# Indicate that this is a unix-like system 44# 45set(UNIX 1) 46 47# 48# Library prefixes, suffixes, extra libs. 49# 50set(CMAKE_LINK_LIBRARY_SUFFIX "") 51set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # lib 52set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") # .a 53 54set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib 55set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so 56set(CMAKE_EXECUTABLE_SUFFIX "") # .exe 57 58set(CMAKE_DL_LIBS "dl") 59 60# 61# BG/Q supports dynamic libraries regardless of whether we're building 62# static or dynamic *executables*. 63# 64set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) 65set(CMAKE_FIND_LIBRARY_PREFIXES "lib") 66 67# 68# For BGQ builds, we're cross compiling, but we don't want to re-root things 69# (e.g. with CMAKE_FIND_ROOT_PATH) because users may have libraries anywhere on 70# the shared filesystems, and this may lie outside the root. Instead, we set the 71# system directories so that the various system BG CNK library locations are 72# searched first. This is not the clearest thing in the world, given IBM's driver 73# layout, but this should cover all the standard ones. 74# 75macro(__BlueGeneQ_common_setup compiler_id lang) 76 # Need to use the version of the comm lib compiled with the right compiler. 77 set(__BlueGeneQ_commlib_dir gcc) 78 if (${compiler_id} STREQUAL XL) 79 set(__BlueGeneQ_commlib_dir xl) 80 endif() 81 82 set(CMAKE_SYSTEM_LIBRARY_PATH 83 /bgsys/drivers/ppcfloor/comm/default/lib # default comm layer (used by mpi compiler wrappers) 84 /bgsys/drivers/ppcfloor/comm/${__BlueGeneQ_commlib_dir}/lib # PAMI, other lower-level comm libraries 85 /bgsys/drivers/ppcfloor/gnu-linux/lib # CNK python installation directory 86 /bgsys/drivers/ppcfloor/gnu-linux/powerpc64-bgq-linux/lib # CNK Linux image -- standard runtime libs, pthread, etc. 87 ) 88 89 # Add all the system include paths. 90 set(CMAKE_SYSTEM_INCLUDE_PATH 91 /bgsys/drivers/ppcfloor/comm/sys/include 92 /bgsys/drivers/ppcfloor/ 93 /bgsys/drivers/ppcfloor/spi/include 94 /bgsys/drivers/ppcfloor/spi/include/kernel/cnk 95 /bgsys/drivers/ppcfloor/comm/${__BlueGeneQ_commlib_dir}/include 96 ) 97 98 # Ensure that the system directories are included with the regular compilers, as users will expect this 99 # to do the same thing as the MPI compilers, which add these flags. 100 set(BGQ_SYSTEM_INCLUDES "") 101 foreach(dir ${CMAKE_SYSTEM_INCLUDE_PATH}) 102 string(APPEND BGQ_SYSTEM_INCLUDES " -I${dir}") 103 endforeach() 104 set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") 105 set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${BGQ_SYSTEM_INCLUDES} <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") 106 107 # 108 # Code below does setup for shared libraries. That this is done 109 # regardless of whether the platform is static or dynamic -- you can make 110 # shared libraries even if you intend to make static executables, you just 111 # can't make a dynamic executable if you use the static platform file. 112 # 113 if (${compiler_id} STREQUAL XL) 114 # Flags for XL compilers if we explicitly detected XL 115 set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") 116 set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") 117 else() 118 # Assume flags for GNU compilers (if the ID is GNU *or* anything else). 119 set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") 120 set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") 121 endif() 122 123 # Both toolchains use the GNU linker on BG/P, so these options are shared. 124 set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") 125 set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,") 126 set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,") 127 set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic") 128 set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib 129 set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty 130 131endmacro() 132 133# 134# This macro needs to be called for dynamic library support. Unfortunately on BG, 135# We can't support both static and dynamic links in the same platform file. The 136# dynamic link platform file needs to call this explicitly to set up dynamic linking. 137# 138macro(__BlueGeneQ_setup_dynamic compiler_id lang) 139 __BlueGeneQ_common_setup(${compiler_id} ${lang}) 140 141 if (${compiler_id} STREQUAL XL) 142 set(BGQ_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") 143 else() 144 set(BGQ_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") 145 endif() 146 147 # For dynamic executables, need to provide special BG/Q arguments. 148 set(BGQ_${lang}_DEFAULT_EXE_FLAGS 149 "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") 150 set(CMAKE_${lang}_LINK_EXECUTABLE 151 "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGQ_${lang}_DYNAMIC_EXE_FLAGS} ${BGQ_${lang}_DEFAULT_EXE_FLAGS}") 152endmacro() 153 154# 155# This macro needs to be called for static builds. Right now it just adds -Wl,-relax 156# to the link line. 157# 158macro(__BlueGeneQ_setup_static compiler_id lang) 159 __BlueGeneQ_common_setup(${compiler_id} ${lang}) 160 161 # For static executables, use default link settings. 162 set(BGQ_${lang}_DEFAULT_EXE_FLAGS 163 "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") 164 set(CMAKE_${lang}_LINK_EXECUTABLE 165 "<CMAKE_${lang}_COMPILER> -Wl,-relax ${BGQ_${lang}_DEFAULT_EXE_FLAGS}") 166endmacro() 167