Last active
          January 30, 2023 13:43 
        
      - 
      
- 
        Save ojroques/9824c85cfd1eabafb3c0be5530c35b5a to your computer and use it in GitHub Desktop. 
    buildme.sh for CMake
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | #!/bin/bash | |
| set -e | |
| SOURCE_DIR=$(cd "$(dirname "$0")" && pwd) | |
| BUILD_DIR="$SOURCE_DIR"/build | |
| # Options | |
| CMAKE_BUILD_TYPE="RELEASE" | |
| # Remove old build environment | |
| if [[ "$1" == "--force" ]]; then | |
| rm -rf "$BUILD_DIR" | |
| fi | |
| # Generate build environment | |
| cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" \ | |
| -D CMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ | |
| -D CMAKE_EXPORT_COMPILE_COMMANDS="ON" | |
| # Build | |
| cmake --build "$BUILD_DIR" --parallel | |
| # Install | |
| sudo cmake --install "$BUILD_DIR" | |
| # Link compile commands | |
| ln -sfv "$BUILD_DIR"/compile_commands.json "$SOURCE_DIR"/compile_commands.json | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment