-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[CMake][OCaml] Make OCaml bindings suitable for out-of-tree install #123478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
1644b1b
583a0e1
8ae9be9
3fcb90f
0e007ad
efb9b9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,12 +38,20 @@ function(add_ocaml_library name) | |
| set(ocaml_inputs) | ||
|
|
||
| set(ocaml_outputs "${bin}/${name}.cma") | ||
| # Always use -custom when building in-tree | ||
|
||
| if( (NOT LLVM_OCAML_OUT_OF_TREE) OR LLVM_OCAML_CUSTOM ) | ||
| set(ocaml_custom TRUE) | ||
| else() | ||
| set(ocaml_custom FALSE) | ||
| endif() | ||
|
|
||
| if( ARG_C ) | ||
| # ocamlmklib outputs .a and .so | ||
| list(APPEND ocaml_outputs | ||
| "${bin}/lib${name}${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
| if ( BUILD_SHARED_LIBS ) | ||
| "${bin}/lib${name}.a") | ||
| if ( NOT ocaml_custom ) | ||
| list(APPEND ocaml_outputs | ||
| "${bin}/dll${name}${CMAKE_SHARED_LIBRARY_SUFFIX}") | ||
| "${bin}/dll${name}.so") | ||
|
Comment on lines
+58
to
+61
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you change the suffixes? What about Windows when we have
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see past talk on this, I still don't like this solution, however. |
||
| endif() | ||
| endif() | ||
| if( HAVE_OCAMLOPT ) | ||
|
|
@@ -52,7 +60,12 @@ function(add_ocaml_library name) | |
| "${bin}/${name}${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||
| endif() | ||
|
|
||
| set(ocaml_flags "-lstdc++" "-ldopt" "-L${LLVM_LIBRARY_DIR}" | ||
| if ( LLVM_OCAML_OUT_OF_TREE ) | ||
| set(ocaml_llvm_libdir "-L${LLVM_OCAML_EXTERNAL_LLVM_LIBDIR}") | ||
| else() | ||
| set(ocaml_llvm_libdir "-L${LLVM_LIBRARY_DIR}") | ||
| endif() | ||
| set(ocaml_flags "-lstdc++" "${ocaml_llvm_libdir}" | ||
| "-ccopt" "-L\\$CAMLORIGIN/../.." | ||
| "-ccopt" "-Wl,-rpath,\\$CAMLORIGIN/../.." | ||
| ${ocaml_pkgs}) | ||
|
|
@@ -62,12 +75,12 @@ function(add_ocaml_library name) | |
| list(APPEND ocaml_flags ${dep_ocaml_flags}) | ||
| endforeach() | ||
|
|
||
| if( NOT BUILD_SHARED_LIBS ) | ||
| if( ocaml_custom ) | ||
| list(APPEND ocaml_flags "-custom") | ||
| endif() | ||
|
|
||
| if(LLVM_LINK_LLVM_DYLIB) | ||
| list(APPEND ocaml_flags "-lLLVM") | ||
| list(APPEND ocaml_flags "-lLLVM-${LLVM_VERSION_MAJOR}") | ||
| else() | ||
| explicit_map_components_to_libraries(llvm_libs ${ARG_LLVM}) | ||
| foreach( llvm_lib ${llvm_libs} ) | ||
|
|
@@ -201,9 +214,9 @@ function(add_ocaml_library name) | |
| if( NOT (ext STREQUAL ".cmo" OR | ||
| ext STREQUAL ".ml" OR | ||
| ext STREQUAL CMAKE_C_OUTPUT_EXTENSION OR | ||
| ext STREQUAL CMAKE_SHARED_LIBRARY_SUFFIX) ) | ||
| ext STREQUAL ".so") ) | ||
| list(APPEND install_files "${ocaml_output}") | ||
| elseif( ext STREQUAL CMAKE_SHARED_LIBRARY_SUFFIX) | ||
| elseif( ext STREQUAL ".so") | ||
| list(APPEND install_shlibs "${ocaml_output}") | ||
| endif() | ||
| endforeach() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't do this, instead with an
OCAML_BINDINGS_BUILD_STANDALONEwe would do afindPackage(LLVM ...). That in turn would setLLVM_LIBRARY_DIRto be the external dir, and we wouldn't need the conditions below.