Results 1 to 6 of 6

Thread: Specific compiler options for specific source files in qmake?

  1. #1
    Join Date
    Mar 2009
    Posts
    39
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Specific compiler options for specific source files in qmake?

    On qmake (QtCreator) is there a way to set specific compiler options for specific source files?

    I use some typeinfo/dynamic_cast in specific locations but I'd prefer to not have all the classes names around in the Release final executable. I thought that compiling with rtti only those modules would suffit. Otherwise the final exe would be fully documented with all the class names and I don't want to (or is there some other feature or strategy to deal with this?)

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Specific compiler options for specific source files in qmake?

    There is a way to do it but it is certainly not something you can write down in two lines of code or with a click on a button. You'd have to provide a custom compiler definition for qmake. This is described in the docs as well as in our wiki. But I'm not convinced your approach is a good idea.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Posts
    39
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Specific compiler options for specific source files in qmake?

    Thanks for the reply. Please feel free to elaborate if you are willing to. What do you think is the bad idea, compiling with separate options or the fact of wanting to somehow obfuscate the executable?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Specific compiler options for specific source files in qmake?

    I think it is a bad idea to compile one file with rtti enabled and others with it disabled. Either enable it everywhere or disable it everywhere. It is best to avoid dynamic_cast altogether. Maybe you can substitute it with qobject_cast?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    thru (14th February 2011)

  6. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Specific compiler options for specific source files in qmake?

    I agree that using different compiler flags for different source files is a bad idea. Many flags are mutually exclusive, and using them incorrectly in different source files will produce compile time errors, or - much worse - runtime errors that are extremely difficult to pin down.

    If you insist, however, the simplest approach would be to gather all your source files requiring a particular set of flags into a single project, and build them into a library that is linked by another project. The flags set in the project files for each can then be different.

  7. The following user says thank you to SixDegrees for this useful post:

    thru (14th February 2011)

  8. #6
    Join Date
    Mar 2009
    Posts
    39
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Specific compiler options for specific source files in qmake?

    Many thanks for your suggestions. I think I have a quick and dirty solution but that works, after compiling the impudic names are on the executable in a single place so rewriting them with meaningless strings of the same length does the trick (under Windows seems to work well)

Similar Threads

  1. platform specific qmake versions ?
    By andjesto in forum Newbie
    Replies: 1
    Last Post: 17th January 2011, 18:45
  2. Replies: 3
    Last Post: 19th July 2010, 10:59
  3. Replies: 1
    Last Post: 10th March 2010, 10:12
  4. Replies: 4
    Last Post: 10th February 2010, 06:47
  5. How to access files from specific folder using QContentSet
    By hrudhay in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 30th June 2008, 19:57

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.