Skip to content

Commit 45ab7d7

Browse files
committedMay 7, 2019
[compiler-rt] Create install targets for Darwin libraries
Darwin targets were generating CMake install rules but not the corresponding install targets. Centralize the existing install target creation to a function and use that function for both Darwin and non-Darwin builds. Differential Revision: https://reviews.llvm.org/D61541 llvm-svn: 360181
1 parent 6a281a7 commit 45ab7d7

File tree

3 files changed

+66
-44
lines changed

3 files changed

+66
-44
lines changed
 

‎compiler-rt/cmake/Modules/AddCompilerRT.cmake

+5-42
Original file line numberDiff line numberDiff line change
@@ -240,28 +240,6 @@ function(add_compiler_rt_runtime name type)
240240
set_target_properties(${LIB_PARENT_TARGET} PROPERTIES
241241
FOLDER "Compiler-RT Misc")
242242
endif()
243-
if(NOT TARGET install-${LIB_PARENT_TARGET})
244-
# The parent install target specifies the parent component to scrape up
245-
# anything not installed by the individual install targets, and to handle
246-
# installation when running the multi-configuration generators.
247-
add_custom_target(install-${LIB_PARENT_TARGET}
248-
DEPENDS ${LIB_PARENT_TARGET}
249-
COMMAND "${CMAKE_COMMAND}"
250-
-DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
251-
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
252-
add_custom_target(install-${LIB_PARENT_TARGET}-stripped
253-
DEPENDS ${LIB_PARENT_TARGET}
254-
COMMAND "${CMAKE_COMMAND}"
255-
-DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
256-
-DCMAKE_INSTALL_DO_STRIP=1
257-
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
258-
set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
259-
FOLDER "Compiler-RT Misc")
260-
set_target_properties(install-${LIB_PARENT_TARGET}-stripped PROPERTIES
261-
FOLDER "Compiler-RT Misc")
262-
add_dependencies(install-compiler-rt install-${LIB_PARENT_TARGET})
263-
add_dependencies(install-compiler-rt-stripped install-${LIB_PARENT_TARGET}-stripped)
264-
endif()
265243
endif()
266244

267245
foreach(libname ${libnames})
@@ -352,27 +330,12 @@ function(add_compiler_rt_runtime name type)
352330
endif()
353331
endif()
354332

355-
# We only want to generate per-library install targets if you aren't using
356-
# an IDE because the extra targets get cluttered in IDEs.
357-
if(NOT CMAKE_CONFIGURATION_TYPES)
358-
add_custom_target(install-${libname}
359-
DEPENDS ${libname}
360-
COMMAND "${CMAKE_COMMAND}"
361-
-DCMAKE_INSTALL_COMPONENT=${libname}
362-
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
363-
add_custom_target(install-${libname}-stripped
364-
DEPENDS ${libname}
365-
COMMAND "${CMAKE_COMMAND}"
366-
-DCMAKE_INSTALL_COMPONENT=${libname}
367-
-DCMAKE_INSTALL_DO_STRIP=1
368-
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
369-
# If you have a parent target specified, we bind the new install target
370-
# to the parent install target.
371-
if(LIB_PARENT_TARGET)
372-
add_dependencies(install-${LIB_PARENT_TARGET} install-${libname})
373-
add_dependencies(install-${LIB_PARENT_TARGET}-stripped install-${libname}-stripped)
374-
endif()
333+
set(parent_target_arg)
334+
if(LIB_PARENT_TARGET)
335+
set(parent_target_arg PARENT_TARGET ${LIB_PARENT_TARGET})
375336
endif()
337+
add_compiler_rt_install_targets(${libname} ${parent_target_arg})
338+
376339
if(APPLE)
377340
set_target_properties(${libname} PROPERTIES
378341
OSX_ARCHITECTURES "${LIB_ARCHS_${libname}}")

‎compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include(CMakeParseArguments)
2+
include(CompilerRTUtils)
23

34
# On OS X SDKs can be installed anywhere on the base system and xcode-select can
45
# set the default Xcode to use. This function finds the SDKs that are present in
@@ -249,10 +250,18 @@ function(darwin_lipo_libs name)
249250
)
250251
add_custom_target(${name}
251252
DEPENDS ${LIB_OUTPUT_DIR}/lib${name}.a)
253+
set_target_properties(${name} PROPERTIES FOLDER "Compiler-RT Misc")
252254
add_dependencies(${LIB_PARENT_TARGET} ${name})
255+
256+
if(CMAKE_CONFIGURATION_TYPES)
257+
set(install_component ${LIB_PARENT_TARGET})
258+
else()
259+
set(install_component ${name})
260+
endif()
253261
install(FILES ${LIB_OUTPUT_DIR}/lib${name}.a
254-
DESTINATION ${LIB_INSTALL_DIR})
255-
set_target_properties(${name} PROPERTIES FOLDER "Compiler-RT Misc")
262+
DESTINATION ${LIB_INSTALL_DIR}
263+
COMPONENT ${install_component})
264+
add_compiler_rt_install_targets(${name} PARENT_TARGET ${LIB_PARENT_TARGET})
256265
else()
257266
message(WARNING "Not generating lipo target for ${name} because no input libraries exist.")
258267
endif()

‎compiler-rt/cmake/Modules/CompilerRTUtils.cmake

+50
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,53 @@ function(compiler_rt_process_sources OUTPUT_VAR)
415415
endif()
416416
set("${OUTPUT_VAR}" ${sources} ${headers} PARENT_SCOPE)
417417
endfunction()
418+
419+
# Create install targets for a library and its parent component (if specified).
420+
function(add_compiler_rt_install_targets name)
421+
cmake_parse_arguments(ARG "" "PARENT_TARGET" "" ${ARGN})
422+
423+
if(ARG_PARENT_TARGET AND NOT TARGET install-${ARG_PARENT_TARGET})
424+
# The parent install target specifies the parent component to scrape up
425+
# anything not installed by the individual install targets, and to handle
426+
# installation when running the multi-configuration generators.
427+
add_custom_target(install-${ARG_PARENT_TARGET}
428+
DEPENDS ${ARG_PARENT_TARGET}
429+
COMMAND "${CMAKE_COMMAND}"
430+
-DCMAKE_INSTALL_COMPONENT=${ARG_PARENT_TARGET}
431+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
432+
add_custom_target(install-${ARG_PARENT_TARGET}-stripped
433+
DEPENDS ${ARG_PARENT_TARGET}
434+
COMMAND "${CMAKE_COMMAND}"
435+
-DCMAKE_INSTALL_COMPONENT=${ARG_PARENT_TARGET}
436+
-DCMAKE_INSTALL_DO_STRIP=1
437+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
438+
set_target_properties(install-${ARG_PARENT_TARGET} PROPERTIES
439+
FOLDER "Compiler-RT Misc")
440+
set_target_properties(install-${ARG_PARENT_TARGET}-stripped PROPERTIES
441+
FOLDER "Compiler-RT Misc")
442+
add_dependencies(install-compiler-rt install-${ARG_PARENT_TARGET})
443+
add_dependencies(install-compiler-rt-stripped install-${ARG_PARENT_TARGET}-stripped)
444+
endif()
445+
446+
# We only want to generate per-library install targets if you aren't using
447+
# an IDE because the extra targets get cluttered in IDEs.
448+
if(NOT CMAKE_CONFIGURATION_TYPES)
449+
add_custom_target(install-${name}
450+
DEPENDS ${name}
451+
COMMAND "${CMAKE_COMMAND}"
452+
-DCMAKE_INSTALL_COMPONENT=${name}
453+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
454+
add_custom_target(install-${name}-stripped
455+
DEPENDS ${name}
456+
COMMAND "${CMAKE_COMMAND}"
457+
-DCMAKE_INSTALL_COMPONENT=${name}
458+
-DCMAKE_INSTALL_DO_STRIP=1
459+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
460+
# If you have a parent target specified, we bind the new install target
461+
# to the parent install target.
462+
if(LIB_PARENT_TARGET)
463+
add_dependencies(install-${LIB_PARENT_TARGET} install-${name})
464+
add_dependencies(install-${LIB_PARENT_TARGET}-stripped install-${name}-stripped)
465+
endif()
466+
endif()
467+
endfunction()

0 commit comments

Comments
 (0)
Please sign in to comment.