Skip to content

Commit 467b23a

Browse files
authored
Merge pull request #37577 from gottesmm/pr-1105250c37357c900a8232c2106cbb9fd68896f8
[cmake] Some more small changes to enable host side tools that use swift using standard cmake.
2 parents 47ed173 + 53a7cca commit 467b23a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ endfunction()
389389
# add_swift_host_library(name
390390
# [SHARED]
391391
# [STATIC]
392+
# [OBJECT]
393+
# [IGNORE_LLVM_UPDATE_COMPILE_FLAGS]
392394
# [LLVM_LINK_COMPONENTS comp1 ...]
393395
# source1 [source2 source3 ...])
394396
#
@@ -401,15 +403,25 @@ endfunction()
401403
# STATIC
402404
# Build a static library.
403405
#
406+
# OBJECT
407+
# Build an object library
408+
#
404409
# LLVM_LINK_COMPONENTS
405410
# LLVM components this library depends on.
406411
#
412+
# IGNORE_LLVM_UPDATE_COMPILE_FLAGS
413+
# If set do not use llvm_update_compile_flags to generate cflags/etc. This is
414+
# generally used when compiling a mixed c/c++/swift library and one wants to
415+
# disable this for the swift part.
416+
#
407417
# source1 ...
408418
# Sources to add into this library.
409419
function(add_swift_host_library name)
410420
set(options
411421
SHARED
412-
STATIC)
422+
STATIC
423+
OBJECT
424+
IGNORE_LLVM_UPDATE_COMPILE_FLAGS)
413425
set(single_parameter_options)
414426
set(multiple_parameter_options
415427
LLVM_LINK_COMPONENTS)
@@ -423,8 +435,8 @@ function(add_swift_host_library name)
423435
424436
translate_flags(ASHL "${options}")
425437
426-
if(NOT ASHL_SHARED AND NOT ASHL_STATIC)
427-
message(FATAL_ERROR "Either SHARED or STATIC must be specified")
438+
if(NOT ASHL_SHARED AND NOT ASHL_STATIC AND NOT ASHL_OBJECT)
439+
message(FATAL_ERROR "One of SHARED/STATIC/OBJECT must be specified")
428440
endif()
429441
430442
if(XCODE)
@@ -449,11 +461,15 @@ function(add_swift_host_library name)
449461
set(libkind SHARED)
450462
elseif(ASHL_STATIC)
451463
set(libkind STATIC)
464+
elseif(ASHL_OBJECT)
465+
set(libkind OBJECT)
452466
endif()
453467
454468
add_library(${name} ${libkind} ${ASHL_SOURCES})
455469
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
456-
llvm_update_compile_flags(${name})
470+
if (NOT ASHL_IGNORE_LLVM_UPDATE_COMPILE_FLAGS)
471+
llvm_update_compile_flags(${name})
472+
endif()
457473
swift_common_llvm_config(${name} ${ASHL_LLVM_LINK_COMPONENTS})
458474
set_output_directory(${name}
459475
BINARY_DIR ${SWIFT_RUNTIME_OUTPUT_INTDIR}

0 commit comments

Comments
 (0)