Results 1 to 5 of 5

Thread: Files with the same prefix as target cpp file automatically get added to project?

  1. #1
    Join Date
    May 2008
    Posts
    20
    Thanks
    1

    Default Files with the same prefix as target cpp file automatically get added to project?

    I was trying to test some different ways to add headers to a project (add_custom_target, source_group, etc.). To start to test this, I created a folder with my CMakeLists.txt:

    Qt Code:
    1. Project(TestProject)
    2. add_executable(Test Test.cpp)
    To copy to clipboard, switch view to plain text mode 

    and two other files, Test.cpp and Test.h. When I opened the CMakeLists.txt file with QtCreator and generated the project, I was suprised to find Test.h was added to the project. I created another header file, MyClass.h, and re-ran CMake and this file was not added to the project (as I originally expected).

    Is it the desired behavior for files with the same prefix to be added to the project? Or is there some other explanation of why Test.h would be added to the project without being mentioned in the CMakeLists.txt?

    Thanks,

    David

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Files with the same prefix as target cpp file automatically get added to project?

    What do you mean with "added to the projcet"?
    Did QtCreator modify your CMakeLists.txt and put Test.h into some variable?

    Cheers,
    _

  3. #3
    Join Date
    May 2008
    Posts
    20
    Thanks
    1

    Default Re: Files with the same prefix as target cpp file automatically get added to project?

    I mean that Test.h shows up in the list of files under TestProject in the Projects panel on the left side of the QtCreator window.

    David

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Files with the same prefix as target cpp file automatically get added to project?

    Ah, I see.

    My guess would be that cmake scans the source file for dependencies and provides that information in a way that allows QtCreator to use it.

    Cheers,
    _

  5. #5
    Join Date
    May 2008
    Posts
    20
    Thanks
    1

    Default Re: Files with the same prefix as target cpp file automatically get added to project?

    Nope, it's not that. There was no reference to Test.h in Test.cpp and it does appear in the project, and even when I add a reference (#include "MyClass.h") to MyClass.h, it does not appear in the project.

Similar Threads

  1. Replies: 8
    Last Post: 27th December 2013, 02:47
  2. Files added to the wrong .pro file
    By ComServant in forum Newbie
    Replies: 2
    Last Post: 13th February 2013, 18:00
  3. How do you add project file to existing source files?
    By airbud in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2012, 11:17
  4. how do I set the PREFIX inside the project file?
    By hakermania in forum Newbie
    Replies: 3
    Last Post: 19th August 2011, 21:09
  5. Replies: 1
    Last Post: 3rd December 2009, 23:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.