soloud
soloud copied to clipboard
Non-Issue: How to Generate CMake Build Files with Genie
Generating gmake, ninja or any of the Visual Studio targets are typically best done from genie but there is at least one case where CMake would be ideal:
- Building the source code using Clang instead of GCC. Genie doesn't offer it as a c compiler option when running
genie --cc. One can probably override it using variables and update-alternatives (if building on a Debian system), but generating the cmake target allows a bit more fine tuning and control over the build. Most common CMake definitions seem to work out of the box (especially for cross-compilation and using something like ccache or distcc to speed up the build).
To get it to generate properly, you need to manually run genie this way (in the build subdirectory):
genie --os=bsd --platform=x64 cmake
If you don't pass os and platform, it may not automatically detect those variables correctly leading to the generated files doing nothing. I've only tested on FreeBSD 14.0 and with --with-miniaudio-only for the backend, so your mileage will vary.
After generating the cmake build files, you can do things like this:
cmake -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=/usr/local/llvm17/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/local/llvm17/bin/clang++ \
-DCMAKE_BUILD_TYPE=Release \
-B build -S cmake \
-DCMAKE_CXX_FLAGS="-Wexceptions -std=c++17 $(llvm-config --cflags)"
For my particular needs and wants, I needed to use Clang17 and ccache and link directly against LLVM.