-
Notifications
You must be signed in to change notification settings - Fork 7
/
run-cmake.sh
executable file
·54 lines (44 loc) · 1.24 KB
/
run-cmake.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
#!/bin/sh
: ${BUILD_TYPE:="Release"}
: ${BUILD_DIR:="Build/${BUILD_TYPE}"}
if [ "${BUILD_TYPE}" == "Debug" ]; then
: ${BUILD_SHARED_LIBS:="OFF"}
else
: ${BUILD_SHARED_LIBS:="ON"}
fi
if [ ! -d "${LLVM_PREFIX}" ]; then
echo "LLVM_PREFIX not specified"
echo "Try: LLVM_PREFIX=/path/to/llvm/build $0"
exit 1
fi
clang="${LLVM_PREFIX}/bin/clang"
include_dirs="/usr/include /usr/local/include"
libcxx=""
if [ "`uname -s`" == "Darwin" ]; then
include_dirs="${include_dirs} /Library/Developer/CommandLineTools/usr/include"
include_dirs="${include_dirs} /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"
fi
for include in ${include_dirs}
do
cppinc="${include}/c++/v1"
if [ -d "${cppinc}" ]; then libcxx=${cppinc}; break; fi
done
if [ "${libcxx}" = "" ]; then
echo "No libc++ in ${include_dirs}"
exit 1
fi
if [ "${NOCLEAN}" == "" ]; then
rm -rf ${BUILD_DIR}
fi
mkdir -p ${BUILD_DIR} || exit 1
echo '*' > ${BUILD_DIR}/.gitignore
cd ${BUILD_DIR} || exit 1
PATH=${PATH}:${LLVM_PREFIX}/bin \
cmake \
-G Ninja \
-D CMAKE_BUILD_TYPE=${BUILD_TYPE} \
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
-D LLVM_DIR="${LLVM_PREFIX}/share/llvm/cmake" \
-D CMAKE_C_COMPILER="${clang}" \
-D CMAKE_CXX_COMPILER="${clang}++" \
../..