pthread was not inserted into mkl on subsequent cmake call

Code was short-circuited.
Moved all codes into separate macros that are called only if necessary.