qmake and std::filesystem on Mac

Viewed 447

I'm using Qt Creator and a qmake project. I have what should be a very simple problem:

#include <filesystem>
...
std::filesystem::path myPath;

During the build, as well as in the IDE, I get the error 'path is unavailable: introduced in macOS 10.15'.

I can manually compile just fine with either g++ or clang++ (without using qmake).

My qmake project file has:

TEMPLATE = app
CONFIG += c++17
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
CONFIG += sdk_no_version_check

Is there a magical incantation? I don't even care about the build, as this isn't even a Qt app and I have a manually-produced Makefile. I just don't want the IDE to scream errors at me.

The closest related items I can find on StackOverflow about this talk about link issues. I'm not even getting that far within Qt Creator, although I've tried various suggested flags.

--

I'm doing more digging. I'm manually editing the produced Makefile and running make and getting the same errors out of clang++. I tried g++. Same errors. But normally I build with my own manually-written Makefile, and it's compiling clean.

So I looked at the flags:

-mmacosx-version-min=10.13

Removing that manually gets rid of the error during compilation (from the command line).

So, questions:

  1. How do I get qmake to NOT put that flag in the generated Makefile?

  2. How do I get the linter to not see that flag (I assume that's why it shows up inline in the code editor portion of the IDE)?

1 Answers

The magical incantation I was searching for turned out to be, in the .pro file:

 QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15

Without that, it was trying to build to support earlier versions of MacOS, which didn't have C++17 features yet.

Related