Updated to allow for static and shared libs (yes, you can use shared libs on a cray). The expectation is that your toolchain file will have the appropriate logic to deal with this. Something like:
set(CMAKE_SYSTEM_NAME ComputeNodeLinux) ... if(DEFINED ENV{CRAYPE_LINK_TYPE} AND "$ENV{CRAYPE_LINK_TYPE}" EQUALS "dynamic") set(_CRAY_LINK_OPTS "-dynamic") else() # The default behavior if not specified is explicit static-only linkage set(_CRAY_LINK_OPTS "-static") # If we're using static linking then make sure that CMake explicitly # only looks for static libraries set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") endif() ... set(CMAKE_C_FLAGS "... ${_CRAY_LINK}" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS "... ${_CRAY_LINK}" CACHE STRING "" FORCE) set(CMAKE_Fortran_FLAGS "... ${_CRAY_LINK}" CACHE STRING "" FORCE) - Chuck On Thu, Aug 14, 2014 at 6:46 PM, Chuck Atkins <chuck.atk...@kitware.com> wrote: > I've been using CMake on Cray's quite a bit lately and some of the cross > compilation leaves a bit to be desired. No particular capability is really > missing but the "foo" of getting things to build and work seems to be > rather dispersed across various individuals and corners of the internet. > I'd like to start pooling some of this together to be shipped with CMake. > > For starters, I'd like to add a Platform file for the cross compilation > target of ComputeNodeLinux. While it's not entirely different from running > Linux natively, some assumptions from native host Linux build environments > aren't valid and building for it explicitly needs search paths defined by > the Cray environment modules. It's also distinctly different from the > commonly used Catamount (which is very far removed from the currently used > OS). Attached is a patch for a new Platform file that uses information from > the loaded environment modules on the login nodes to define it's > appropriate path and version info. I've been using this successfully on > Garnet (an XE6) and Titan (an XK7). > > - Chuck >
From f386ceb9f1f35c873ce34420bc5d143868c6e8d6 Mon Sep 17 00:00:00 2001 From: Chuck Atkins <chuck.atk...@kitware.com> Date: Thu, 14 Aug 2014 18:30:01 -0400 Subject: [PATCH] Add a platform file for cross-compiling to Cray Compute Node Linux This platform module is designed t be used with the Cray Programming Environment. Esentially this means that it will get it's various options and settings through variables loaded in "environment modules" used on modern Crays. --- Modules/Platform/ComputeNodeLinux.cmake | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Modules/Platform/ComputeNodeLinux.cmake diff --git a/Modules/Platform/ComputeNodeLinux.cmake b/Modules/Platform/ComputeNodeLinux.cmake new file mode 100644 index 0000000..ae6aa94 --- /dev/null +++ b/Modules/Platform/ComputeNodeLinux.cmake @@ -0,0 +1,36 @@ +# Compute Node Linux doesn't quite work the same as native Linux so all of this +# needs to be custom. We use the variables defined through Cray's environment +# modules to set up the right paths for things. + +if(NOT CMAKE_SYSTEM_VERSION) + if(NOT DEFINED ENV{XTOS_VERSION}) + message(FATAL_ERROR "The CMAKE_SYSTEM_VERSION variable is not set and the XTOS_VERSION environment variable is not defined. The ComputeNodeLinux CMake platform module either requires it to be manually set or the XTOS_VERSION environment variable to be available. This usually means that the necessary PrgEnv-* module is not loaded") + else() + set(CMAKE_SYSTEM_VERSION "$ENV{XTOS_VERSION}") + endif() +endif() + +# Contrary to popular belief, you can use shared libraries on a Cray +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") + +set(CMAKE_FIND_LIBRARY_PREFIXES "lib") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") + +# Make sure we have the appropriate environment loaded +if(NOT DEFINED ENV{SYSROOT_DIR}) + message(FATAL_ERROR "The SYSROOT_DIR environment variable is not defined but the ComputeNodeLinux CMake platform module requires it. This usually means that the necessary PrgEnv-* module is not loaded") +endif() + +# Set up system search paths that CMake will use to look for libraries and +# include files. These will be the standard UNIX search paths but rooted +# in the SYSROOT of the computes nodes. +include(Platform/UnixPaths) +set(CMAKE_FIND_ROOT_PATH "$ENV{SYSROOT_DIR}") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -- 1.9.3
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake-developers