Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QtCreator runs CMake from /tmp directory
Forum Updated to NodeBB v4.3 + New Features

QtCreator runs CMake from /tmp directory

Scheduled Pinned Locked Moved Solved General and Desktop
qtcreatorcmakecmakelists.txtubuntu 14.04
6 Posts 3 Posters 4.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StrikeEagleIII
    wrote on 15 May 2017, 20:37 last edited by
    #1

    I have a CMake project in which one of the first things done is to run

    execute_process (COMMAND git rev-parse --show-toplevel OUTPUT_VARIABLE FOCUS_REPO_ROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
    

    to get the root directory of the repository. It fails though because qtcreator appears to be running cmake from a /tmp folder:

    Running "/usr/bin/cmake /home/overlord/focus/build/cmake '-GCodeBlocks - Unix Makefiles' -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER:STRING=/usr/bin/g++ -DQT_QMAKE_EXECUTABLE:STRING=/home/overlord/Qt5.7.0/5.7/gcc_64/bin/qmake" in /tmp/qtc-cmake-DU5v5x
    

    The error received is

    fatal: Not a git repository (or any of the parent directories): .git
    

    and qtcreator quits parsing the CMakeLists.txt file.

    Is there a way to tell qtcreator to run CMake from a specific directory?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 15 May 2017, 22:08 last edited by
      #2

      Hi,

      You should add which version of Qt Creator you are using.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        StrikeEagleIII
        wrote on 16 May 2017, 13:47 last edited by
        #3

        I am using Qt Creator 4.0.2 (Qt 5.7.0, although I am not using the qt libraries in this project)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 16 May 2017, 20:29 last edited by
          #4

          After a quick check, you should add WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} to your execute_process calls. That way the command will be called in your project source tree whatever the folder cmake is called from.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            StrikeEagleIII
            wrote on 16 May 2017, 20:36 last edited by
            #5

            Perfect. Thanks!

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hunger
              wrote on 18 May 2017, 05:53 last edited by
              #6

              CMake insists on creating the build directory, and it is annoying that you have to delete build directories all over the place when all you want to do is take a quick look at some sources. So creator "builds" in a temporary directory to extract information from CMake -- till you actually trigger an explicit build from creator. At that point the actual build directory is created and all the files go there.

              You need to tell cmake to run your command in the source directory if those commands depend on being run from there: CMake usually does not build in the directory your sources are and will default to running stuff in the build directory.

              1 Reply Last reply
              1

              1/6

              15 May 2017, 20:37

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved