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

CMake: Proper use of TREE argument in source_group

    XMLWordPrintable

Details

    • 423315178 (12.0)

    Description

      QtCreator should not create a top level virtual folder named TREE when using source_group(TREE <src>) command.

      The reasoning for this is, as per CMake specs, the TREE option is a special argument for the source_group command, it is not the actual <name> argument, and as such it should be considered a distinct case, i.e. "CMake will automatically detect, from <src> files paths, source groups it needs to create, to keep structure of source groups analogically to the actual files and directories structure in the project. Paths of <src> files will be cut to be relative to <root>".

      So in my opinion the actual fix would be simple: when source_group(TREE <src>) command is used, do not consider TREE as a group <name> argument but treat it as a special case (as per spec) and don't create a virtual folder named TREE (just use the the physical file organization from the file system, and place the top directories relative to the <root> as direct children of the project node).

      As an example, when using source_group(TREE ${PROJECT_SOURCE_DIR}) the project structure:

      1. should look like this (GOOD):

      <target>
         | actual_dir_on_fs
            | src_file.h
            | src_file.c
         | another_actual_dir_on_fs
            | another_src_file.h
            | another_src_file.c

      2. instead of (BAD):

      <target>
         | TREE
            | actual_dir_on_fs
               | src_file.h
               | src_file.c
            | another_actual_dir_on_fs
               | another_src_file.h
               | another_src_file.c

      3. or instead of (BAD):

      <target>
         | Header Files
            | actual_dir_on_fs
               | src_file.h
            | another_actual_dir_on_fs
               | another_src_file.h
         | Source Files
            | actual_dir_on_fs
               | src_file.c
            | another_actual_dir_on_fs
               | another_src_file.c

      Applying the attached patch seems to fix the problem, and the project structure looks like case 1 above(0001-CMake-Proper-use-of-TREE-argument-in-source_group.patch).

       Related issues: QTCREATORBUG-23372 and QTCREATORBUG-23318.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              hunger Tobias Hunger
              iq2luc Luc
              Votes:
              7 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes