Skip to content

Commit f13ccf8

Browse files
CMake: link object libraries as targets
Signed-off-by: Stephan Lachnit <[email protected]>
1 parent d8ac9df commit f13ccf8

File tree

5 files changed

+13
-9
lines changed

5 files changed

+13
-9
lines changed

core/clib/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ target_include_directories(Clib
4444
# alternative for strlcpy on linux, see https://github.com/root-project/root/issues/12152
4545
if(libbsd)
4646
target_link_libraries(Clib PUBLIC LIBBSD::libbsd)
47+
target_link_libraries(Core PUBLIC LIBBSD::libbsd)
4748
endif()
4849

4950
target_include_directories(Core
5051
PUBLIC
5152
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
5253
)
5354

54-
target_sources(Core PRIVATE $<TARGET_OBJECTS:Clib>)
55+
# link object libraries
56+
target_link_libraries(Core PRIVATE Clib)
5557

5658
ROOT_INSTALL_HEADERS()

core/dictgen/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ target_include_directories(Dictgen PRIVATE
4848
${CLING_INCLUDE_DIRS}
4949
)
5050

51+
# link object libraries
52+
target_link_libraries(Dictgen PRIVATE Clib)
53+
5154
# Register the llvm include directories after clangs. This instructs the compiler to resolve
5255
# headers from our builtin clang. That's an issue when we are building with bultin_llvm=Off
5356
# and we have installed clang headers, too.

core/metacling/src/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ if (clad)
106106
endif()
107107

108108
ROOT_LINKER_LIBRARY(Cling
109-
$<TARGET_OBJECTS:ClingUtils>
110-
$<TARGET_OBJECTS:Dictgen>
111-
$<TARGET_OBJECTS:MetaCling>
112109
LIBRARIES ${CLING_LIBRARIES} ${LINK_LIBS} ${CLING_PLUGIN_LINK_LIBS})
113110

111+
# link object libraries
112+
target_link_libraries(Cling PRIVATE ClingUtils Dictgen MetaCling)
113+
114114
string(TOUPPER "${LLVM_BUILD_TYPE}" THE_BUILD_TYPE)
115115
if("${THE_BUILD_TYPE}" STREQUAL DEBUG OR "${THE_BUILD_TYPE}" STREQUAL RELWITHDEBINFO)
116116
# When these two link at the same time, they can exhaust the RAM on many machines, since they both link against llvm.

core/rootcling_stage1/CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ if(NOT builtin_clang)
2323
endif()
2424

2525
ROOT_EXECUTABLE(rootcling_stage1 src/rootcling_stage1.cxx
26-
$<TARGET_OBJECTS:Clib>
27-
$<TARGET_OBJECTS:ClingUtils>
28-
$<TARGET_OBJECTS:Dictgen>
29-
$<TARGET_OBJECTS:Foundation_Stage1>
3026
LIBRARIES ${CLING_LIBRARIES} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} ${ROOT_ATOMIC_LIBS}
3127
NOINSTALL)
3228

29+
# link object libraries
30+
target_link_libraries(rootcling_stage1 Clib ClingUtils Dictgen Foundation_Stage1)
31+
3332
target_include_directories(rootcling_stage1 PRIVATE
3433
${CMAKE_SOURCE_DIR}/core/foundation/inc # for RConfig.hxx
3534
${CMAKE_SOURCE_DIR}/core/dictgen/res # for rootcling_impl.h

rootx/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if(x11)
1313
ROOT_EXECUTABLE(root
1414
src/rootx.cxx
1515
src/rootxx.cxx
16-
../core/clib/src/strlcpy.c
1716
)
1817
target_include_directories(root
1918
PRIVATE
@@ -24,6 +23,7 @@ if(x11)
2423
${X11_Xft_LIB}
2524
${X11_Xpm_LIB}
2625
${X11_LIBRARIES}
26+
Clib # for strlcpy/strlcat
2727
)
2828

2929
if (CMAKE_SYSTEM_NAME MATCHES FreeBSD)

0 commit comments

Comments
 (0)