Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QtCreator runs CMake from /tmp directory

    General and Desktop
    qtcreator cmake cmakelists.txt ubuntu 14.04
    3
    6
    3393
    Loading More Posts
    • 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
      StrikeEagleIII last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • S
          StrikeEagleIII last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • S
              StrikeEagleIII last edited by

              Perfect. Thanks!

              1 Reply Last reply Reply Quote 0
              • hunger
                hunger last edited by

                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 Reply Quote 1
                • First post
                  Last post