@@ -51,6 +51,13 @@ HOST_COMPILER=${CXX:-g++} # $CXX if set, otherwise `g++`
5151CUDA_ARCHS=native # detect system's GPU architectures
5252CXX_STANDARD=17
5353
54+ # Initialize CMAKE_ARGS from environment variable if available
55+ if [ -n " ${CMAKE_ARGS:- } " ]; then
56+ read -ra CMAKE_ARGS <<< " $CMAKE_ARGS"
57+ else
58+ CMAKE_ARGS=()
59+ fi
60+
5461function usage {
5562 echo " cuCollections build script"
5663 echo " Usage: $0 [OPTIONS]"
@@ -62,9 +69,9 @@ function usage {
6269 echo " --prefix: Build directory prefix (Defaults to <repo_root>/build)"
6370 echo " -i/--infix: Build directory infix (Defaults to local)"
6471 echo " -d/--debug: Debug build"
65- echo " -p/--parallel: Build parallelism (Defaults to \ $ PARALLEL_LEVEL if set, otherwise the system's number of CPU cores)"
66- echo " --cuda: CUDA compiler (Defaults to \ $ CUDACXX if set, otherwise nvcc)"
67- echo " --cxx: Host compiler (Defaults to \ $ CXX if set, otherwise g++)"
72+ echo " -p/--parallel: Build parallelism (Defaults to $PARALLEL_LEVEL if set, otherwise the system's number of CPU cores)"
73+ echo " --cuda: CUDA compiler (Defaults to $CUDACXX if set, otherwise nvcc)"
74+ echo " --cxx: Host compiler (Defaults to $CXX if set, otherwise g++)"
6875 echo " --arch: Target CUDA arches, e.g. \" 60-real;70;80-virtual\" (Defaults to the system's native GPU archs)"
6976 echo " --std: CUDA/C++ standard (Defaults to 17)"
7077 echo " -v/-verbose/--verbose: Enable shell echo for debugging"
@@ -103,6 +110,16 @@ function usage {
103110 echo " Enables verbose mode for detailed output and builds with C++17 standard."
104111 echo " Build files will be written to <repo_root>/build/local and symlinked to <repo_root>/build/latest."
105112 echo
113+ echo " Using CMAKE_ARGS Environment Variable:"
114+ echo " $ CMAKE_ARGS=\" -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_FEATURE=ON\" $0 -t"
115+ echo " $ export CMAKE_ARGS=\" -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_FEATURE=ON\" "
116+ echo " $ $0 -t"
117+ echo " Uses CMAKE_ARGS environment variable to pass additional CMake options."
118+ echo " Can be overridden by using -- followed by specific arguments."
119+ echo
120+ echo " Pass-through to CMake:"
121+ echo " -- [CMake args...] Anything after -- is forwarded to CMake (overrides CMAKE_ARGS env var)"
122+ echo
106123 exit 1
107124}
108125
@@ -126,6 +143,7 @@ while [ "${#args[@]}" -ne 0 ]; do
126143 --arch) CUDA_ARCHS=" ${args[1]} " ; args=(" ${args[@]: 2} " );;
127144 --std) CXX_STANDARD=" ${args[1]} " ; args=(" ${args[@]: 2} " );;
128145 -v | -verbose | --verbose) VERBOSE=1; args=(" ${args[@]: 1} " );;
146+ --) CMAKE_ARGS=(" ${args[@]: 1} " ); break ;;
129147 -h | -help | --help) usage ;;
130148 * ) echo " Unrecognized option: ${args[0]} " ; usage ;;
131149 esac
@@ -156,14 +174,12 @@ if [ "$BUILD_TESTS" == "OFF" ] && [ "$BUILD_EXAMPLES" == "OFF" ] && [ "$BUILD_BE
156174 BUILD_BENCHMARKS=ON
157175fi
158176
177+ BUILD_DIR=" $BUILD_PREFIX /$BUILD_INFIX "
159178# Trigger clean (re-)build
160179if [ " $CLEAN_BUILD " -eq 1 ]; then
161180 rm -rf BUILD_DIR
162181fi
163-
164- BUILD_DIR=" $BUILD_PREFIX /$BUILD_INFIX "
165182mkdir -p $BUILD_DIR
166- export BUILD_DIR # TODO remove
167183
168184# The most recent build will be symlinked to cuCollections/build/latest
169185rm -f $BUILD_PREFIX /latest
@@ -188,10 +204,10 @@ CMAKE_OPTIONS="
188204 -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \
189205"
190206
191- echo " ========================================"
192- echo " -- START : $( date) "
207+ echo " [INFO]====== ========================================"
208+ echo " -- TIMESTAMP : $( date -u + " %Y-%m-%d %H:%M:%S UTC " ) "
193209echo " -- GIT_SHA: $( git rev-parse HEAD 2> /dev/null || echo ' Not a repository' ) "
194- echo " -- PWD : $( pwd) "
210+ echo " -- SRC_DIR : $( dirname $( pwd) ) "
195211echo " -- BUILD_DIR: ${BUILD_DIR} "
196212echo " -- BUILD_TYPE: ${BUILD_TYPE} "
197213echo " -- PARALLEL_LEVEL: ${PARALLEL_LEVEL} "
@@ -200,21 +216,30 @@ echo "-- BUILD_TESTS: ${BUILD_TESTS}"
200216echo " -- BUILD_EXAMPLES: ${BUILD_EXAMPLES} "
201217echo " -- BUILD_BENCHMARKS: ${BUILD_BENCHMARKS} "
202218
219+ if [ ${# CMAKE_ARGS[@]} -gt 0 ]; then
220+ echo " -- CMAKE_ARGS: ${CMAKE_ARGS[*]} "
221+ else
222+ echo " -- CMAKE_ARGS: (none)"
223+ fi
224+
225+
203226# configure
204- cmake -S .. -B $BUILD_DIR $CMAKE_OPTIONS
205- echo " ======================================== "
227+ echo " [CONFIGURE]======================================== "
228+ cmake -S .. -B $BUILD_DIR $CMAKE_OPTIONS " ${CMAKE_ARGS[@]} "
206229
207230if command -v sccache > /dev/null; then
208231 source " ./sccache_stats.sh" start
232+ else
233+ echo " sccache stats: N/A"
209234fi
210235
211236# build
237+ echo " [BUILD]============================================"
212238cmake --build $BUILD_DIR --parallel $PARALLEL_LEVEL
213- echo " ========================================"
214239echo " Build complete"
215240
216241if command -v sccache > /dev/null; then
217242 source " ./sccache_stats.sh" end
218243else
219244 echo " sccache stats: N/A"
220- fi
245+ fi
0 commit comments