-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbuild_with_cmake.sh
More file actions
executable file
·58 lines (46 loc) · 1.41 KB
/
build_with_cmake.sh
File metadata and controls
executable file
·58 lines (46 loc) · 1.41 KB
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
#!/usr/bin/env bash
set -ex # Print each command and exit on error
# Detect OS for library path
OS="$(uname)"
if [[ "$OS" == "Darwin" ]]; then
LIB_PATH_VAR="DYLD_LIBRARY_PATH"
#CMAKE_FLAGS="-G Xcode"
else
LIB_PATH_VAR="LD_LIBRARY_PATH"
fi
# Create and enter build directory
mkdir -p build
cd build
# Get absolute path to current directory (fallback for macOS without realpath)
get_abs_path() {
if command -v realpath >/dev/null 2>&1; then
realpath "$1"
else
# Fallback using Python for macOS
python3 -c "import os; print(os.path.abspath('$1'))"
fi
}
ROOT_DIR="$(get_abs_path ..)"
# Set default paths
if [ -z "$1" ]; then
DDS_HOME="$ROOT_DIR/dds"
QUICKFIX_HOME="$ROOT_DIR/quickfix"
LOG4CXX_HOME="$ROOT_DIR/log4cxx"
INSTALL_PREFIX="$ROOT_DIR/DistributedATS"
else
INSTALL_PREFIX="$(get_abs_path "$1")"
fi
# Run cmake and build
cmake ${CMAKE_FLAGS:-} .. -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX"
cmake --build . --target install --config Debug -v
# Write the environment setup script
cat <<EOM > "$INSTALL_PREFIX/dats_env.sh"
#!/usr/bin/env bash
export DATS_HOME="$INSTALL_PREFIX"
export DDS_HOME="$DDS_HOME"
export QUICKFIX_HOME="$QUICKFIX_HOME"
export LOG4CXX_HOME="$LOG4CXX_HOME"
export $LIB_PATH_VAR="\$DATS_HOME/lib:\$DDS_HOME/lib:\$QUICKFIX_HOME/lib:\$LOG4CXX_HOME/lib:\$$LIB_PATH_VAR"
export LOG4CXX_CONFIGURATION="\$DATS_HOME/config/log4cxx.xml"
EOM
chmod +x "$INSTALL_PREFIX/dats_env.sh"