Results 1 to 8 of 8

Thread: qmake exclude specific file in SOURCES

  1. #1
    Join Date
    Nov 2015
    Posts
    41
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default qmake exclude specific file in SOURCES

    Is there any way to exclude one file from statement

    Qt Code:
    1. SOURCES += ../src/*.cpp
    To copy to clipboard, switch view to plain text mode 

    I want to join to SOURCES all .cpp files from src dir but without main.cpp

  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: qmake exclude specific file in SOURCES

    Have you tried

    Qt Code:
    1. SOURCES += ../src/*.cpp
    2. SOURCES -= ../src/main.cpp
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Nov 2015
    Posts
    41
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qmake exclude specific file in SOURCES

    Yes, but i get and error

    error: multiple definition of `main'
    I want to join each .h and .cpp file for unit testing project which is a part of subdirs template project.

    But test project has own main function which is declared by means of command

    QTEST_MAIN(myClass)
    #include "myClass.moc"

    I do not want to add each file separately

    HEADERS += myclass.h \
    myclass2.h \
    itd

    SOURCES += myclass.cpp \
    myclass2.cpp \
    itd \

    So I try to find better solution.
    Screenshot of project structure
    subdirs project.jpg

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qmake exclude specific file in SOURCES

    First solution - common files in src directory, two main.cpp files in subdirs of src.
    In pro file You have :
    SOURCES += ../src/*.cpp
    SOURCES += ../src/subdir/main.cpp

    Second solution - one main.cpp with conditional compilation.

  5. #5
    Join Date
    Nov 2015
    Posts
    41
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qmake exclude specific file in SOURCES

    Is there any official or good template for projects with unit testing? In Qt documentation i have not found any information about that how to join main project with unit testing. Whether it should be 2 completely separated projects? Or as I use in example above - subdirs template?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: qmake exclude specific file in SOURCES

    Quote Originally Posted by Scope View Post
    Is there any way to exclude one file from statement

    Qt Code:
    1. SOURCES += ../src/*.cpp
    To copy to clipboard, switch view to plain text mode 

    I want to join to SOURCES all .cpp files from src dir but without main.cpp
    See if this works for you:
    http://sergey.vlasov.me/2013/03/expa...ith-qmake.html

    You will still have to rerun qmake if you add or remove files from any of the globbed directories.

  7. #7
    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: qmake exclude specific file in SOURCES

    Quote Originally Posted by Scope View Post
    Is there any official or good template for projects with unit testing? In Qt documentation i have not found any information about that how to join main project with unit testing. Whether it should be 2 completely separated projects? Or as I use in example above - subdirs template?
    For a QMake based project I would go for a SUBDIRS template.

    Cheers,
    _

  8. The following user says thank you to anda_skoa for this useful post:

    Scope (23rd July 2016)

  9. #8
    Join Date
    Nov 2015
    Posts
    41
    Thanks
    5
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qmake exclude specific file in SOURCES

    I also found information that QtCeator sinve 4.0 version has feature called "Autotest integration". It sound promising
    http://doc-snapshots.qt.io/qtcreator...-autotest.html

Similar Threads

  1. qmake HEADERS/SOURCES and INCLUDEPATH
    By conti in forum Newbie
    Replies: 2
    Last Post: 28th January 2012, 19:29
  2. Replies: 5
    Last Post: 14th February 2011, 15:06
  3. platform specific qmake versions ?
    By andjesto in forum Newbie
    Replies: 1
    Last Post: 17th January 2011, 19:45
  4. Replies: 1
    Last Post: 10th March 2010, 11:12
  5. qmake fails processing many many sources in one .pri
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2009, 09:54

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.