There are options that can be used to create the project configuration before build.
Always needs to be set, usual values are Debug, Release, or RelWithDebInfo for the different build targets.
Example:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -B build/debugCan be set to stop the application from logging.
Example:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DDEACTIVATE_LOGGING -B build/debugWill not only enable application internal debugging, but also profiling (APP_PROFILE). This option is mainly useful to
get debugging and profiling output on release builds.
Example:
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DDEBUG -B build/releaseEnable profiling, useful for profiling a release build.
Example:
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DAPP_PROFILE -B build/releaseTreat compiler warnings as errors. This option is by default true. To disable set it to FALSE.
Example:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DWARNINGS_AS_ERRORS=FALSE -B build/debugAfter configuration the application can be built through CMake via cmake --build, passing a build folder as argument.
Example:
cmake --build build/debugThis will build the application with the given configuration. Depending on the platform it was executed on a different build directory structure will be generated, reflecting how the application will latter be installed on packaging.
When not running through an IDE like CLion, the built application can be run by directly executing the generated binary. Depending on the operating system it can be found at a different place, as different build directory structures are generated.
On Apple devices an app package structure is created under ./build/<TARGET>/src/app/App.app, where <TARGET> is the
build target like debug or release. Inside
that application bundle
is the app executable.
Run on a built target, in this example debug:
./build/debug/src/app/App.app/Contents/MacOS/AppThough, even better is to use Xcode as generator to create app builds on macOS. Only difference in usage is running
CMake with -GXcode and setting the CMAKE_OSX_ARCHITECTURES variable, for example to x86_64;arm64 for a universal
binaries.
To run a debug build created with Xcode:
./build/xcode/src/app/Debug/App.app/Contents/MacOS/AppTo run a release build created with Xcode:
./build/xcode/src/app/Release/App.app/Contents/MacOS/AppTo run a debug build:
build/debug/src/app/App.exeTo run a release build:
build/release/src/app/App.exeFor Linux the generated structure is a direct executable, as libraries and assets have dedicated locations on the system.
Run on a built target, in this example debug:
./build/debug/src/app/AppNext up: Testing