Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator+cmake: list all files in project tree
Forum Updated to NodeBB v4.3 + New Features

QtCreator+cmake: list all files in project tree

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
5 Posts 2 Posters 6.5k 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.
  • miclandM Offline
    miclandM Offline
    micland
    wrote on last edited by
    #1

    I'm working on a cmake based project (non-Qt) and I want to open and edit the project with the QtCreator. I was able to oben, configure and build the project with QtCreator but now I noticed that not all files are listed in the project tree:
    The CmakeLists.txt files reference only the .cpp files so the QtCreator lists only the named .cpp files and their corresponding .hpp file. There are also several header only implementations which are included in some cpp files but which are not listed in the cmake files so the QtCreator does not show them in the project tree.
    (I did not create this cmake structure so I do not want to discuss if this is a wrong usage of cmake or not).

    My question is: Does anyone know a trick how to list all files in the project tree, regardless whether the files are listed in CMakeLists.txt or not.
    I'm looking for a way without editing / fixing / adjusting all the CMakeLists.txt (e.g. Eclipse/CDT lists all files found in the filesystem and that might be the reason why these cmake files contain no header files).

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by A Former User
      #2

      Hi! You can change the view from "Projects" to "File System". Above the treeview, there is a combobox where you can switch between the settings.

      miclandM 1 Reply Last reply
      1
      • ? A Former User

        Hi! You can change the view from "Projects" to "File System". Above the treeview, there is a combobox where you can switch between the settings.

        miclandM Offline
        miclandM Offline
        micland
        wrote on last edited by
        #3

        @Wieland
        I had the same idea but the "file system" view is just a flat view of one directory, not a hierarchical tree view so it's not a useful alternative (in my case)...

        1 Reply Last reply
        0
        • miclandM Offline
          miclandM Offline
          micland
          wrote on last edited by
          #4

          I found a solution that works for me: Instead of editing all the CMakeLists.txt I can add a dummy target in the top most CMakeLists.txt that collects all header files:

          file(GLOB_RECURSE ALL_SRC_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Source/*.hpp")
          file(GLOB_RECURSE ALL_TEST_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Tests/*.hpp")
          add_library(dummy_target_with_all_headers EXCLUDE_FROM_ALL ${ALL_SRC_HEADER_FILES} ${ALL_TEST_HEADER_FILES})
          target_link_libraries(dummy_target_with_all_headers)
          set_target_properties(dummy_target_with_all_headers PROPERTIES LINKER_LANGUAGE CXX)
          

          But I'm still looking for a way to move this target declaration to a separate file and pass this file as an additional command line argument to cmake so I don't have to modify the existing CMakeLists.txt file...

          miclandM 1 Reply Last reply
          1
          • miclandM micland

            I found a solution that works for me: Instead of editing all the CMakeLists.txt I can add a dummy target in the top most CMakeLists.txt that collects all header files:

            file(GLOB_RECURSE ALL_SRC_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Source/*.hpp")
            file(GLOB_RECURSE ALL_TEST_HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Tests/*.hpp")
            add_library(dummy_target_with_all_headers EXCLUDE_FROM_ALL ${ALL_SRC_HEADER_FILES} ${ALL_TEST_HEADER_FILES})
            target_link_libraries(dummy_target_with_all_headers)
            set_target_properties(dummy_target_with_all_headers PROPERTIES LINKER_LANGUAGE CXX)
            

            But I'm still looking for a way to move this target declaration to a separate file and pass this file as an additional command line argument to cmake so I don't have to modify the existing CMakeLists.txt file...

            miclandM Offline
            miclandM Offline
            micland
            wrote on last edited by
            #5

            Update: QtCreator 4.3 (beta1) lists all header files - regardless whether they are listed in the CMakeLists.txt or not (as long as "hide generated files" is not checked). The previously mentioned dummy target is not required anymore.

            1 Reply Last reply
            1

            • Login

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