Skip to content

Commit e11c334

Browse files
Convert all usages of target_link_libraries to use PUBLIC/PRIVATE specifiers (#81924)
Co-authored-by: Aleksey Kliger (λgeek) <[email protected]>
1 parent 4dd649b commit e11c334

File tree

121 files changed

+347
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+347
-318
lines changed

src/coreclr/debug/createdump/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if(CLR_CMAKE_HOST_WIN32)
2424
)
2525

2626
target_link_libraries(createdump
27+
PRIVATE
2728
kernel32.lib
2829
${STATIC_MT_CRT_LIB}
2930
advapi32.lib
@@ -83,6 +84,7 @@ else()
8384
endif(CLR_CMAKE_HOST_OSX)
8485

8586
target_link_libraries(createdump
87+
PRIVATE
8688
corguids
8789
dbgutil
8890
# share the PAL in the dac module

src/coreclr/dlls/mscordbi/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ if(CLR_CMAKE_HOST_WIN32)
9090
${STATIC_MT_VCRT_LIB}
9191
)
9292

93-
target_link_libraries(mscordbi ${COREDBI_LIBRARIES})
93+
target_link_libraries(mscordbi PRIVATE ${COREDBI_LIBRARIES})
9494

9595
elseif(CLR_CMAKE_HOST_UNIX)
9696

@@ -114,7 +114,7 @@ elseif(CLR_CMAKE_HOST_UNIX)
114114
# COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols
115115
# if they are defined after they are used. Having all libs twice makes sure that ld will actually
116116
# find all symbols.
117-
target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})
117+
target_link_libraries(mscordbi PRIVATE ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES})
118118

119119
add_dependencies(mscordbi mscordaccore)
120120

src/coreclr/gc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ convert_to_absolute_path(GC_SOURCES ${GC_SOURCES})
106106

107107
add_library_clr(clrgc SHARED ${GC_SOURCES})
108108
add_dependencies(clrgc eventing_headers)
109-
target_link_libraries(clrgc ${GC_LINK_LIBRARIES})
109+
target_link_libraries(clrgc PRIVATE ${GC_LINK_LIBRARIES})
110110
install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime)
111111

112112
add_definitions(-DBUILD_AS_STANDALONE)

src/coreclr/gc/sample/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ add_executable_clr(gcsample
6363
)
6464

6565
if(CLR_CMAKE_TARGET_WIN32)
66-
target_link_libraries(gcsample ${GC_LINK_LIBRARIES})
66+
target_link_libraries(gcsample PRIVATE ${GC_LINK_LIBRARIES})
6767
endif()

src/coreclr/hosts/corerun/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ add_executable_clr(corerun
1919

2020
if(CLR_CMAKE_HOST_WIN32)
2121
target_link_libraries(corerun
22+
PRIVATE
2223
advapi32.lib
2324
oleaut32.lib
2425
uuid.lib
@@ -27,13 +28,13 @@ if(CLR_CMAKE_HOST_WIN32)
2728
${STATIC_MT_VCRT_LIB}
2829
)
2930
else(CLR_CMAKE_HOST_WIN32)
30-
target_link_libraries(corerun ${CMAKE_DL_LIBS})
31+
target_link_libraries(corerun PRIVATE ${CMAKE_DL_LIBS})
3132
# Required to expose symbols for global symbol discovery
32-
target_link_libraries(corerun -rdynamic)
33+
target_link_libraries(corerun PRIVATE -rdynamic)
3334

3435
# Android implements pthread natively
3536
if(NOT CLR_CMAKE_TARGET_ANDROID)
36-
target_link_libraries(corerun pthread)
37+
target_link_libraries(corerun PRIVATE pthread)
3738
endif()
3839
endif(CLR_CMAKE_HOST_WIN32)
3940

src/coreclr/hosts/coreshim/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_library_clr(CoreShim
1313
)
1414

1515
target_link_libraries(CoreShim
16+
PRIVATE
1617
utilcodestaticnohost
1718
advapi32.lib
1819
oleaut32.lib

src/coreclr/ilasm/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ endif(CLR_CMAKE_TARGET_WIN32)
109109

110110
if(CLR_CMAKE_HOST_UNIX)
111111
target_link_libraries(ilasm
112+
PRIVATE
112113
${ILASM_LINK_LIBRARIES}
113114
utilcodestaticnohost
114115
mscorrc
@@ -118,6 +119,7 @@ if(CLR_CMAKE_HOST_UNIX)
118119
)
119120
else()
120121
target_link_libraries(ilasm
122+
PRIVATE
121123
${ILASM_LINK_LIBRARIES}
122124
ole32
123125
oleaut32

src/coreclr/ildasm/exe/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ endif(CLR_CMAKE_HOST_WIN32)
9999

100100
if(CLR_CMAKE_HOST_UNIX)
101101
target_link_libraries(ildasm
102+
PRIVATE
102103
${ILDASM_LINK_LIBRARIES}
103104
mscorrc
104105
coreclrpal
@@ -107,6 +108,7 @@ if(CLR_CMAKE_HOST_UNIX)
107108
)
108109
else()
109110
target_link_libraries(ildasm
111+
PRIVATE
110112
${ILDASM_LINK_LIBRARIES}
111113
ole32
112114
oleaut32

src/coreclr/jit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ function(add_jit jitName)
565565
set_property(TARGET ${jitName} APPEND_STRING PROPERTY LINK_DEPENDS ${JIT_EXPORTS_FILE})
566566

567567
target_link_libraries(${jitName}
568+
PRIVATE
568569
${JIT_LINK_LIBRARIES}
569570
${JIT_ARCH_LINK_LIBRARIES}
570571
)

src/coreclr/pal/src/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ if(CLR_CMAKE_TARGET_OSX)
273273
find_library(SECURITY Security)
274274
find_library(SYSTEM System)
275275
target_link_libraries(coreclrpal
276+
PUBLIC
276277
${COREFOUNDATION}
277278
${CORESERVICES}
278279
${SECURITY}
@@ -282,6 +283,7 @@ endif(CLR_CMAKE_TARGET_OSX)
282283

283284
if(CLR_CMAKE_TARGET_FREEBSD)
284285
target_link_libraries(coreclrpal
286+
PUBLIC
285287
pthread
286288
rt
287289
${UNWIND_LIBS}
@@ -292,27 +294,30 @@ if(CLR_CMAKE_TARGET_LINUX)
292294
# On Android, we don't need to link with gcc_s, pthread and rt
293295
if(NOT CLR_CMAKE_TARGET_ANDROID)
294296
target_link_libraries(coreclrpal
297+
PUBLIC
295298
gcc_s
296299
pthread
297300
rt
298301
)
299302
else(NOT CLR_CMAKE_TARGET_ANDROID)
300303
target_link_libraries(coreclrpal
304+
PUBLIC
301305
${ANDROID_GLOB}
302306
${LZMA})
303307
endif(NOT CLR_CMAKE_TARGET_ANDROID)
304308

305309
target_link_libraries(coreclrpal
310+
PUBLIC
306311
dl
307312
)
308313

309314
if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
310-
target_link_libraries(coreclrpal ${UNWIND_LIBS})
315+
target_link_libraries(coreclrpal PUBLIC ${UNWIND_LIBS})
311316
endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
312317

313318
# bundled libunwind requires using libucontext on alpine and x86 and ppc64le
314319
if(CLR_CMAKE_TARGET_ALPINE_LINUX AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_POWERPC64))
315-
target_link_libraries(coreclrpal ucontext)
320+
target_link_libraries(coreclrpal PUBLIC ucontext)
316321
endif(CLR_CMAKE_TARGET_ALPINE_LINUX AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_POWERPC64))
317322

318323
endif(CLR_CMAKE_TARGET_LINUX)
@@ -324,6 +329,7 @@ if(CLR_CMAKE_TARGET_NETBSD)
324329
add_definitions(-D_KMEMUSER)
325330
find_library(KVM kvm)
326331
target_link_libraries(coreclrpal
332+
PUBLIC
327333
pthread
328334
rt
329335
${UNWIND}
@@ -333,6 +339,7 @@ endif(CLR_CMAKE_TARGET_NETBSD)
333339

334340
if(CLR_CMAKE_TARGET_SUNOS)
335341
target_link_libraries(coreclrpal
342+
PUBLIC
336343
pthread
337344
rt
338345
)

0 commit comments

Comments
 (0)