/cpp-project

Template for C++ projects with CMake and QT5 Widgets.

Primary LanguageCMakeMIT LicenseMIT

license

Template for C++ projects with QT5 Gui (For Windows and Linux)

  • Sources, headers and mains separated in distinct folders
  • Access to Google Tests
  • Use of CMake for much easier compiling
  • Example configuration of QT5:Widgets

Why?

I wanted to easily port my source codes from linux and compile them on windows without having to configure that tedious visual studio thing.

Depndencies

Linux

  • CMake
  • Qt5

Windows

Structure

.
├── CMakeLists.txt
├── app
│   ├── main.cpp
    └── example.ui
├── include
│   ├── example.h
│   └── Config.h.in
├── src
│   └── example.cpp
└── tests
    ├── dummy.cpp
    └── main.cpp

Sources go in src/, header files in include/, main programs (including QT5-related files) in app/, and tests go in tests/ (compiled to unit_tests.x by default).

You can find the example that builds the example in app/main.cpp under the Build section in CMakeLists.txt. If the executable you made does not use the library in src/, then only the first line is needed.

Building

Build by making a build directory (i.e. build/), run cmake in that dir, and then use mingw32-make to build the desired target.

Linux

$ mkdir build && cd build
$ cmake .. -DCMAKE_BUILD_TYPE=[Debug | Release] 
$ make
$ make gtest     # Makes and runs the tests.(Only Available in debug mode )

Windows

$ mkdir build && cd build
$ cmake .. -DCMAKE_BUILD_TYPE=[Debug | Release] -G "MinGW Makefiles"
$ mingw32-make
$ mingw32-make gtest     # Makes and runs the tests.(Only Available in debug mode )

Setup

git clone https://github.com/alcros33/cpp-project
git remote remove origin

.gitignore

The .gitignore file is a copy of the Github C++.gitignore file, with the addition of ignoring the build directory (build/).

IMPORTANT!!!

For windows be sure that MinGW installation directory in on PATH (Guide Info)