+4 votes
71 views
Install CMake Linux

in Linux/Unix by (552k points)
reopened | 71 views

1 Answer

+5 votes
Best answer

How to install CMake on Linux

One of the advantages of Linux distributions is its ability to install and manage multipurpose tools, one of the most popular is everything related to programming, Linux is an enriched platform for this type of task since, as we mentioned, it will be possible to make use of various platforms to expand this action and CMake is one of the best options available thanks to its cross-platform operation..

 

What is CMake
CMake is a group of open source cross-platform tools with which it is possible to create, test and package software in a simple way and with the best security and development options, CMake allows us to control the software compilation process using its platform and extra mode with the use of compiler-independent configuration files, this will result in native makefiles and workspaces ideal for use in the build environment to be used.
CMake is mostly used in the C and C++ languages, but it does not mean that it only applies to these two since it will be possible to compile source code from other compatible languages.

 

CMake Options
The global CMake options are as follows:

 

 

-S <path>: indicates the source directory

 

-B <directory_path>: refers to the build directory

 

-C <initial_cache>: preload a script to fill the cache

 

-D <var>[:<type>]=<value> – create or update a CMake cache entry

 

-G <generator>: indicates a build system generator

 

-T <tool_group>: refers to the name of the toolset to see its compatibility with the generator

 

--install-prefix <directory> Indicates the installation directory

 

-wdev: enable developer warnings

 

-wno-dev: ignore developer warnings

 

--preset <preset>: indicates a configuration default value

 

--list-presets: apply the list of presets

 

-E: is the CMake command mode

 

--build <dir>: build a binary tree generated by CMake

 

-N: makes use of display mode

 

--trace: Set CMake to trace mode

 

 

TechnoWikis will explain how to install CMake on Linux and for this case we will use Ubuntu.

 

 

To stay up to date, remember to subscribe to our YouTube channel!   SUBSCRIBE

 

How to install CMake on Linux

 

Step 1

We open the terminal and install the initial utilities with the command:
 sudo apt install clang lldb lld 
image

 

 

Step 2

We must confirm this process by entering the letter S:

 

image

 

 

Step 3

The download and installation will start:

 

image

 

 

Step 4

At the end of this process we will see the following:

 

image

 

step 5

Clang is a language interface and tool framework available for the C languages ​​(C, C++, Objective C/C++, OpenCL, CUDA, and RenderScript) and for the LLVM project, it is integrated by a GCC-compliant compiler driver (clang ) and a compiler driver that is compatible with MSVC (clang-cl.exe), within its features we find:
  • Architecture based on the modular library model
  • Expressive diagnoses
  • Fast builds and low memory usage so you don't exceed resources
  • GCC Compatibility
  • IDE Integration
  • Integrates a unified parser for C, Objective C, C++, and Objective C++

 

step 6

Now we install GCC:
 sudo apt install build-essential 
image

 

step 7

GCC (GNU Compiler Collection) are a group of GNU compilers for C, C++, Objective-C, Fortran, Ada, Go and D interfaces, some of its features are:

 

  • It has multiple language interfaces
  • Compatible with 64-bit microcontrollers, DSPs and CPUs
  • GCC is written in C
  • It has a modular design

 

step 8

Once this is installed, we open Ubuntu Software to find and install CMake:

 

image

 

 

step 9

We click on CMake to see the following:

 

image

 

step 10

We click on Install, confirm the password and the installation will take place:

 

image

 

step 11

At the end we will see the following:

 

image

 

 

step 12

The syntax to use CMake on Linux is as follows:
 cmake -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=<linker>" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld= <linker" -DCMAKE_CXX_COMPILER=<C++ compiler> 
step 13

In the terminal we execute "cmake" to see the available options:

 

 

image

 

 

step 14

CMake can use generators for platforms like:
  • Sublime Text 2 – Ninja
  • Sublime Text 2 – Unix
  • Kate-Ninja
  • Watcom WMake
  • Ninja
  • Eclipse CDT4 – Ninja
  • Eclipse CDT4 – Unix
  • Code Blocks – Ninja
  • CodeLite – Ninja
  • CodeLite-Unix

 

CMake is a valuable tool if your focus is development, thanks to its functions, this task will become something extremely simple but full of expansion options..


by (3.5m points)
edited

Related questions

+4 votes
1 answer
asked Oct 12, 2023 in Linux/Unix by backtothefuture (552k points) | 53 views
+4 votes
1 answer
asked Oct 7, 2023 in Linux/Unix by backtothefuture (552k points) | 69 views
+5 votes
1 answer
asked Sep 29, 2023 in Linux/Unix by backtothefuture (552k points) | 74 views
+4 votes
1 answer
asked Sep 22, 2023 in Linux/Unix by backtothefuture (552k points) | 67 views
+3 votes
1 answer
asked Aug 25, 2023 in Linux/Unix by backtothefuture (552k points) | 67 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users