Giter VIP home page Giter VIP logo

Hi there 👋

Here are some common CMake CLI (Command Line Interface) commands used in typical workflows:

1. Generate Build Files

Generate build files using a CMake generator (e.g., Makefile, Ninja, Visual Studio):

cmake -S <source_directory> -B <build_directory> -G <generator_name> -S: Specify the source directory containing the CMakeLists.txt. -B: Specify the build directory where the build files will be generated. -G: Specify the generator (e.g., "Unix Makefiles", "Ninja", "Visual Studio 16 2019"). Example:

cmake -S . -B build -G "Unix Makefiles"

2. Configure a Project

Set CMake variables during configuration:

cmake -S <source_directory> -B <build_directory> -D<variable>=<value> -D<variable>=<value>:

Define a CMake variable. You can define multiple variables by adding more -D flags. Example:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON

3. Build a Project

Build the project after configuration:

cmake --build <build_directory> --target <target_name> --config <configuration> --target: Specify a particular target to build (optional). --config: Specify the build configuration (e.g., Debug, Release).

Example:

cmake --build build --config Release

4. Install the Project

Install the build outputs to a specified directory:

cmake --install <build_directory> --prefix <install_directory>

Example:

cmake --install build --prefix /usr/local

5. Run Tests

Run tests after building the project:

ctest --test-dir <build_directory> --output-on-failure --output-on-failure: Shows test output if a test fails. Example:

ctest --test-dir build --output-on-failure

6. Clean the Build Directory

Remove build artifacts:

cmake --build <build_directory> --target clean

Example:

cmake --build build --target clean

7. Package the Project

Create a package (e.g., .tar.gz, .zip) from the build artifacts:

cpack --config <package_configuration_file>

Example: cpack --config CPackConfig.cmake These commands help manage a CMake-based project through the command line, from generation and building to testing and packaging.

Harikrishnan R's Projects

apple.com icon apple.com

In this project, I tried to clone apple's official website, using HTML, CSS, and javascript.

nasa-clone icon nasa-clone

An informative landing page, depicting the accomplishments of NASA, in a fun and innovative manner

vr-website icon vr-website

Website to display all kind of VR Models available, with description of their features and a link to buy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.