Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to specify different compiler flags for different cpp files within a single qmake project?
Forum Updated to NodeBB v4.3 + New Features

How to specify different compiler flags for different cpp files within a single qmake project?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.8k Views 1 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    Is it possible to compile a number of .cpp files within a project with different compiler flags than other files?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Violet Giraffe
      wrote on last edited by
      #2

      I've found and tried this trick:

      @QMAKE_CXXFLAGS += -march=x86-64 -msse -msse2

      Creating a new compiler for sources that use AVX

      gccavx.input = SOURCES_AVX
      gccavx.output = ${QMAKE_FILE_BASE}.o
      gccavx.commands = g++ $$QMAKE_CXXFLAGS ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} -mavx -mfma -I$$IN_PWD/linux
      QMAKE_EXTRA_COMPILERS += gccavx

      SOURCES_AVX += AVX.cpp@

      But it doesn't exactly work as it should. I'm compiling a static lib using this trick, and am getting a lot of "undefined reference", including main, for this one file I'm compiling with this trick. I think a linker is invoked, while I only need to compile the file so that it's linked with others using global linker flags.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3

        Why not have two different projects, which are then combined into a single SUBDIRS project?

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Violet Giraffe
          wrote on last edited by
          #4

          Because I need it to link into a single library, not two libraries. Anyway, I've figured it out, just need to correct the code in my question a little bit.

          1 Reply Last reply
          0

          • Login

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