IMPORTED_LINK_INTERFACE_MULTIPLICITY not working for me
Linking against the Intel MKL static libraries introduces circular dependencies. Here is a minimal example that fails for me,
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(test Fortran)
add_executable(main main.f90)
set(LIBRARIES mkl_intel_lp64 mkl_sequential mkl_core)
foreach(_lib ${LIBRARIES})
add_library(${_lib} UNKNOWN IMPORTED)
set_target_properties(${_lib} PROPERTIES IMPORTED_LOCATION
/opt/intel/mkl/lib/intel64/lib${_lib}.a
IMPORTED_LINK_INTERFACE_MULTIPLICITY 3)
endforeach()
list(APPEND LIBRARIES dl pthread)
target_link_libraries(main PRIVATE ${LIBRARIES})
#target_link_libraries(main PRIVATE ${LIBRARIES} ${LIBRARIES} ${LIBRARIES})
#target_link_libraries(main PRIVATE -Wl,--start-group ${LIBRARIES} -Wl,--end-group)
# main.f90
call zpotrf
end program
The build fails with undefined references. If I uncomment either of the two last lines in CMakeLists.txt the build succeeds.
Did I misunderstand how IMPORTED_LINK_INTERFACE_MULTIPLICITY
works? I thought it works more or less exactly like the commented lines in my CMakeLists.txt example, except in a more elegant way.
Edited by Raul Laasner