Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,823
    • Issues 3,823
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMake
  • CMakeCMake
  • Issues
  • #17964
Closed
Open
Created May 04, 2018 by Raul Laasner@raullaasnerContributor

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.

CMakeFiles/3.11.1

Edited Feb 15, 2021 by Raul Laasner
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking