-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupLCG.sh
105 lines (92 loc) · 3.48 KB
/
setupLCG.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# User choice: choose a build mode (opt or dbg)
###lcg_mode=dbg
lcg_mode=opt
#-------------------------------------------------------------------------------
# Check that this setup script has been sourced
#-------------------------------------------------------------------------------
if [ "$BASH_SOURCE" = "$0" ]; then
echo "ERROR! The setup script was not sourced?" > /dev/stderr
exit 1
elif [ "$BASH_SOURCE" = "" ]; then
echo "ERROR! The setup script was not sourced from bash?" > /dev/stderr
return 1
fi
# Determine the path to this sourced script
topdir=`dirname ${BASH_SOURCE}`
topdir=`cd ${topdir}; pwd`
#-------------------------------------------------------------------------------
# Set up the build environment for BLUEFIN using LCG views
#-------------------------------------------------------------------------------
# Set up Boost and ROOT from LCG views on cvmfs
# Path to LCG view location on cvmfs
lcgviews=/cvmfs/sft.cern.ch/lcg/views
if [ ! -d ${lcgviews} ]; then
echo "ERROR! Directory '${lcgviews}' does not exist"
return 1
fi
# Check that the host architecture (LCG_arch) is supported
lcg_arch=$(make -f Makefile print-LCG_arch)
if [ "${lcg_arch}" != "x86_64" ]; then
echo "ERROR! Unknown architecture '${lcg_arch}'"
return 1
fi
CMAKE_CXX_FLAGS="-m64"
# Set up ninja and CMake just in case
# (On centos7 they are taken from the LCG views, but not on slc6)
export PATH=/cvmfs/sft.cern.ch/lcg/contrib/CMake/3.23.1/Linux-x86_64/bin:${PATH}
export PATH=/cvmfs/sft.cern.ch/lcg/contrib/ninja/1.10.0/Linux-x86_64:${PATH}
# Set CMAKE_BUILD_TYPE from the LCG build mode
if [ "${lcg_mode}" == "opt" ]; then
LCG_mode=${lcg_mode}
CMAKE_BUILD_TYPE=Release
elif [ "${lcg_mode}" == "dbg" ]; then
LCG_mode=${lcg_mode}
CMAKE_BUILD_TYPE=Debug
else
echo "ERROR! Unknown build mode '${lcg_mode}'"
return 1
fi
CMAKEFLAGS="-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE $CMAKEFLAGS"
# Check that the host O/S (LCG_os) is supported
# Use a different LCG view depending on LCG_os
# Use a different compiler depending on LCG_os
lcg_os=$(make -f Makefile print-LCG_os)
if [ "${lcg_os}" == "slc6" ]; then
lcg_compiler=gcc49
lcg_system=${lcg_arch}-${lcg_os}-${lcg_compiler}-${LCG_mode}
. ${lcgviews}/LCG_72a/${lcg_system}/setup.sh
elif [ "${lcg_os}" == "centos7" ]; then
lcg_compiler=gcc10
lcg_system=${lcg_arch}-${lcg_os}-${lcg_compiler}-${LCG_mode}
. ${lcgviews}/LCG_101/${lcg_system}/setup.sh
else
echo "ERROR! Unknown O/S ${lcg_os}"
return 1
fi
# Set the build flags (C++ std) appropriate to each compiler in LCG views
if [[ ${lcg_compiler} == *gcc10* ]]; then
CMAKE_CXX_FLAGS="-std=c++14 ${CMAKE_CXX_FLAGS}"
elif [[ ${lcg_compiler} == *gcc6* ]]; then
CMAKE_CXX_FLAGS="-std=c++14 ${CMAKE_CXX_FLAGS}"
elif [[ ${lcg_compiler} == *gcc5* ]]; then
CMAKE_CXX_FLAGS="-std=c++14 ${CMAKE_CXX_FLAGS}"
elif [[ ${lcg_compiler} == *gcc49* ]]; then
CMAKE_CXX_FLAGS="-std=c++1y ${CMAKE_CXX_FLAGS}"
elif [[ ${lcg_compiler} == *gcc48* ]]; then
CMAKE_CXX_FLAGS="-std=c++11 ${CMAKE_CXX_FLAGS}"
else
echo "ERROR! Unknown compiler ${lcg_compiler}"
return 1
fi
CMAKEFLAGS="-DCMAKE_CXX_FLAGS='$CMAKE_CXX_FLAGS' $CMAKEFLAGS"
# Additional settings for Makefile and ninja verbosity
VERBOSE=1
CMAKEFLAGS="-DCMAKE_VERBOSE_MAKEFILE=ON $CMAKEFLAGS"
# Use ninja by default, if it exists, in the build rules generated by CMake
if ninja --version > /dev/null 2>&1; then
CMAKEFLAGS="-GNinja $CMAKEFLAGS"
fi
# Export the additional variables relevant for the cmake build of BLUEFIN
export CMAKEFLAGS
export LCG_mode
export VERBOSE