Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-26110

Add build library search path to PATH doesn't prepend dependencies folders

    XMLWordPrintable

    Details

    • Platform/s:
      Windows
    • Commits:
      c1c70d339d66784896a0bb5310b91337563dd280 (qt-creator/qt-creator/5.0)

      Description

      Hi Tobias Hunger the #28742 is buggy on Windows, it works correctly on Unix and correctly adds dependency libraries paths to the LD_LIBRARY_PATH, but it doesn't on windows ( not to LD_LIBRARY_PATH but to PATH of course on Windows ).

      I have spent 7 hours yesterday investigating what is going on, first I thought that I have something bad in my CmakeLists.txt, after few hours I understood that the problem will be somewhere else.

      Then I discovered this PR #28742 and found these files in CMake build directory .cmake\api\v1\reply\target-utils-Debug-b58a280613befd8bf0f3.json and I understood that the Qt Creator somehow queries the CMake build system and obtains info about dependencies for every target ( FileApi and so-called fragments in your source code ). So I started investigating these files.

      I have discovered that on Unix the fragments at link.commandFragment.fragment have forward slashes in the path, but on Windows, they have double backslashes and this can be a source of the whole problem. eg.

      "link" :
      {
          "commandFragments" :
          [
              {
                  "backtrace" : 6,
                  "fragment" : "tests\\auto\\utils\\utils.lib",
                  "role" : "libraries"
              },
          ]
      }

      Problem is that I don't have setup qtcreator dev. env. so I can not verify it, I have deduced it only from the #28742 PR and the source of the problem can still be somewhere else.

      I have also set up a simple example that should add 2 paths on the PATH, but on windows, it adds only 1 path, and it is the path of the compiled executable ( I don't understand why this path ), the rest 2 paths for executable library dependencies are not added.

      This example behaves correctly on Unix and it correctly adds 2 paths on LD_LIBRARY_PATH.

      library_cmake.tgz

      Let me know what do you need to fix or confirm this issue, can you verify it?

      Part 2

       So I tried to use the same commands that process filepaths in PR #28742 and manually paste buggy input: 

      QDir buildDir("e:\\c\\qMedia\\TinyOrm\\TinyOrm-builds\\build-TinyOrm-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug-cmake");
      
      auto currentBuildDir = QDir(buildDir.absoluteFilePath(buildDir.currentPath()));
      
      QString p = "tests\\\\auto\\\\utils\\\\utils.lib";
      auto fromNative = QDir::fromNativeSeparators(p);
      auto tmp = currentBuildDir.absoluteFilePath(fromNative);
      

      These commands are exactly the same as here and here

       And at the end here the command looks like this: 

      librarySeachPaths.append("E:/c/tests_qt/qt_auto_test_cmake/qtautotest_cmake-builds/build-qtautotest_cmake-Desktop_Qt_5_15_2_MSVC2019_64bit-Debug/tests//auto//utils//utils.lib");

      Do you see it, it contains double forward slashes. 

      All this is based on the assumption that input.targetDetails here already contains paths with double backslashes on Windows, if it doesn't then the problem will be somewhere else.

      Part 3

      Screenshots below are from the library_cmake example project that I have uploaded in the comment above and I have selected Run Configuration for the query subproject, to be clear I'm pasting screenshot:

      It adds 2 paths on Unix:

      And 1 path on windows:

      On windows, it adds the path of compiled autotest exe, I don't understand why this folder?

      On Unix it adds 2 paths of compiled autotest executable's shared library dependencies, this is correct.

        Attachments

        1. cmake_path_run_config.jpg
          cmake_path_run_config.jpg
          74 kB
        2. library_cmake.tgz
          2 kB
        3. Unix_LD_LIBRARY_PATH.jpg
          Unix_LD_LIBRARY_PATH.jpg
          68 kB
        4. WIndow_PATH.jpg
          WIndow_PATH.jpg
          69 kB

          Issue Links

          For Gerrit Dashboard: QTCREATORBUG-26110
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              cadam Cristian Adam
              Reporter:
              silverq Silver Zachara
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes