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 can I specify different compile options for each source file in a project
Forum Updated to NodeBB v4.3 + New Features

How can I specify different compile options for each source file in a project

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 336 Views
  • 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.
  • R Offline
    R Offline
    rjmoses
    wrote on last edited by
    #1

    How can I set up the projects file to have different compile options for each C/C++ source code module.

    N.B.: The actual usage is radically different than this grossly simplified example. It is NOT possible to use a different name.

    DEFINES += USE_MAX=3
    DEFINES += USE_MAX=5

    SOURCES +=
    main.c \
    Mod1.c \ (Would like to have DEFINES += USE_MAX=3)
    Mod2.c (Would like to have DEFINES += USE_MAX=5)

    Thanks

    JonBJ 1 Reply Last reply
    0
    • R rjmoses

      How can I set up the projects file to have different compile options for each C/C++ source code module.

      N.B.: The actual usage is radically different than this grossly simplified example. It is NOT possible to use a different name.

      DEFINES += USE_MAX=3
      DEFINES += USE_MAX=5

      SOURCES +=
      main.c \
      Mod1.c \ (Would like to have DEFINES += USE_MAX=3)
      Mod2.c (Would like to have DEFINES += USE_MAX=5)

      Thanks

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @rjmoses
      Does the answer in https://stackoverflow.com/questions/27683777/how-to-specify-compiler-flag-to-a-single-source-file-with-qmake work for you?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rjmoses
        wrote on last edited by
        #3

        Thanks for the suggestion. Unfortunately, it doesn't quite fit what I need in that I would have to have separate compiler code for each module.

        I am using something similar to the post you suggested for re2c tokenizer and the lemon grammar parser.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Use cmake with set_properties() and COMPILE_DEFINITIONS.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          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