-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·47 lines (32 loc) · 1.49 KB
/
build.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
#!/bin/sh
# ## Description
# Assuming the `conanfile` does not have a `layout` field.
#set -e
#set -x
script_dir=$(dirname "$(readlink -f "$0")")
cd $script_dir
# ## Build
rm -rf build
does_exist_conanfile=false
[ -f "conanfile.txt" -o -f "conanfile.py" ] && does_exist_conanfile=true
conan_output_folder="generators"
# Ref: [Building for multiple configurations: Release, Debug, Static and Shared](Building for multiple configurations: Release, Debug, Static and Shared)
#[ $does_exist_conanfile = true ] && conan install . --build=missing --output-folder=build/$conan_output_folder -s "build_type=Debug"
# Ref: [Build the project with Debug while dependencies with Release](https://github.com/conan-io/conan/issues/13478#issuecomment-1475389368)
[ $does_exist_conanfile = true ] && conan install . --build=missing --output-folder=build/$conan_output_folder -s "&:build_type=Debug" -s "build_type=Release"
[ ! -d build ] && mkdir build
cd build
[ $does_exist_conanfile = true ] && . $conan_output_folder/conanbuild.sh
# ## Generate build system
#compiler="env CC=/usr/bin/clang CXX=/usr/bin/clang++"
compiler="env CC=/usr/bin/gcc CXX=/usr/bin/g++"
cmake_option=("-G Ninja")
if [ $does_exist_conanfile = true ]; then
cmake_option+=("-DCMAKE_TOOLCHAIN_FILE=$conan_output_folder/conan_toolchain.cmake")
cmake_option+=("-DCMAKE_BUILD_TYPE=Debug")
fi
$compiler cmake .. ${cmake_option[*]}
# ## Compile/Link
cmake --build .
[ $does_exist_conanfile = true ] && . $conan_output_folder/deactivate_conanbuild.sh
cd ..