Skip to content

Broken CMake EXPORT set with external LLVM  #11138

@StefanBruens

Description

@StefanBruens
  • Checked for duplicates

Describe the bug

When trying to build with --builtin_llvm=OFF --builtin_clang=OFF --builtin_cling=ON, CMake reports an error

[   52s] -- Enabled support for:  builtin_cling builtin_openui5 dataframe davix exceptions fftw3 gdml gnuinstall http imt mathmore mlp minuit2 mysql opengl pgsql roofit rpath runtime_cxxmodules shared soversion sqlite ssl tmva tmva-cpu spectrum x11 xml xrootd
[   52s] -- Configuring done
[   53s] CMake Error: install(EXPORT "ROOTExports" ...) includes target "Cling" which requires target "clingInterpreter" that is not in any export set.
[   53s] CMake Error: install(EXPORT "ROOTExports" ...) includes target "Cling" which requires target "clingMetaProcessor" that is not in any export set.
[   53s] CMake Error: install(EXPORT "ROOTExports" ...) includes target "Cling" which requires target "clingUtils" that is not in any export set.
[   54s] -- Generating done

Expected behavior

CMake call succeeds

To Reproduce

The problem is caused by the SHARED libCling (TARGET Cling) specyfing the 3 OBJECT libraries from above as PUBLIC link libraries:

ROOT_LINKER_LIBRARY(Cling
$<TARGET_OBJECTS:ClingUtils>
$<TARGET_OBJECTS:Dictgen>
$<TARGET_OBJECTS:MetaCling>
LIBRARIES ${CLING_LIBRARIES} ${LINK_LIBS} ${CLING_PLUGIN_LINK_LIBS})

target_link_libraries(${library} PUBLIC ${ARG_LIBRARIES} ${ARG_DEPENDENCIES})

CLING_LIBRARIES is clingInterpreter;clingMetaProcessor;clingUtils.

OBJECT libraries which are just used as convenience libraries and are not installed should by specified as PRIVATE link libraries.

A minimal reproducer is given below, with PRIVATE it works fine, with PUBLIC cmake -B _builddir -S . fails.

project(exportTest)

cmake_minimum_required(VERSION 3.1)

add_library(objLib OBJECT)
target_sources(objLib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/objA.cxx)

add_library(shLib SHARED)
target_sources(shLib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/libA.cxx)
target_link_libraries(shLib PUBLIC objLib) # <-- fails
#target_link_libraries(shLib PRIVATE objLib) # <-- OK

add_executable(main)
target_sources(main PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/main.cxx)
target_link_libraries(main PUBLIC shLib)

install(TARGETS main shLib EXPORT exportTest)
install(EXPORT exportTest DESTINATION lib/exportTest)

(libA.cxx and objA.cxx are empty files. main.cxx just contains an empty main function: int main(int, char**) { return 0;})

Setup

  1. ROOT version: 6.26.06
  2. openSUSE Leap 15.4, SLE15SP4

Additional context

Metadata

Metadata

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions