# Controlling link order with imported (INTERFACE) targets

**URL:** <https://discourse.cmake.org/t/controlling-link-order-with-imported-interface-targets/3295>\
**Category:** Code\
**Tags:** os:linux, gen:makefiles\
**Created:** [May 11, 2021, 8:14pm UTC](https://discourse.cmake.org/t/controlling-link-order-with-imported-interface-targets/3295 "2021-05-11T20:14:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brentd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brentd/32/3596_2.png) [@brentd](https://discourse.cmake.org/u/brentd)\
**Post date:** [May 11, 2021, 8:14pm UTC](https://discourse.cmake.org/t/controlling-link-order-with-imported-interface-targets/3295/1 "2021-05-11T20:14:27Z")

</div>

I have a project using the FFTW3 library and also trying to detect if the Intel MKL library is present. If it is present, I want to link the MKL before I link the FFTW library to enable the FFTW library to use the MKL. I have written a small FindMKL cmake script to create an MKL target to add to my target\_link\_libraries() line. The Find script defines an INTERFACE library for the MKL and an alias to that library.

No matter what I do, I am unable to change the link order of the underlying MKL shared library relative the FFTW library. The MKL library is always prepended to the link line, keeping the FFTW library from using the MKL routines.

What is the solution to this? Are INTERFACE libraries always prepended to the linker’s options? I found a similar issue on the forum with link flags, but this is an actual link library to be linked in. Should I be treating this as a flag?

Thanks,  
Brent
