From ab916900b90299735cf58eb3f0f7b6e79de7e837 Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Fri, 11 Oct 2019 14:32:43 +0000 Subject: [PATCH] [llvm] [ocaml] Support linking against dylib Support linking OCaml modules against LLVM dylib when requested, rather than against static libs that might not be installed at all. Differential Revision: https://reviews.llvm.org/D68452 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374556 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/AddOCaml.cmake | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/cmake/modules/AddOCaml.cmake b/cmake/modules/AddOCaml.cmake index 02bab684637..554046b20ed 100644 --- a/cmake/modules/AddOCaml.cmake +++ b/cmake/modules/AddOCaml.cmake @@ -66,21 +66,25 @@ function(add_ocaml_library name) list(APPEND ocaml_flags "-custom") endif() - explicit_map_components_to_libraries(llvm_libs ${ARG_LLVM}) - foreach( llvm_lib ${llvm_libs} ) - list(APPEND ocaml_flags "-l${llvm_lib}" ) - endforeach() + if(LLVM_LINK_LLVM_DYLIB) + list(APPEND ocaml_flags "-lLLVM") + else() + explicit_map_components_to_libraries(llvm_libs ${ARG_LLVM}) + foreach( llvm_lib ${llvm_libs} ) + list(APPEND ocaml_flags "-l${llvm_lib}" ) + endforeach() - get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS) - foreach(system_lib ${system_libs}) - if (system_lib MATCHES "^-") - # If it's an option, pass it without changes. - list(APPEND ocaml_flags "${system_lib}" ) - else() - # Otherwise assume it's a library name we need to link with. - list(APPEND ocaml_flags "-l${system_lib}" ) - endif() - endforeach() + get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS) + foreach(system_lib ${system_libs}) + if (system_lib MATCHES "^-") + # If it's an option, pass it without changes. + list(APPEND ocaml_flags "${system_lib}" ) + else() + # Otherwise assume it's a library name we need to link with. + list(APPEND ocaml_flags "-l${system_lib}" ) + endif() + endforeach() + endif() string(REPLACE ";" " " ARG_CFLAGS "${ARG_CFLAGS}") set(c_flags "${ARG_CFLAGS} ${LLVM_DEFINITIONS}") -- 2.40.0