In this tutorial we’ll demonstrate how to create new projects within the COSMOS framework. We will use the project name “myproject”.
4.4.1 Create a new Git Repository
Go to Bitbucket, GitHub or GitLab to create a new git repository for your new project “myproject” (instructions to create a new repo in Bitbucket, instructions to create a new repo in GitHub). Don’t forget to create a “README.md” file that describes the project.
4.4.2 Clone Git Repository
Clone the repository to ~/cosmos/source/projects/myproject
4.4.3 Copy Template Project
The easiest way to bootstrap a new COSMOS project is to use the template (otherwise you’ll have to create a few things from scratch). Clone the template repository from https://github.com/hsfl/cosmos-project-template to the projects folder (cosmos/source/projects/
). You can also check other examples from the COSMOS projects list.
Copy the files from the template folder into “my-project” folder.
For example: copy from cosmos/source/projects/project-template
to cosmos/source/projects/my-project
.
4.4.4 Hello World Test
Create a hello_world.cpp
test program using Qt Creator.
- Open Qt Creator
- Open the file
CMakeLists.txt
.
- File → Open File or Project ...
- Open the
CMakeLists.txt
filecosmos/source/projects/my-project/source/CMakeLists.txt
- Select “configure project” when the window opens.
- Create the new file
- File → New File or Project → C++ Source file
- Add the new file into
cosmos/source/projects/my-project/source/hello_world.cpp
- In Qt Creator, edit the
CMakeLists.txt
and enter the following line:
add_executable(hello_world "hello_world.cpp")
- Build Build by clicking on the hammer icon or with the shortcut CTRL + B
- Run Run the program in Qt with the shortcut CTRL + R