- Setup
- Compile
- Package
- Documentation
Build tools:
sudo pacman -Sy git gcc clang llvm cmake make ninja
wxWidgets:
sudo pacman -Sy wxgtk3
Documentation:
sudo pacman -Sy doxygen python-sphinx python-breathe python-sphinx_rtd_theme
Static analysis:
sudo pacman -Sy cppcheck llvm
Debugging:
sudo pacman -Sy gdb lldb
Memory checker:
sudo pacman -Sy valgrind
CPack DEB:
sudo pacman -Sy dpkg
CPack RPM:
sudo pacman -Sy rpm-tools
GoogleTest:
sudo pacman -Sy gtest
Coverage:
sudo pacman -Sy lcov gcovr
Build tools:
sudo apt install git cmake make ninja-build build-essential clang llvm
wxWidgets:
sudo apt install libwxgtk3.0-gtk3-dev
Documentation:
sudo apt install doxygen sphinx-common python3-breathe python3-sphinx-rtd-theme
Static analysis:
sudo apt install cppcheck clang-tidy
Formatting:
sudo apt install clang-format
Debugging:
sudo apt install gdb lldb
Memory checker:
sudo apt install valgrind
CPack DEB:
sudo apt install dpkg
CPack RPM:
sudo apt install rpm
GoogleTest:
sudo apt install libgtest-dev
Coverage:
sudo apt install lcov gcovr
Build tools:
sudo yum -y install git cmake make ninja-build gcc gcc-c++ clang llvm
wxWidgets:
sudo yum -y install wxBase3 wxGTK3 wxGTK-devel
Documentation:
sudo yum -y install doxygen sphinx python3-breathe python3-sphinx_rtd_theme
Static analysis & Formatting:
sudo yum -y install cppcheck clang-tools-extra
Debugging:
sudo yum -y install gdb lldb
Memory checker:
sudo yum -y install valgrind
CPack DEB:
sudo yum -y install dpkg
CPack RPM:
sudo yum -y install rpm-build
GoogleTest:
sudo yum -y install gtest
Coverage:
sudo yum -y install lcov gcovr
Download and install Visual Studio.
In Visual Studio Installer, click "Modify" and install "Desktop development with C++".
Download latest MinGW builds.
Example:
- Architecture: i686 - for compiling 32 bit programs
- Architecture: x86_64 - for compiling 64 bit programs
Put the MinGW bin folder in the path for the intended architecture.
- git
- CMake
- Doxygen
- Sphinx:
- Get Python at the Windows Store, and run in an elevated command shell:
pip install sphinx
pip install breathe
pip install sphinx_rtd_theme
- cppcheck
- Add
C:\Program Files\Cppcheck
to the Path environment variable
- Add
- LLVM (includes clang-tidy and clang-format). Tick option to add to PATH during installation.
- OpenCppCoverage
- NSIS
- WiX Toolset
- Ninja:
- Open an elevated command shell (cmd/powershell), and type:
choco install ninja
- Open an elevated command shell (cmd/powershell), and type:
- Download Windows binaries from: https://www.wxwidgets.org/downloads
We need the Header Files, the Development Files, and the Release DLLs for the chosen compiler and architecture.
After extracting the files to a directory (e.g. C:\wxwidgets
), we should end up with a file tree like this:
C:\wxwidgets
├───build
│ └───msw
├───include
│ ├───msvc
│ │ └───wx
│ └───wx
│ ├───android
│ ├───...
│ └───xrc
└───lib
└───vc14x_x64_dll
├───mswu
│ └───wx
│ └───msw
└───mswud
└───wx
└───msw
# https://stackoverflow.com/a/48947121/3049315
set wxWidgets_ROOT_DIR=C:\wxwidgets
set wxWidgets_LIB_DIR=C:\wxwidgets\lib\vc14x_x64_dll
cd <project_root>
mkdir build && cd build
cmake .. -DBUILD_TESTING=OFF
cmake --build . --config Release
Instructions at: https://docs.wxwidgets.org/stable/plat_msw_binaries.html
Install Google Test:
cd C:
git clone https://github.com/google/googletest.git -b v1.13.0
cd googletest
mkdir build && cd build
cmake .. #-DBUILD_GMOCK=OFF
cmake --build . --config Debug
cmake --build . --config Release
cd <project_root>
# https://stackoverflow.com/a/32749652/3049315
cd <project_root>
mkdir build && cd build
cmake .. -DGTEST_ROOT:PATH="C:\googletest\googletest" -DGTEST_LIBRARY:PATH="C:\googletest\build\lib\Release\gtest.lib" -DGTEST_MAIN_LIBRARY:PATH="C:\googletest\build\lib\Release\gtest_main.lib" #-DBUILD_PROJECTWX=OFF
cmake --build . --config Release
cd <project_root>
# Install vcpkg - A C++ package manager
# https://docs.microsoft.com/en-us/cpp/build/vcpkg?view=vs-2019
# https://devblogs.microsoft.com/cppblog/vcpkg-updates-static-linking-is-now-available/
git clone https://github.com/Microsoft/vcpkg
cd .\vcpkg
.\bootstrap-vcpkg.bat
# Search library example (optional, just to see if it's available)
.\vcpkg.exe search zlib
## Install libraries (x86 for 32-bit, x64 for 64-bit)
# wxWidgets with vcpkg: https://www.wxwidgets.org/blog/2019/01/wxwidgets-and-vcpkg/
#.\vcpkg.exe install wxwidgets:x86-windows
#.\vcpkg.exe install wxwidgets:x64-windows
#.\vcpkg.exe install wxwidgets:x64-windows-release
## With MSVC:
.\vcpkg.exe install wxwidgets:x64-windows-static
.\vcpkg.exe install gtest:x64-windows-static
## With MinGW:
.\vcpkg.exe install wxwidgets:x64-mingw-static
.\vcpkg.exe install gtest:x64-mingw-static
## With Clang:
git clone https://github.com/Neumann-A/my-vcpkg-triplets.git
.\vcpkg.exe install wxwidgets:x64-win-llvm-static-md-release --overlay-triplets=my-vcpkg-triplets
.\vcpkg.exe install gtest:x64-win-llvm-static-md-release --overlay-triplets=my-vcpkg-triplets
# Make libraries available
.\vcpkg.exe integrate install
# Build project
cd ..
mkdir build && cd build
# Note: toolchain file must by specified with full path.
## With MSVC:
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_TOOLCHAIN_FILE=<project_root>/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DVCPKG_HOST_TRIPLET=x64-windows-static
## With MinGW:
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_TOOLCHAIN_FILE=<project_root>/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVCPKG_HOST_TRIPLET=x64-mingw-static
## With Clang:
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_TOOLCHAIN_FILE=<project_root>/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-win-llvm-static-md-release -DVCPKG_HOST_TRIPLET=x64-win-llvm-static-md-release -G "Ninja Multi-Config" -DCMAKE_CXX_COMPILER=clang++
#-DVCPKG_OVERLAY_TRIPLETS=vcpkg/my-vcpkg-triplets
# If your generator is a single-config generator like "Unix Makefiles" or "Ninja", then the build type is specified by the CMAKE_BUILD_TYPE variable, which can be set in the configure command by using -DCMAKE_BUILD_TYPE:STRING=Release. For multi-config generators like the Visual Studio generators and "Ninja Multi-Config", the config to build is specified in the build command using the --config argument argument like --config Release. A default value can be specified at configure time by setting the value of the CMAKE_DEFAULT_BUILD_TYPE variable, which will be used if the --config argument isn't passed to the build command.
# https://stackoverflow.com/a/74077157/3049315
cmake --build . --config Release
brew install wxwidgets googletest
Tip: Use Ninja. It can run faster, is less noisy, defaults to multiple cores, and can use the same directory for debug and release builds.
cmake .. -G "Ninja Multi-Config"
ninja
Building for release:
cmake --build . --config Release
Clean:
cmake --build . --target clean
Reference: https://cmake.org/cmake/help/v3.22/guide/user-interaction/index.html#invoking-the-buildsystem
git clone --recursive -j4 https://github.com/MangaD/cpp-project-template
cd cpp-project-template
mkdir build && cd build
cmake .. -G "Ninja"
ninja
git clone --recursive -j4 https://github.com/MangaD/cpp-project-template
cd cpp-project-template
mkdir build && cd build
# without vcpkg:
cmake ..
# with vcpkg:
cmake .. -DCMAKE_TOOLCHAIN_FILE=<project_root>/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DVCPKG_HOST_TRIPLET=x64-windows-static
cmake --build . --config Release
Package the binary:
# following is necessary with MSVC:
cmake --build . --config Release
cpack
# or, on linux:
make package
Package the source code:
cpack --config CPackSourceConfig.cmake
# or, on linux:
make package_source
Download and Install the Null Soft Installer (NSIS) from here.
cmake ..
cmake --build . --config Release
cpack -G NSIS64
Download and Install the WiX Toolset from here
cmake ..
cmake --build . --config Release
cpack -G WIX
cmake ..
cpack -G DEB
cmake ..
cpack -G RPM
cmake ..
cpack -G DragNDrop
cmake ..
cpack -G productbuild
# Doxygen:
cmake --build . --target doxygen
# Sphinx:
cmake --build . --target sphinx