68 lines
1.7 KiB
Bash
Executable File
68 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build script for CeresWrapper shared library on Linux
|
|
|
|
set -e # Exit on error
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${GREEN}Building CeresWrapper shared library...${NC}"
|
|
|
|
# Get script directory
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
BUILD_DIR="${SCRIPT_DIR}/build"
|
|
INSTALL_DIR="${SCRIPT_DIR}/install"
|
|
|
|
# Remove old build directory to avoid CMake cache conflicts
|
|
if [ -d "${BUILD_DIR}" ]; then
|
|
echo -e "${YELLOW}Removing old build directory...${NC}"
|
|
rm -rf "${BUILD_DIR}"
|
|
fi
|
|
|
|
# Create build directory
|
|
mkdir -p "${BUILD_DIR}"
|
|
cd "${BUILD_DIR}"
|
|
|
|
# Configure CMake
|
|
echo -e "${YELLOW}Configuring CMake...${NC}"
|
|
cmake .. \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
|
|
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
|
|
|
# Build
|
|
echo -e "${YELLOW}Building...${NC}"
|
|
make -j$(nproc)
|
|
|
|
# Install
|
|
echo -e "${YELLOW}Installing...${NC}"
|
|
make install
|
|
|
|
# Show results
|
|
echo -e "${GREEN}Build completed successfully!${NC}"
|
|
echo ""
|
|
echo "Library location: ${INSTALL_DIR}/lib/libceres_wrapper.so"
|
|
echo "Header location: ${INSTALL_DIR}/include/ceres_wrapper/ceres_wrapper.h"
|
|
echo ""
|
|
|
|
# Run tests if built
|
|
if [ -f "${BUILD_DIR}/ceres_wrapper_test" ]; then
|
|
echo -e "${YELLOW}Running tests...${NC}"
|
|
echo ""
|
|
"${BUILD_DIR}/ceres_wrapper_test"
|
|
TEST_RESULT=$?
|
|
echo ""
|
|
if [ $TEST_RESULT -eq 0 ]; then
|
|
echo -e "${GREEN}All tests passed!${NC}"
|
|
else
|
|
echo -e "${RED}Some tests failed!${NC}"
|
|
fi
|
|
echo ""
|
|
fi
|
|
|
|
echo "To use the library, set LD_LIBRARY_PATH:"
|
|
echo " export LD_LIBRARY_PATH=${INSTALL_DIR}/lib:\$LD_LIBRARY_PATH"
|