diff --git a/flang/cmake/modules/AddFlang.cmake b/flang/cmake/modules/AddFlang.cmake index aeb4d862cf780..9ed1a3050b7e8 100644 --- a/flang/cmake/modules/AddFlang.cmake +++ b/flang/cmake/modules/AddFlang.cmake @@ -55,23 +55,13 @@ function(add_flang_library name) set(LIBTYPE SHARED STATIC) elseif(ARG_SHARED) set(LIBTYPE SHARED) + elseif(ARG_STATIC) + # If BUILD_SHARED_LIBS and ARG_STATIC are both set, llvm_add_library prioritizes STATIC. + # This is required behavior for libFortranFloat128Math. + set(LIBTYPE STATIC) else() - # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set, - # so we need to handle it here. - if(BUILD_SHARED_LIBS) - set(LIBTYPE SHARED) - else() - set(LIBTYPE STATIC) - endif() - if(NOT XCODE AND NOT MSVC_IDE) - # The Xcode generator doesn't handle object libraries correctly. - # The Visual Studio CMake generator does handle object libraries - # correctly, but it is preferable to list the libraries with their - # source files (instead of the object files and the source files in - # a separate target in the "Object Libraries" folder) - list(APPEND LIBTYPE OBJECT) - endif() - set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name}) + # Let llvm_add_library decide, taking BUILD_SHARED_LIBS into account. + set(LIBTYPE) endif() llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})