b-com-software-basis / builddefs-qmake

QMake build script tools to manage cross platform project building and dependencies in development projects (also manages nsis installer, mac bundling...). Aims at providing Maven like dependencies management to C/C++ builds.
2 stars 4 forks source link

INCLUDEPATH issue with QTCreator Clang Code Model: errors in editor, compilation is fine #10

Closed jim-bcom closed 1 year ago

jim-bcom commented 2 years ago

HOW TO REPRODUCE Open a SolAR project, for example this one (the following examples are not from this project).

EXPECTED BEHAVIOR

OBSERVED BEHAVIOR

This makes QtCreator barely usable as we lose all completion and code navigation for our project dependencies.

SOME LEADS INCLUDEPATH is built in packagedependencies-parser.pri.

for (var, LIST_CFLAGVAR) {
    first2char = $$str_member($$eval($${var}), 0, 1)
    equals (first2char, "-I") {
        #manage path with space
        # TODO check with a real path with space
        INCLUDEPATH += $$shell_quote($$replace($$eval(var), -I,))
    } else {
        QMAKE_CXXFLAGS += $$eval($${var})
    }
}

I've tried several things. For example, with a missing reference to xpcf library:

I thought that some kind of special character might have been inserted by the loop in the list, so I've checked that every entry of that list is an existing file

for (incFile, INCLUDEPATH) {
    exists($${incFile}) {
        message("include file $${incFile} exists")
    }
}

All files do exist, all right:

Project MESSAGE: include file /home/user/.remaken/packages/linux-gcc/SolARBuild/SolARFramework/0.10.0/interfaces exists
Project MESSAGE: include file /home/user/.remaken/packages/linux-gcc/thirdParties/spdlog/0.14.0/interfaces exists
Project MESSAGE: include file /home/user/.remaken/packages/linux-gcc/xpcf/2.5.0/interfaces exists
Project MESSAGE: include file /home/user/.remaken/packages/linux-gcc/grpc/1.37.1/interfaces exists

So I tried to include those path to INCLUDEPATH:

for (incFile, INCLUDEPATH) {
    exists($${incFile}) {
        message("include file $${incFile} exists")
        INCLUDEPATH += $${incFile}
    }
}

Does not work.

I've tried to add the hard-coded path in the loop

for (incFile, INCLUDEPATH) {
    exists($${incFile}) {
        message("include file $${incFile} exists")
        INCLUDEPATH += /home/user/.remaken/packages/linux-gcc/xpcf/2.5.0/interfaces
    }
}

Does not work.

But if I add a hard-coded path after the loop, it works:

for (incFile, INCLUDEPATH) {
    exists($${incFile}) {
        message("include file $${incFile} exists")
        INCLUDEPATH += /home/user/.remaken/packages/linux-gcc/xpcf/2.5.0/interfaces
    }
}
INCLUDEPATH += /home/user/.remaken/packages/linux-gcc/xpcf/2.5.0/interfaces

It seems to behave as if the the concatenation in a for loop does not work.

CONFIGURATION OS: Windows 10 / gnu-Linux-Ubuntu 18.04 QtCreator 4.14.0 Qt: 5.15.2 MSVC 2019

QtCreator is an old version. I keep it to avoid regression issues I already encountered by upgrading. But this might be fixed in latest releases, I haven't tested it.

stefled commented 1 year ago

bug reproduced with :

The next release of builddefs-qmake 4.10.0 apparently no longer has this problem.

Management of INCLUDEPATH/QMAKE_CXXFLAGS has changed in packagedependencies-parser.pri. Generic separation of INCLUDE_PATH and QMAKE_CXXFLAGS has bee replaced by new pkgconfig commands for getting only concerned parameters :

PKGCFG_INCLUDE_PATH = $$system(pkg-config --cflags-only-I $$pkgCfgVars $$pkgCfgFilePath)
# disable external/system warnings
contains(DEPENDENCIESCONFIG,externaldeps)|contains(CONFIG,externaldeps)|contains(REMAKENCONFIG,externaldeps) {
  win32{
    QMAKE_CXXFLAGS += $$replace(PKGCFG_INCLUDE_PATH, -I," /external:I ")
  } else {
    QMAKE_CXXFLAGS += $$replace(PKGCFG_INCLUDE_PATH, -I, -isystem)
  }
} else {
  INCLUDEPATH += $$replace(PKGCFG_INCLUDE_PATH, -I, "")
}
QMAKE_CXXFLAGS += $$system(pkg-config --cflags-only-other $$pkgCfgVars $$pkgCfgFilePath)

NB : this code also handles removing warnings from external libraries with externaldeps config flag

I advise to delete the build folder so that the project is reindexed entirely with clang.

fix will be available in builddefs/qmake 4.10.0

stefled commented 1 year ago

available in release 4.10.0

stefled commented 9 months ago

external Deps is incompatible with removing clangd errors when indexing on Windows Ok on Linux

tested with SolarFramework branch develop