Qt Creator: Shared project settings for CMake project



  • Is there a way to share Qt Creator project settings when working on a CMake project? I'm thinking about something like what's described for QMake projects in https://doc.qt.io/qtcreator/creator-sharing-project-settings.html. The idea would be to check the "shared" config into a GIT repository.

    It looks like the CMake equivalent to a .pro.user file is CMakeLists.txt.user, so you might think CMakeList.txt.share would have the same role as the .pro.shared file. I tried creating such a file, though, and as far as I could tell, it was not read at start-up.

    So, is there CMake equivalent to a .pro.shared file, and if there is, what is it called? If not, what would be the best way to share settings via a version control system? I could check in the .user file, obviously, but I suspect that it also contains state information that makes it somewhat unsuitable for that purpose.


  • Qt Champions 2018

    What settings to do you want to share exactly?



  • I want to share the actual build and run configurations from the Qt Creator project settings. For a certain project I'm importing, the build configs that are generated when you load a CMake configuration are not 100 % suitable; I need to

    • Assign a special kit, which sets up an "alternative" compiler and CMake version. (I want to be able to share that, too, but that's in a way a separate issue.)
    • Change the build directory - as the CMake set-up tries to enforce certain conventions. (I could change the Build&Run default, but that's not really a shared setting, either.)
    • Make some minor adjustments to the CMake settings
    • Define a number of environment variables

    In addition to that, I want to add extra configs for special cases like a partial build. (This is a fairly large multi-directory project.)

    For the run configs, I may need a "non-default" current directory as well as special command line arguments in some cases.

    I might perhaps also mention that ideally, I want to set up the environment variables in a project-wide manner (but not system-wide or user-wide) rather than defining them in every build configuration, but I can't find a way to do that.


  • Qt Champions 2018

    But such settings are neither stored in cmake nor qmake files. I think you have to dig into the qtcreator configuration files to see if you can share some of them



  • @Christian-Ehrlicher
    It seems like you didn't read my original post.

    For a CMake project, these settings are stored in a file called CMakeLists.txt.user. That file is not cmake config as such - it's qtcreator specific. The problem is, it also contains dynamic state information that changes pretty much every time you run qtcreator. That means it's not quite an ideal candidate for sharing.

    For qmake projects, there is a similar situation; config and state is stored in a file with extension .pro.user - but in that case, you can also choose to put "static" information in a .pro.shared file, and the .pro.user file gets synced against it on start-up. That's documented in the link I provided. I was asking if there is an equivalent mechanism for CMake.


  • Qt Champions 2018

    The CMakeLists.txt.user is not meant to be moved around. Neither is .pro.user
    There is nothing like a .txt.shared file nor does my qtcreator (4.8.2) create such a file when I open a .pro project file so I don't know what's inside this file which could be shared somehow.


  • Lifetime Qt Champion

    Hi,

    @Christian-Ehrlicher the content of the .pro.shared file is explained here.

    I don't know however if there's an equivalent for cmake currently.


  • Qt Champions 2018

    @SGaist said in Qt Creator: Shared project settings for CMake project:

    I don't know however if there's an equivalent for cmake currently.

    No since these are no configuration specific parameters but settings for the editor. Looks like qtcreator is misusing a the .pro extension since it has even nothing to do with the qmake syntax. But maybe @aha_1980 knows more?


  • Qt Champions 2018

    Hi @Christian-Ehrlicher @SGaist @toralf

    I honestly don't know how the state of CMake .shared is. Best would be to ask on the [Creator mailing list]https://lists.qt-project.org/listinfo/qt-creator() where the developers can better answer that question.

    However, as @Christian-Ehrlicher already said, the .shared settings are not thought for build system specific setups. There is an idea that a project setup wizard could do things like that, but I'm not even aware of a task, not to mention a date when that could happen.

    The only thing I can say, is that many people have similar needs as you have and such a wizard would be very welcome.

    Regards



  • @Christian-Ehrlicher said in Qt Creator: Shared project settings for CMake project:

    @SGaist said in Qt Creator: Shared project settings for CMake project:

    I don't know however if there's an equivalent for cmake currently.

    No since these are no configuration specific parameters but settings for the editor

    On what do you base that statement?

    As far as I can tell, project.pro.user or CMakeLists.txt.user or (for a plain Makefile project) project.creator.user contains everything you enter in the Projects mode GUI, including build and run settings, and that information is stored nowhere else, and qtcreator looks for all ".user" settings in ".shared" as well in cases where the file is supported.

    The .pro.shared documentation does mention

    Typically, you would share some of the values in the ProjectExplorer.Project.EditorSettings section.

    but that's a far cry from saying that the file is meant exclusively for editor settings.



  • The only thing I can say, is that many people have similar needs as you have and such a wizard would be very welcome.

    I honestly don't see what good something like that would do. The principal mechanism for sharing configuration is already in place, and like I said elsewhere, it does support build and run configurations. I've no idea whether it was "meant for" that purpose, but it works, so why should I care? The only problem is that support for the CMake version of the XML files may be missing.

    Or, I guess there is some room for improvement - like there might be a simpler way to copy settings to the shared configuration than using a plaintext editor, and there could be a better mechanism for setting up "project relative" file names and paths. A "project setup wizard" doesn't sound like something that would address those issues, though.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.