From 64b53efe3eb8e1279b83a8df44755c2a852dc836 Mon Sep 17 00:00:00 2001 From: Tammo Ippen Date: Fri, 29 Apr 2016 11:35:39 +0200 Subject: [PATCH 1/3] Have target/host triples as in autotools Many internal functions, e.g. memory_thisjob, require the target triples "arch-vendor-os" as they were supplied with autotools. The file GetTriple.cmake adds functions for retrieving these. The rest of this commit sets the appropriate defines in config.h.in --- CMakeLists.txt | 4 ++ cmake/GetTriple.cmake | 89 +++++++++++++++++++++++++++++++++++++++++ libnestutil/config.h.in | 8 ++-- 3 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 cmake/GetTriple.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 57ec94d719..6bec160eef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,10 @@ find_program( SED NAMES sed gsed ) ################## CPack, checks, ... in external modules ################## ################################################################################ +include( GetTriple ) +get_host_triple( NEST_HOST_TRIPLE NEST_HOST_ARCH NEST_HOST_VENDOR NEST_HOST_OS ) +get_target_triple( NEST_TARGET_TRIPLE NEST_TARGET_ARCH NEST_TARGET_VENDOR NEST_TARGET_OS ) + include( CPackVariables ) include( CheckIncludesSymbols ) include( ProcessOptions ) diff --git a/cmake/GetTriple.cmake b/cmake/GetTriple.cmake new file mode 100644 index 0000000000..bc39d9a559 --- /dev/null +++ b/cmake/GetTriple.cmake @@ -0,0 +1,89 @@ +# cmake/GetTriple.cmake +# +# This file is part of NEST. +# +# Copyright (C) 2004 The NEST Initiative +# +# NEST is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# NEST is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with NEST. If not, see . + +# Based on libcxx/cmake/Modules/GetTriple.cmake + +# Define functions to get the host and target triple. + +function(get_host_triple out out_arch out_vendor out_os) + # Get the architecture. + set( arch "${CMAKE_HOST_SYSTEM_PROCESSOR}" ) + # i686 is an enhanced version of x86 + if ( arch STREQUAL "x86" ) + set( arch "i686" ) + endif () + + # Get the vendor. + if ( "${CMAKE_HOST_SYSTEM_NAME}" MATCHES "^Darwin.*" ) + set( vendor "apple" ) + else () + set( vendor "pc" ) + endif () + + # Get os. + if ( "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows" ) + set( os "win32" ) + else () + string( TOLOWER "${CMAKE_HOST_SYSTEM_NAME}" os ) + endif () + + set( triple "${arch}-${vendor}-${os}" ) + + # return values + set( ${out} ${triple} PARENT_SCOPE ) + set( ${out_arch} ${arch} PARENT_SCOPE ) + set( ${out_vendor} ${vendor} PARENT_SCOPE ) + set( ${out_os} ${os} PARENT_SCOPE ) + + message( STATUS "Host triple: ${triple}" ) +endfunction () + + +function(get_target_triple out out_arch out_vendor out_os) + # Get the architecture. + set( arch "${CMAKE_SYSTEM_PROCESSOR}" ) + # i686 is an enhanced version of x86 + if ( arch STREQUAL "x86" ) + set( arch "i686" ) + endif () + + # Get the vendor. + if ( "${CMAKE_SYSTEM_NAME}" MATCHES "^Darwin.*") + set( vendor "apple" ) + else () + set( vendor "pc" ) + endif () + + # Get os. + if ( "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" ) + set( os "win32" ) + else () + string( TOLOWER "${CMAKE_SYSTEM_NAME}" os ) + endif () + + set(triple "${arch}-${vendor}-${os}") + + # return values + set( ${out} ${triple} PARENT_SCOPE ) + set( ${out_arch} ${arch} PARENT_SCOPE ) + set( ${out_vendor} ${vendor} PARENT_SCOPE ) + set( ${out_os} ${os} PARENT_SCOPE ) + + message(STATUS "Target triple: ${triple}") +endfunction() diff --git a/libnestutil/config.h.in b/libnestutil/config.h.in index bd1f727689..0dc3d5bc66 100644 --- a/libnestutil/config.h.in +++ b/libnestutil/config.h.in @@ -37,10 +37,10 @@ #define NEST_VERSION_PATCHLEVEL "@NEST_VERSION_PATCHLEVEL@" // TODO NEST_HOST and NEST_HOSTVENDOR not available with cmake -#define NEST_HOST "@CMAKE_HOST_SYSTEM_PROCESSOR@-@host_vendor@-@CMAKE_HOST_SYSTEM@" -#define NEST_HOSTOS "@CMAKE_HOST_SYSTEM@" -#define NEST_HOSTCPU "@CMAKE_HOST_SYSTEM_PROCESSOR@" -#define NEST_HOSTVENDOR "@host_vendor@" +#define NEST_HOST "@NEST_TARGET_TRIPLE@" +#define NEST_HOSTOS "@NEST_TARGET_OS@" +#define NEST_HOSTCPU "@NEST_TARGET_ARCH@" +#define NEST_HOSTVENDOR "@NEST_TARGET_VENDOR@" #define NEST_SOURCEDIR "@PKGSRCDIR@" #define NEST_BUILDDIR "@PKGBUILDDIR@" From 5bd473731ff8d5ca8e65c8738dccdc094dbabd48 Mon Sep 17 00:00:00 2001 From: Tammo Ippen Date: Mon, 9 May 2016 10:55:26 +0200 Subject: [PATCH 2/3] Set correct system name and processor for BG/Q --- cmake/Platform/BlueGeneQ_Base.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/Platform/BlueGeneQ_Base.cmake b/cmake/Platform/BlueGeneQ_Base.cmake index 4ff4dfbcea..ec26a259fa 100644 --- a/cmake/Platform/BlueGeneQ_Base.cmake +++ b/cmake/Platform/BlueGeneQ_Base.cmake @@ -94,7 +94,8 @@ # # Based on the BlueGeneQ-base platform file -set( CMAKE_SYSTEM_NAME BlueGeneQ_Base CACHE STRING "Cross-compiling for BlueGene/Q" FORCE ) +set( CMAKE_SYSTEM_NAME Linux CACHE STRING "Cross-compiling for BlueGene/Q" FORCE ) +set( CMAKE_SYSTEM_PROCESSOR ppc64 ) # Set enable-bluegene for main CMakeList.txt set( enable-bluegene "Q" CACHE STRING "Configure for BlueGene." FORCE ) From f56ac1d8c6e9ee43ba724e1ef35bd2cb7dc2f375 Mon Sep 17 00:00:00 2001 From: Tammo Ippen Date: Mon, 9 May 2016 11:00:48 +0200 Subject: [PATCH 3/3] set vendors for our supported targets --- cmake/GetTriple.cmake | 3 +++ cmake/Platform/BlueGeneQ_Base.cmake | 1 + cmake/Platform/Fujitsu-Sparc64.cmake | 1 + 3 files changed, 5 insertions(+) diff --git a/cmake/GetTriple.cmake b/cmake/GetTriple.cmake index bc39d9a559..79bf04dc53 100644 --- a/cmake/GetTriple.cmake +++ b/cmake/GetTriple.cmake @@ -66,6 +66,9 @@ function(get_target_triple out out_arch out_vendor out_os) # Get the vendor. if ( "${CMAKE_SYSTEM_NAME}" MATCHES "^Darwin.*") set( vendor "apple" ) + elseif ( TRIPLET_VENDOR ) + # In our own tool chain files we define vendors. + set( vendor "${TRIPLET_VENDOR}" ) else () set( vendor "pc" ) endif () diff --git a/cmake/Platform/BlueGeneQ_Base.cmake b/cmake/Platform/BlueGeneQ_Base.cmake index ec26a259fa..a47d4db1b7 100644 --- a/cmake/Platform/BlueGeneQ_Base.cmake +++ b/cmake/Platform/BlueGeneQ_Base.cmake @@ -96,6 +96,7 @@ # Based on the BlueGeneQ-base platform file set( CMAKE_SYSTEM_NAME Linux CACHE STRING "Cross-compiling for BlueGene/Q" FORCE ) set( CMAKE_SYSTEM_PROCESSOR ppc64 ) +set( TRIPLET_VENDOR ibm ) # Set enable-bluegene for main CMakeList.txt set( enable-bluegene "Q" CACHE STRING "Configure for BlueGene." FORCE ) diff --git a/cmake/Platform/Fujitsu-Sparc64.cmake b/cmake/Platform/Fujitsu-Sparc64.cmake index 731cb470eb..5992c94cce 100644 --- a/cmake/Platform/Fujitsu-Sparc64.cmake +++ b/cmake/Platform/Fujitsu-Sparc64.cmake @@ -20,6 +20,7 @@ # the name of the target operating system set( CMAKE_SYSTEM_NAME Linux CACHE STRING "Cross-compiling for Fujitsu Sparc64, with MPI" ) set( CMAKE_SYSTEM_PROCESSOR "s64fx" ) +set( TRIPLET_VENDOR fujitsu ) # # Set k-computer for main CMakeList.txt