Linking against target specific libraries

I’m the author of jTox and I’ve always used static libraries to link with for the project.

Now that aarch64 is here tho the method I used to “switch” the library source folder is clunky. I used this kind of trick to switch based on project build profile:

CONFIG(debug,debug|release){ TOX_PATH = extra/i486 }
# CONFIG(debug,debug|release){ TOX_PATH = extra/armv7hl }
CONFIG(release,debug|release){ TOX_PATH = extra/armv7hl }
# CONFIG(release,debug|release){ TOX_PATH = extra/aarch64 }

This is pretty clunky now however. Is there a better way I can point to specific folders based on the target platform with the newer SDKs?

Have you tried just using the %{_arch} variable in your spec file?

How would that work tho? The choice of folders to use for linking is defined in the .pro file

You can define an environment variable in your specfile, i.e. JTOX_ARCH=%{_arch} and then expand that in your project file using $$(JTOX_ARCH). There are probably also QMAKE_TARGET related variables that could work without that, but I don’t know qmake good enough for that.

This works, as long as I whitelist the env var in the sailfishOS general config as well (took me a while to figure out why the env var was missing).

1 Like