File tree Expand file tree Collapse file tree 2 files changed +76
-11
lines changed Expand file tree Collapse file tree 2 files changed +76
-11
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,25 @@ project(competitive_programming_library LANGUAGES CXX)
88set (CMAKE_CXX_STANDARD 20)
99set (CMAKE_CXX_STANDARD_REQUIRED ON )
1010
11- add_subdirectory (tools EXCLUDE_FROM_ALL )
12- add_subdirectory (benchmarks EXCLUDE_FROM_ALL )
13- add_subdirectory (cpl)
11+ option (BUILD_BENCHMARKS "Build benchmarks" OFF )
12+
13+ # Should almost* always build tests to verify correctness, regardless of if you intend to run them or not.
14+ # Only case where this should be omitted is if you are building this library as a dependency where
15+ # correctness can be assumed.
16+ option (BUILD_TESTING "Build tests" ON )
17+ option (BUILD_TOOLS "Build tools" OFF )
18+
19+ if (BUILD_BENCHMARKS)
20+ add_subdirectory (benchmarks)
21+ endif ()
1422
15- if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
23+ if (BUILD_TOOLS)
24+ add_subdirectory (tools)
25+ endif ()
26+
27+ if (BUILD_TESTING)
1628 enable_testing ()
1729 add_subdirectory (tests)
1830endif ()
31+
32+ add_subdirectory (cpl)
Original file line number Diff line number Diff line change 33# Copyright (c) Brandon Pacewic
44# SPDX-License-Identifier: MIT
55
6- if [ -d " build" ]; then
7- rm -rf build/
8- fi
6+ set -e
7+
8+ BUILD_DIR=" build"
9+ BUILD_TESTS=ON
10+ RUN_TESTS=OFF
11+ BUILD_BENCH=OFF
12+ BUILD_TOOLS=OFF
13+ CMAKE_GENERATOR=" Unix Makefiles"
14+
15+ while [ $# -gt 0 ]; do
16+ case " $1 " in
17+ --clean)
18+ rm -rf " $BUILD_DIR "
19+ shift
20+ ;;
21+ --build-tests)
22+ BUILD_TESTS=OFF
23+ shift
24+ ;;
25+ --test)
26+ RUN_TESTS=ON
27+ shift
28+ ;;
29+ --bench)
30+ BUILD_BENCH=ON
31+ shift
32+ ;;
33+ --tools)
34+ BUILD_TOOLS=ON
35+ shift
36+ ;;
37+ --build-dir=* )
38+ BUILD_DIR=" ${1#* =} "
39+ shift
40+ ;;
41+ --help)
42+ echo " Usage: $0 [--clean] [--build-tests] [--test] [--bench] [--tools] [--build-dir=<dir>] [--help]"
43+ exit 0
44+ ;;
45+ * )
46+ echo " Unknown option: $1 "
47+ exit 1
48+ ;;
49+ esac
50+ done
51+
52+ mkdir -p " $BUILD_DIR "
53+ cd " $BUILD_DIR "
54+
55+ cmake -G " $CMAKE_GENERATOR " \
56+ -DBUILD_TESTING=" $BUILD_TESTS " \
57+ -DBUILD_BENCHMARKS=" $BUILD_BENCH " \
58+ -DBUILD_TOOLS=" $BUILD_TOOLS " \
59+ ..
960
10- mkdir build/
11- cd build/
12- cmake -G " Unix Makefiles" ../
1361make
14- ctest --output-on-failure
62+
63+ if [ " $RUN_TESTS " = " ON" ]; then
64+ ctest --output-on-failure
65+ fi
You can’t perform that action at this time.
0 commit comments