Skip to content

Commit 2234bc5

Browse files
ADD include/cvector.h and UPDATE project structure and ADD build.sh script
1 parent a81c1fd commit 2234bc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4111
-0
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
project(cvector LANGUAGES C CXX)
3+
4+
include_directories(include)
5+
6+
add_library(cvector STATIC src/utils.c)
7+
8+
add_executable(example examples/example_usage.c)
9+
target_link_libraries(example cvector)

build.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
# Colors for output
4+
GREEN='\033[0;32m'
5+
RED='\033[0;31m'
6+
NC='\033[0m' # No color
7+
8+
# Directories
9+
BUILD_DIR="build"
10+
11+
# CMake options
12+
CMAKE_BUILD_TYPE="Debug" # Change to "Release" if needed
13+
BUILD_TESTS=OFF # Enable or disable tests
14+
15+
echo -e "${GREEN}--- Configuring and building with CMake ---${NC}"
16+
17+
# Configure and generate build files using CMake
18+
if ! cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -DBUILD_TESTS="$BUILD_TESTS" .; then
19+
echo -e "${RED}CMake configuration failed.${NC}"
20+
exit 1
21+
fi
22+
23+
# Build the project
24+
if ! cmake --build "$BUILD_DIR" --config "$CMAKE_BUILD_TYPE"; then
25+
echo -e "${RED}Build failed.${NC}"
26+
exit 1
27+
fi
28+
29+
echo -e "${GREEN}--- Build completed successfully ---${NC}"
30+
31+
# Run tests if enabled
32+
if [ "$BUILD_TESTS" = "ON" ]; then
33+
echo -e "${GREEN}--- Running tests ---${NC}"
34+
if ! ctest --test-dir "$BUILD_DIR" --output-on-failure; then
35+
echo -e "${RED}Some tests failed.${NC}"
36+
exit 1
37+
fi
38+
echo -e "${GREEN}All tests passed successfully.${NC}"
39+
fi
40+
41+
echo -e "${GREEN}Script completed successfully.${NC}"

0 commit comments

Comments
 (0)