Skip to content

Instantly share code, notes, and snippets.

@bb1950328
Created December 28, 2021 17:40
Show Gist options
  • Save bb1950328/4a023a96594fb11599558cbfcd748606 to your computer and use it in GitHub Desktop.
Save bb1950328/4a023a96594fb11599558cbfcd748606 to your computer and use it in GitHub Desktop.
CMake: create build dir, configure and build
#!/usr/bin/env bash
build_type_arg=${1:-release}
build_type_lower=${build_type_arg,,}
if ! [[ "$build_type_lower" =~ ^(debug|release|relwithdebinfo|minsizerel)$ ]]; then
echo "invalid build type specified"
exit 1;
fi
build_dir="cmake-build-${build_type_lower}"
mkdir build_dir
cmake -S . -B build_dir -DCMAKE_BUILD_TYPE=$build_type_arg
cmake --build $build_dir -- -j${nproc}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment