How to enable --threads:on only for files using it?

231 Views Asked by At

In a project producing multiple binaries, where only some of them are importing a library (in this case "threadpool") which requires --threads:on to be passed to the compiler, what would the way to handle this?

In my nimble file I have something like

srcDir = "src"
binDir = "bin" 
namedBin = {
    "program ": "program", 
    "prog_threads": "program-threads", 
}.toTable()

and at the moment I have --threads:on in my nim.cfg file, which results in all the binaries being compiled with threads support. I realized this is not what I need as it creates problems downstream, and I would need a way to compile program without threads an prog_threads with it.

I'm using a "Makefile" as workaround, but I would love to be able to build the project with nimble build.

1

There are 1 best solutions below

0
On BEST ANSWER

You need to use config file per module. Put --threads:on into <module name>.nim.cfg