Building a Development Environment that can work Crossplatform and not be tedious
As I use Windows and Linux to similar amounts I wanted to find a setup that is
cross platform and works without relying on a lot of tedious GUI tools for
building packages. That’s why I found out about CMake
for generating the
systemspecific build-files for me, so I can focus on writing fun code instead of
battling with compiler flags every time I try something out.
Sadly not every Library I found supports a CMake
based build process yet, but
the percentage seems to be encouraging and even when the library doesn’t support
it directly it seems to be always possible to link against it. As I am a total
noob with C++ who just started it could be that the last few sentences weren’t
even wrong, so bear with me for a moment and please write pissed corrections to
me so I can stop being totally wrong! :)
Getting Set-Up for Easy Prototyping
Coming from developing mostly in python I was bewildered at first by manual management of dependencies and thought that there is no way, that everybody just slaps the folders somewhere into their build directory and calls it a day. And it turns out this feeling was right!
As it turns out a better way to manage your build and all the necessary
dependencies is using a so called build-generator
like CMake
. As this is the one
I tried out this is gonna be the one I’m writing about. On top of that
Modern CMake
VCPKG and pitfall for beginners
- To use vcpkg specify toolchain
via
-DCMAKE_TOOLCHAIN_FILE=C:/Users/hecti/bin/vcpkg/scripts/buildsystems/vcpkg.cmake
- Per default vcpkg fetches 32 bit binaries, you have to get <package>:x64-windows to really get the one you want
- https://vcpkg.io/en/docs/examples/installing-and-using-packages.html
Getting Set-Up on Windows with Spacemacs
This was way less straightforward than I would have hoped, which could be a consequence of my not knowing a bit about the C++ build process, but Finally I managed to have a configuration that is just working for me. The first stumbling block for me was that for getting docstrings and correct detection of linked libraries, the cpp lsp-mode needed a so called build-database. But the process of obtaining such a build database wasn’t very intuitive to me, which is why I describe it here in the hope of helping another poor Soul, that tries to generate one. (Mind you that I needed a database targeting the native msvc toolkit for better compatability with the JUCE framework) After reading the great Article about build databases by %HUMAN% at %link% I finally managed to use Ninja to just generate the build-database.json for me. Once this was present in the Source directory all syntax-highlighting and doc string discovery worked flawlessly for me. Still I think it was very unstraightforward getting Set-Up here, your mileage may vary though. On Linux on the other hand it was a breeze getting set-up. I hope Ableton someday will release a Linux native port of their Live DAW so I can finally ditch Windows for good!