cmake repository for laserdock library with WiFi Cube Support
Windows (msvc2019 x86)
macOS (clang)
android (ndk r21 + the latest sdk, arm64/armv7 supported)
Linux (tested on Ubuntu 18.04)
- Download Qt Online installer from https://www.qt.io/download-qt-installer
- Run installer and install Qt for mac/windows (the latest version is recommended, library was tested on 5.15, 5.14 is minimal)
- Download the latest stable cmake if you don't have it already https://cmake.org/download/ Minimum cmake version is 3.11
- Ensure that Cmake is available in Qt Creator Preferences -> Kits -> CMake.
- Check Qt Creator Preferences -> Kits -> Kits page for any warnings
- Open root CMakeLists.txt.
- Setup build dirs and create them manually. Qt Creator won't do it until you check the corresponding checkbox in Preferences -> Kits -> Cmake. However this checkbox can create unnecessary dirs if you decide to change build dir later.
- Build & run
- copy dist.local.cmake and rename it to local.cmake
- Open local.cmake and set the path
QT_BASE_DIR
to your local Qt installation directory, e.gd:\Dev\Qt\5.15.0\
- Open x86 Native tools command prompt for VS 2019 and go to
libLaserdockCore
dir mkdir build
cd build
cmake -G "Visual Studio 16 2019" ..
Instead of step 1-2 you can set QTDIR
manually by passing it to cmake on this step:
cmake -G "Visual Studio 16 2019" -DQTDIR="d:\Dev\Qt\5.15.0\msvc2019" ..
- Build & run
- copy dist.local.cmake and rename it to local.cmake
- Open local.cmake and set the path
QT_BASE_DIR
to your local Qt installation directory, e.g/Users/ncuxer/dev/Qt/5.13.0
cd libLaserdockCore
mkdir build && cd build
cmake -G "Xcode" ..
Instead of steps 1-2 you can set QTDIR
on this step:
cmake -G "Xcode" -DQTDIR="/Users/ncuxer/dev/Qt/5.13.0/clang_64" ..
- open
ldCore.xcodeproj
- build and run
Code style helps to read and edit the project easier to all of us. Please follow it.
Do not use exceptions.
Do not use tabs symbols in code. You can setup your IDE to save tabs as spaces (1 tab is 4 spaces).
Try to declare float variables with f
suffix in a new code - 1.0f
or 1.f
instead of 1.0
or 1
Try to avoid copy-paste.
Recommended class field prefix is m_*, but try to keep the same style if some old class has other prefix.
Try to create significant names to variables and functions and avoid short names (except some obvious one like x,y, etc).
Please try to keep the existing braces style.
Clasess/structs/functions should have braces on new line:
class ldClass
{
...
};
void doSomething()
{
...
}
for/while/if should have braces in the end of the first line:
for(int i = 0; i < size; i++) {
...
}
``
//It is recommended avoid braces if you have only one line of cycle
//if content. Just leave blank line before and after this construction to make it clear.
if(true)
doSomething();
Common prefix for all classes/structs is ld*. If some class is strictly connected to one mini-app, you can use app name as second prefix - ldTunes*, ldClock*.
Recommended class member order: public, public slots, signals, protected slots, protected, private slots, private. In each section order is: enum, static functions, constructor, functions, fields.
From common to local:
-
<The corresponding *.h file (if it is cpp file)\>
-
<C++ std module\>
-
<Qt Module with explicit submodule>
-
<Windows/mac/linux specific>
-
<3rdparty library>
-
"ldCore/../.."
-
"Subfolder/ldClass.h"
Try to sort includes in each subgroup in an alphabetical order.
Try to use forward declaration of classes in *.h files.
When it is possible try to use C++11 syntax for with iterators, e.g for(const ldClass &myClass : myClasses)
instead of index-based for.
Try to use const references for classes/structs in arguments whenever it is possible. If some function doesn't change class field and shouldn't do it in future by design mark this function as const (getters usually).
enum class syntax from C++11 is preferrable instead of old-style enum in most cases. For any enum try to avoid if-else long trees and use switch(){}
instead.
In new code use C++11 nullptr
keyword.
Use C++11 style of variable initialization if it is possible - in *.h file. If something is initialized from constructor then initialize it in constructor declaration. And initialize field in constructor itself if you don't have other options. All fields should be initialiazed.
Use auto keyword only for iterators and lambdas.
Try to avoid using keywords delete
/ free
and any manul memory operations. Prefer to use std::unique_ptr
, std::shared_ptr
or Qt parent-based object system.
Use QString always when it is possible. char*
should be avoided generally. std::string
is not so bad but it creates mess with QString conversions so try to avoid it too.