[OCaml] PR22014: OCaml bindings didn't link to libLLVM-*.so with -Wl,--as-needed
[oota-llvm.git] / cmake / config-ix.cmake
index b124d9411faf54bb3c4e02e4468250dfe17067ce..f806d9c54ed93506498281e7c5f1463881879f3d 100755 (executable)
@@ -84,6 +84,7 @@ check_include_file(mach-o/dyld.h HAVE_MACH_O_DYLD_H)
 check_cxx_source_compiles("
 #include <stddef.h>
 #include <cxxabi.h>
+int main() { return 0; }
 " HAVE_CXXABI_H)
 
 # library checks
@@ -515,3 +516,29 @@ else()
     endif()
   endif()
 endif()
+
+include(FindOCaml)
+include(AddOCaml)
+if(WIN32)
+  message(STATUS "OCaml bindings disabled.")
+else()
+  find_package(OCaml)
+  if( NOT OCAML_FOUND )
+    message(STATUS "OCaml bindings disabled.")
+  else()
+    if( OCAML_VERSION VERSION_LESS "4.00.0" )
+      message(STATUS "OCaml bindings disabled, need OCaml >=4.00.0.")
+    else()
+      find_ocamlfind_package(ctypes VERSION 0.3 OPTIONAL)
+      if( HAVE_OCAML_CTYPES )
+        message(STATUS "OCaml bindings enabled.")
+        find_ocamlfind_package(oUnit VERSION 2 OPTIONAL)
+        set(LLVM_BINDINGS "${LLVM_BINDINGS} ocaml")
+      else()
+        message(STATUS "OCaml bindings disabled, need ctypes >=0.3.")
+      endif()
+    endif()
+  endif()
+endif()
+
+string(REPLACE " " ";" LLVM_BINDINGS_LIST "${LLVM_BINDINGS}")