Created
December 28, 2021 17:40
-
-
Save bb1950328/4a023a96594fb11599558cbfcd748606 to your computer and use it in GitHub Desktop.
CMake: create build dir, configure and build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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