CMake on Windows 10 with Qt5 Error: CMAKE_PREFIX_PATH

Quick one: Set the proper CMAKE_PREFIX_PATH value for Qt5 development on Windows 10 with MinGW and CMake.

Here is the lovely error you get from CMake.

CMake Error at CMakeLists.txt:13 (find_package):
 By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project 
has
 asked CMake to find a package configuration file provided by "Qt5", 
but
 CMake did not find one.

 Could not find a package configuration file provided by "Qt5" with 
any of
 the following names:

 Qt5Config.cmake
 qt5-config.cmake

 Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set 
"Qt5_DIR"
 to a directory containing one of the above files. If "Qt5" provides a
 separate development package or SDK, be sure it has been installed.

CMake asks you to tell it where to find the Qt5 *.cmake configuration files. One option is to set the CMAKE_PREFIX_PATH variable. The Qt5 documentation has the following to say about that:

The easiest way to use CMake is to set the CMAKE_PREFIX_PATH environment variable to the install prefix of Qt 5.

Now, what the hell is the "install prefix"? It turns out it is the path where you can find the compiler-specific Qt binaries, include files and the other stuff. In my case, using MinGW, it is located at "C:\Apps\Qt\5.14.2\mingw73_64". If you are using the MSVC binaries, select the corresponding directory, probably something like "C:\Apps\Qt\5.14.2\msvc_2017".

Automate Game Screenshot Capture: Windows API SendInput Function with C++

I am trying to write video game reviews after I have finished a game and I like to add some impressions in the form of screenshots to the reviews. There is one problem though: sometimes it is impossible to press the keyboard shortcut to capture a screenshot because the game requires my full attention – and all my fingers. Therefore, I miss out on a lot of action sequences. What does a programmer do in such a situation? Write a tool that scratches the itch.

Read More »

Comparing Java Optional vs C++ STL optional

Optionals in Java have been around for some time now, basically since the release of version 8. My other language of choice, C++, has received this feature in version C++17. Since I am currently in the process of writing some C++ code, I was curious how they were implemented there. Optionals are trying to solve a problem that is likely to plague any language. What shall a method or function return if there is no value? Or shall it not return anything but instead start crying like a petulant child and throw an exception?

As an introduction, let me dive a little bit into why we need optionals (or do we?) and compare two different implementations of this concept, one being java.util.Optional and the other C++ std::optional. I chose to compare these two language for several reasons:

  1. I work with Java in my day job, so I have a good idea of how it works there.
  2. As mentioned, C++ is one of the languages I know quite well too.
  3. The main reason: both optional implementations are add-on classes rather than language features. More on that later.
Read More »

WorkTracker 1.4.0 Released

Yes, you read that right. I have released a feature update for my WorkTracker tool. There was one little annoyance that I worked around by using copy and paste and since it was just a few key strokes, I didn’t bother. But in my renewed motivation to do some coding, I thought that it’s about time this issue goes to hell. And now it’s being grilled by Lucifer.Read More »

enable_shared_from_this: boost vs. std

If you are a modern C++ developer, then you are probably using some kind of smart pointer implementation. The boost C++ libraries offer one possible solution (among many other useful features) and are generally held in high regards in the C++ community. With the latest C++11 standard, some of those ideas found their way into the standard library bundled with your C++ compiler. At some point, you very likely run into a situation where you need a shared_ptr of one of your classes, but only have a raw pointer or this available.

This is where enable_shared_from_this comes in. Boost and the standard C++ library provide this feature and they both have a very important prerequisite for this to work.
Read More »

The Pitfall of Trying to Be Too Smart When Using dllexport/dllimport

As a seasoned C++ developer I should’ve been aware of this which makes it a little bit embarrassing. But, since this issue has cost me several hours of searching through the Internet over the course of two or three days, I thought it might be worth sharing. Maybe somebody else is trying to be too smart or just doesn’t know better.

The problem? It is summarized in short in this StackOverflow question that I posted. With this blog post I’ll be a bit more elaborate and show some details.
Read More »

Performance Iterating Directories Revisited

I have written about the performance of iterating directories before, in the context of Java and its switch from version 6 to 7 that brought with it the new Java NIO API. For whatever reason I felt the urge to do something similar again, but this time I wanted to compare two different approaches to recursively scanning a directory’s contents:

To make things more interesting, I implemented this in C++ using the Windows API and the Qt framework, in C# in combination with its buddy the .NET framework and, for good measure, I also threw in the old Java code from over a year ago.

Update (26.12.2014): I added additional data at the bottom of the article.
Read More »

WorkTracker v1.2.2 Released

It has been around three months since the last release, June 22nd to be exact. Since then I have made some small changes along the way, but didn’t publish them because they haven’t been in the shape that I wanted them to be for a release, but still good and helpful enough for me to use them on a daily basis. The biggest new feature is an editor. Second comes the translation and around them gather a few improvements regarding usability.

Visit the GitHub page to download the latest version.Read More »

C# LINQ Performance vs. Iteration

It’s been a while since I have written something related to programming. Time to remedy that.

Just recently my interest for the C# language rose again and to get back up to speed with the fundamentals I swallowed all videos of an absolute beginners guide on Microsoft Virtual Academy. Something that has been touched briefly was LINQ and my initial thought was: how’s the performance of that compared to how I would usually write it in C++ – where my expertise is?

Mind you, I’m not comparing C# vs C++, but merely LINQ vs. old-school iteration. Let’s go and find out.
Read More »

WorkTracker, a Little Open Source Tool

Up until my last post I was working on a little tool that helps me track the time of all (or just one) the different tasks at work. Since the work intensity went down it opened up time (yay!) for some personal stuff. We’re required to record our everyday labor and sometimes it became quite complicated to calculate how much time was spent on a single task, especially when the day didn’t start at 08:00 o’clock but some randome time earlier and ended at some random time.

Introducing: WorkTrackerRead More »

Controlling a Mac’s fans (AppleSMC)

Since the iMac found its way onto my desk I’ve been bothered with the heat generated when playing Diablo 3 (or possibly any other game) – just as with the MacBook Pro. The only difference: The MacBook’s fans were howling to stop the torment, the iMac just swallows the pain it seems. Don’t get me wrong, the system is not overheating and temperature is well within its limits. In fact, the CPU doesn’t even really heat up. It’s more the graphics chip and the power supply. But for me as a former PC user who built all the PCs himself and always had a good (and mostly quiet) cooling this is just a bit unusual.Read More »