Rufledore
Rufledore

Reputation: 33

Qt5 CMake can't find C++ STD library if a definition is added in CMakeLists.txt

Here is the problem I am struggling with.

I am using CMake to build my Qt5 GUI project. I am using a custom module QML-material project from GitHub. The problem is that as it is said in the project documentation - in order to setup the module for your project, you should add a definition:

add_definitions("-DQPM_INIT\(E\)=E.addImportPath\(QStringLiteral\(\"qrc:/\"\)\)\;")

But if this definition is added in CMakeLists.txt the project can't find C++ STD library. If I comment it out the STD features can be used again.

About the definition meaning.

This macro basically calls addImportPath("qec:/") to the argument it is called with. In my case it is in main():

// Working example
QQmlApplicationEngine engine;
QPM_INIT(engine);

But if I just change it and call addImportPath straight forward and remove the definition it doesn't find the custom QML modules.

// Not working example
QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral("qrc:/"));

My questions:

NB! The Qt libraries are still visible. The problem is only with the STD.

Upvotes: 0

Views: 237

Answers (1)

Rufledore
Rufledore

Reputation: 33

Most of the compilers does not tolerate function like definitions. Adding such a macro with add_definition is a workaround as it adds the macro to CXX_FLAGS, not to CXX_DEFINES, but apparently it doesn't work properly too.

Upvotes: 1

Related Questions