Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for imported targets #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented Sep 8, 2018

  • Add CMake property target for disabling the use of CMAKE_<Lang>_IMPLICIT_LINK_* variables.

This is relevant when the project enables Fortran language and its CMake_Fortran_COMPILER_ID is different from the one of targets imported via find_package(Foo)

Explicitly updating the Foo targets setting IMPLICIT_LINK_<LANG>_ENABLED to 0 will ensure only the <Fortran_IMPORTED_TARGET_NAMESPACE>_Fortran_<Fortran_COMPILER_ID>_SUPPORT_LIBRARIES are linked.

Within property like IMPLICIT_LINK_Fortran_ENABLED, it looks like the same effect can be achieved removing Fortran from the IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE properties but this cumbersome:

set_target_properties(blas PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "")
set_target_properties(lapack PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "")

Ideally the foo-config.cmake.in would look like this:

[...]

include("${_Foo_SELF_DIR}/foo-targets.cmake")

# Hint for project building against Foo
set(Foo_Fortran_COMPILER_ID "@CMAKE_Fortran_COMPILER_ID@")

if("SupportLibraries" IN_LIST Foo_FIND_COMPONENTS)
  include(CMakeFindDependencyMacro)

  set(Fortran_COMPILER_ID ${Foo_Fortran_COMPILER_ID})
  set(Fortran_IMPORTED_TARGET_NAMESPACE "Foo")

  find_dependency(Fortran)

  target_link_libraries(Foo INTERFACE  ${Foo_Fortran_${Foo_Fortran_COMPILER_ID}_SUPPORT_LIBRARIES})

  set_target_properties(${Fortran_IMPORTED_TARGET_NAMESPACE}::Fortran_${_id}_${_lib} 
    PROPERTIES IMPLICIT_LINK_ENABLED 0)

  # cleanup
  unset(Fortran_COMPILER_ID)
  unset(Fortran_IMPORTED_TARGET_NAMESPACE)
endif()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant