2019-02-15 21:20:19 +01:00
|
|
|
# CMake project - IDE usage
|
2018-11-20 08:28:27 +01:00
|
|
|
|
2018-11-20 09:16:24 +01:00
|
|
|
There is many IDEs that support CMake projects. It could be natively or via plugins.<br>
|
|
|
|
|
This is a short tutorial on how we can use some IDEs to open a CMake project on linux:
|
|
|
|
|
|
|
|
|
|
- [Qt Creator](#open-the-project-with-qt-creator)
|
|
|
|
|
- [Code::Blocks](#open-the-project-with-codeblocks)
|
|
|
|
|
- [Eclipse](#open-the-project-with-eclipse-cc)
|
|
|
|
|
|
2018-11-20 08:28:27 +01:00
|
|
|
## Open the project with Qt Creator
|
|
|
|
|
|
|
|
|
|
[Qt Creator][] is a cross-platform C/C++ IDE, originally dedicated for the Qt framework.
|
|
|
|
|
It handle natively CMake projects and provide an efficient code completion.
|
|
|
|
|
|
|
|
|
|
*Install Qt creator:*
|
|
|
|
|
|
|
|
|
|
Install from Debian/Ubuntu repo:
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
sudo apt install qtcreator
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Online installer: https://www.qt.io/download-thank-you?hsLang=en<br>
|
|
|
|
|
Offline installer: https://www.qt.io/offline-installers
|
|
|
|
|
|
|
|
|
|
*Open the project:*<br>
|
|
|
|
|
Run Qt Creator, use `Open Files or Project ...` and select the `CMakeLists.txt`
|
|
|
|
|
file of the cloned project.<br>
|
|
|
|
|
Finally, build and run the project.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Open the project with Code::blocks
|
|
|
|
|
|
|
|
|
|
[Code::Blocks][] is a well-known cross-platform C/C++ and Fortran IDE.
|
|
|
|
|
It handle CMake projects by wrapping them into native Code::Blocks projects.
|
|
|
|
|
|
|
|
|
|
*Install Code::Blocks*
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
sudo apt install codeblocks
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
*Prepare the Code::Blocks project:*
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
# Create a folder for the Code::Blocks project
|
2022-11-25 16:41:48 +01:00
|
|
|
cd lettergame
|
2018-11-20 08:28:27 +01:00
|
|
|
mkdir -p build/codeblocks
|
|
|
|
|
cd build/codeblocks
|
|
|
|
|
|
|
|
|
|
# Generate a Code::Blocks project
|
|
|
|
|
cmake ../.. -G "CodeBlocks - Unix Makefiles"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
*Open the project:*<br>
|
2022-11-25 16:41:48 +01:00
|
|
|
Run Code::Blocks, and open the project in `lettergame/build/codeblocks`.<br>
|
2018-11-20 08:28:27 +01:00
|
|
|
Finally, build and run the project.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Open the project with Eclipse C/C++
|
|
|
|
|
|
|
|
|
|
[Eclipse][] is a well-known IDE, widely used in Java projects development, but
|
|
|
|
|
it also supports other programming languages, like in this case C/C++.
|
|
|
|
|
It handle CMake projects by wrapping them into native Eclipse projects.
|
|
|
|
|
|
|
|
|
|
*Download Eclipse C/C++:*
|
|
|
|
|
|
|
|
|
|
Online installer: https://www.eclipse.org/downloads<br>
|
|
|
|
|
Offline package: https://www.eclipse.org/downloads/packages
|
|
|
|
|
|
|
|
|
|
*Prepare the Eclipse project:*
|
|
|
|
|
|
|
|
|
|
```sh
|
|
|
|
|
# Create a folder for the Eclipse project outside this project
|
2022-11-25 16:41:48 +01:00
|
|
|
cd lettergame
|
|
|
|
|
mkdir ../eclipse-lettergame
|
|
|
|
|
cd ../eclipse-lettergame
|
2018-11-20 08:28:27 +01:00
|
|
|
|
|
|
|
|
# Generate an Eclipse project
|
2022-11-25 16:41:48 +01:00
|
|
|
cmake ../lettergame -G "Eclipse CDT4 - Unix Makefiles"
|
2018-11-20 08:28:27 +01:00
|
|
|
```
|
|
|
|
|
*Open the project:*<br>
|
2022-11-25 16:41:48 +01:00
|
|
|
Run Eclipse, and open the project in `eclipse-lettergame`.<br>
|
2018-11-20 08:28:27 +01:00
|
|
|
Create a new run configuration: Go to `Run` > `Run configurations` >
|
|
|
|
|
`C\C++ Application` and specify the C/C++ Application using `Search Project...`<br>
|
|
|
|
|
Finally, build and run the project.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Qt Creator]: https://doc.qt.io/qtcreator
|
|
|
|
|
[Code::Blocks]: http://www.codeblocks.org
|
|
|
|
|
[Eclipse]: https://www.eclipse.org
|