Moving Users folder on Windows

These are the step required to move the Users folder from the system partition to an other partition e.g. from C:\ to D:\ .
Note that once rebooted in command line mode the drive letter might have changed; you must check the actual drive letters and change the commands accordingly.

  1. Reboot in command line mode
  2. robocopy /copyall /mir /xj C:\Users D:\Users
  3. rmdir /S /Q C:\Users
  4. mklink /J C:\Users D:\Users

qmake and vcpkg

I’ve been trying to use vcpkg lately. And if it works easily with CMake, using it with qmake is undocumented. A quick Google search gives useless results including 2 year old forum posts where the conclusion is to use CMake. However there is hope.

How vcpkg works

To understand how vcpkg can be made to work with qmake we have to understand how it works when used normally i.e. with CMake.

When you install a package with vcpkg it gets installed in the packages/<package-name>_<triplet> folder. But you do not really need to care as vcpkg provides a CMake toolchain file that will automatically detect the vcpkg installed packages.

Let’s say you want to install and use yaml-cpp, all you have to do is:

./vcpkg install yaml-cpp
cd <my_project>
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=<path_to_vcpkg>/scripts/buildsystems/vcpkg.cmake
cmake . -build

Provided that in your CMakeLists.txt you have:

find_package(yaml-cpp CONFIG REQUIRED)
target_link_libraries(my_project PRIVATE yaml-cpp)

It will just work and you project will link againt the yaml-cpp library provided by vcpkg.

Solution 1: brute force

Sadly, vcpkg does not provide any support for qmake, so it won’t work out of the box by simply adding a command line option. However, we can take adavantage that vcpkg does not only put installed packages in the packages folder but also in the installed folder where we have a nice hierarchy:

installed/x64-linux/debug/lib/libyaml-cpp.a
installed/x64-linux/include/yaml-cpp/
installed/x64-linux/lib/libyaml-cpp.a

That means that you just can just add a few line to you .pro file to use vcpkg libraries.

CONFIG(debug, debug|release) {
    LIBS += -L<vcpkg>/installed/<triplet>/debug/lib
} else {
    LIBS += -L<vcpkg>/installed/<triplet>/lib
}

INCLUDEPATH += <vcpkg>/installed/<triplet>/include

And then you just need to add LIBS += -lyaml-cpp to link against the yaml-cpp library provided by vcpkg

Solution 2: pkgconfig

This second solution take advantages of pkgconfig and PKG_CONFIG_PATH. To use this solution you need to update your .pro with:

CONFIG += link_pkgconfig
PKGCONFIG += yaml-cpp

And then run qmake with PKG_CONFIG_PATH pointing to the vcpkg installed folder:

PKG_CONFIG_PATH=<vcpkg>/installed/x64-linux/lib/pkgconfig qmake my_project.pro