C++/Qt5 starter project with cmake build system, QtQuick, QtWidgets, AppIcon, macOS bundle and macdeployqt support.
-
Clone the repository.
-
Add the path of your Qt installation to your
~/.bash_profile
:
# there should be an entry like this:
export PATH="$PATH:~/sourcecode/sdk/QtLatest/5.12.0/clang_64/"
- Add the bin path of your CMake installation to your
~/.bash_profile
:
# there should be an entry like this:
export PATH="$PATH:/Applications/CMake.app/Contents/bin"
-
If you want to make a QtQuick app use the
quick_app
folder. For a QtWidgets app use thewidgets_app
folder. -
Edit the
CMakeLists.txt
file and set theCMAKE_PREFIX_PATH
variable to your Qt bin path as described in 2.
Just run ./build.sh
in your app root directory. It will create a build
directory and compile the app. On every run the script removes the build directory entirely. To prevent this, go to the build directory and run make
.
- Check that the program
macdeployqt
is within your PATH variable.
$ which macdeployqt
$ ~/sourcecode/sdk/QtLatest/5.13.0/clang_64/bin/macdeployqt
-
In the folder
res/
there is a fileAppIcon.icns
andAppIcon.png
. Replace these files with your AppIcon. -
In
CMakeLists.txt
on line 4-9 set the variables to your needs. -
Again run
./build.sh
in your app root directory but with parameterrelease
:
$ ./build.sh release
When finished there is a bundle AppName.app
and a AppName.dmg
in the build folder ready to ship.
You can run the app in cli or gui mode by using command line parameters:
$ ./quickapp -h
Usage: ./quickapp [options]
AppName
Options:
-h, --help Displays this help.
-v, --version Displays version information.
-c, --cli Run in cli mode only.
Or in the release bundle:
$ ./AppName.app/Contents/MacOS/AppName -h
Usage: ./AppName.app/Contents/MacOS/AppName [options]
AppName
Options:
-h, --help Displays this help.
-v, --version Displays version information.
-c, --cli Run in cli mode only.
Tested with the following environment:
- macOS Mojave 10.14.3
- CLion 2019.2
- Qt 5.13 clang_64
- CMake 3.13.3