This is how I, a web developer, feel whenever I'm required to build something using cmake. I guess I need to go read a book about it or something because the instructions seem different every time.
This is how I, a web developer, feel whenever I'm required to build something using cmake. I guess I need to go read a book about it or something because the instructions seem different every time.
I've been coding in C++ since the 90s, that's also how I feel whenever I'm required to build something using cmake.
Which is funny, because it's probably the easiest to use (common) build system around.
I beg to differ. It's only easy for projects you're constantly using daily. People tend to build all sorts of abominations with it.
This is hilarious to me, because for me it is exactly the other way around.
Just last Friday, some coworker showed me her mermaid diagrams about workflows at work. I am still not comfortable with needing to login to some website to convert some format into a useful format. If I cannot run it locally on my computer it doesn't exist for me. So I tried to install their official looking cli client.
The protocol from my memory roughly looks like this I npm install something, then it tells me I have to npx (wth is that? I think that is new) install something, which gives me some weird puppeteer permissions issue. If it is permissions I guess I have to be root for the install, I try a bit more and get nowhere the same issues keep happening. Look on their website, see they have a docker as an alternative, this is a pretty newly installed computer so I have to install docker, but which one? There is 3 options and I am not sure. I try to run their docker and mess up because I do not read the documentation correctly and I have to map the directory with my .mdd file with <my-dir>:/data and this was unintuitive to me so I ignored the first part and replaced /data with my path. Again obviously a mistake on my side, but it happens every time and adds to my confusion. I look into the docs again and find my mistake. I finally get a resulting svg from the docker command. Excitement! I open the svg and it lacks all the text and I think there were also errors in the shape. Then I remember obsidian has a mermaid plugin so I thought about trying that, but the obsidian install also fails with some random error about not being able to connect to chrome.
On the other hand whenever I get a cmake project I clone it. I create a folder for the build, cd into it, run cmake <path-to-source-folder> without even looking at the documentation and it either works or I get a pretty clear message what is missing on my OS and with a short web search I can just apt install it and try again (yes this sometimes has multiple rounds) and it works!
Ok, my turn now. Let's build the project 'msdfgen' using cmake.
First step is cloning the 'msdfgen' repo. Done. Next step is reading the readme, which states "to build the project from source, you may use the included CMake script. In its default configuration, it requires vcpkg as the provider for third-party library dependencies. If you set the environment variable VCPKG_ROOT to the vcpkg directory, the CMake configuration will take care of fetching all required packages from vcpkg."
Google 'vcpkg' and end up at the vcpkg website. Click 'get started'. Land on a documentation page. This doesn't look like the right place. Click back and select 'browse packages' instead. This doesn't look like the right place either. Google 'install vcpkg windows'. Find a microsft site saying I need to clone the vcpkg repo. Ok. Clone vcpkg repo. Next step is running the vcpkg bootstrap script. Cd into the directory. Run '.\bootstrap-vcpkg.bat'. Next step is setting the environment variable. Open powershell. Add vcpkg to my path environment variable by copy pasting what the website tells me. Cd back into the original repo. Google how to build using cmake. It looks like I need to install cmake by first downloading the executable from the cmake website. Download cmake 4.1.1. Install.
Ok, it's time to run cmake. Navigate to the guide on the cmake website. It looks like I need to first create a build directory alongside my source directory. Open terminal and navigate to the folder just above the msdfgen-master folder. Run mkdir msdfgen-build in powershell. It looks like I now need to cd into this folder and run 'cmake ..\msdfgen-master'. Run it. It fails with three errors. "Vcpkg triplet not explicitly specified and could not be deduced. Recommend using -A to explicitly select platform (Win32 or x64)". Google what this means. Confusing. Look at the second error "CMake Error at CMakeLists.txt:70 (project): Running 'nmake' '-?' failed with: no such file or directory". Hmm, what is 'nmake'? Google it. It looks like I might need to install 'nmake' and add it to my path environment variable as well. Google it. It looks like I need to install "Visual C++ Development Tools". Google it. It looks like I need to install Visual Studio, and choose "desktop development with c++". Total space required: 10gb. Install this. Restart powershell and cd back into the build directory. Run 'cmake ..\msdfgen-master' again. Same errors.
If I had time, I'd continue down this path, but I know from experience that it will require another day or two of tooling around to get it working. I know I probably look like an idiot who doesn't understand cmake, but that's my whole point: it's a very confusing process for anyone who's unfamiliar.
I had to install vcpkg yesterday for the first time. Well, actually, I ran into a problem last week that could have been solved by installing vcpkg. I also happened to read a comment here on hacker news recently that mentioned vcpkg (but I didn't know what it was).
The problem was that 'cargo install cargo-show' wanted access to an OpenSSL installation (under Windows). The long error spew did mention vcpkg once or twice so I googled it and got very confused by the readme.
So I tried to install OpenSSL without vcpkg. That worked ('winget install openssl') but 'cargo install cargo-show' still didn't. Perhaps I had set up some environment variables wrong.
Yesterday, I finally figured out how to install vcpkg and it was indeed very simple, despite its readme. 'cargo install cargo-show' still didn't work -- it couldn't find openssl installed with the right "triplet" even though it was clearly installed in a way that should work for all 64-bit x86 Windows.
Setting OPENSSL_DIR and then running 'cargo install cargo-show' worked perfectly.
Apparently, there are different ways the directory structure for a vcpkg installed package can look and the vcpkg/openssl gave me one and the build script for one of the dependencies of cargo-show expected another.
Very, very confusing.
I think you can get away with just using 'winget install cmake' and then invoking cmake with the right command line to make it play nice with vcpkg (and that command line is listed in several places). I haven't tried it, though.
'vcpkg integrate install' sets up some sort of secret integration with Visual Studio -- maybe vcpkg learns where VS libraries and binaries (compilers/linkers) are hidden and maybe Visual Studio learns how to invoke vcpkg.
If you run it, it will also tell you to how to integrate more explicitly with cmake:
I hope this makes it slightly less confusing.The main advantage of cmake is it's slightly easier to use than autoconf so long as you stick to the path. Do not attempt to leave the path. Also the path is poorly signposted.
That is the typical experience for C++ tooling lol
C++ is written by 99% professional architecture astronauts who do fuck all in terms of valuable software. I will die on this hill.
C++ might have been developed by architecture astronauts, but it's used to build a ton of valuable software - KDE, Windows, Spotify, etc etc...
HPC?
Windows NT?
GCC?
Video games?
I'm a veteran C programmer with a deep dislike of C++, but to say it's not used for valuable software is just wrong.
The language committee only makes it harder and more astronauty every year. How many Unreal Engine developers from 2007-2013 understand CPP20/23?
I agree with you. I'm no fan of C++.
With that being said, it is (and has been) used to produce valuable software.
You never need to use everything a language provides. You find the parts useful to you or your team and use all of them.
I was a C++ developer for a decade and knew a fair amount of the C++13 spec but never needed to use even half of it in production. I've been a Java developer for years and don't know 10% of the standard library there. That doesn't make either language poorly designed by itself.
Reminds me of the (now decades old) humorous observation that the entired R5RS (Scheme) book is shorter than the table of contents of the C++ spec.
Lmfaooooo..... to everyone else reading, cpp programs are indeed successful, but they are successful in spite of cpp, not because of it, is my assertion. It is increasingly rare to find major applications using the newest cpp features, because of how obtuse they are for 99.9999% of people, including extremely good programmers, of which a Youtube search could produce 12
Linux is a pretty valuable example of such astronautics. Also things like TCP...
I hope you don't die on a hill tho, not anytime soon at least.
Hilariously incorrect take. Zero CPP in the Linux kernel. Torvalds openly hates CPP.
EDIT: thank you for your well wishes though :)
Huh TIL, my apologies.