Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -526,6 +526,9 @@ option (LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO "Show target and host info when tools are invoked with --version." ON) +option (LLVM_BUILD_BINDINGS + "Build bindings for Go and OCaml to LLVM." ON) + # You can configure which libraries from LLVM you want to include in the # shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited # list of LLVM components. All component names handled by llvm-config are valid. Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -568,25 +568,6 @@ message(STATUS "Doxygen disabled.") endif() -set(LLVM_BINDINGS "") -if(WIN32) - message(STATUS "Go bindings disabled.") -else() - find_program(GO_EXECUTABLE NAMES go DOC "go executable") - if(GO_EXECUTABLE STREQUAL "GO_EXECUTABLE-NOTFOUND") - message(STATUS "Go bindings disabled.") - else() - execute_process(COMMAND ${GO_EXECUTABLE} run ${PROJECT_SOURCE_DIR}/bindings/go/conftest.go - RESULT_VARIABLE GO_CONFTEST) - if(GO_CONFTEST STREQUAL "0") - set(LLVM_BINDINGS "${LLVM_BINDINGS} go") - message(STATUS "Go bindings enabled.") - else() - message(STATUS "Go bindings disabled, need at least Go 1.2.") - endif() - endif() -endif() - find_program(GOLD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.gold ld.gold ${LLVM_DEFAULT_TARGET_TRIPLE}-ld ld DOC "The gold linker") set(LLVM_BINUTILS_INCDIR "" CACHE PATH "PATH to binutils/include containing plugin-api.h for gold plugin.") @@ -609,35 +590,58 @@ endif() endif() -# Keep the version requirements in sync with bindings/ocaml/README.txt. -include(FindOCaml) -include(AddOCaml) -if(WIN32) - message(STATUS "OCaml bindings disabled.") -else() - find_package(OCaml) - if( NOT OCAML_FOUND ) +if (LLVM_BUILD_BINDINGS) + set(LLVM_BINDINGS "") + if(WIN32) + message(STATUS "Go bindings disabled.") + else() + find_program(GO_EXECUTABLE NAMES go DOC "go executable") + if(GO_EXECUTABLE STREQUAL "GO_EXECUTABLE-NOTFOUND") + message(STATUS "Go bindings disabled.") + else() + execute_process(COMMAND ${GO_EXECUTABLE} run ${PROJECT_SOURCE_DIR}/bindings/go/conftest.go + RESULT_VARIABLE GO_CONFTEST) + if(GO_CONFTEST STREQUAL "0") + set(LLVM_BINDINGS "${LLVM_BINDINGS} go") + message(STATUS "Go bindings enabled.") + else() + message(STATUS "Go bindings disabled, need at least Go 1.2.") + endif() + endif() + endif() + + # Keep the version requirements in sync with bindings/ocaml/README.txt. + include(FindOCaml) + include(AddOCaml) + if(WIN32) message(STATUS "OCaml bindings disabled.") else() - if( OCAML_VERSION VERSION_LESS "4.00.0" ) - message(STATUS "OCaml bindings disabled, need OCaml >=4.00.0.") + find_package(OCaml) + if( NOT OCAML_FOUND ) + message(STATUS "OCaml bindings disabled.") else() - find_ocamlfind_package(ctypes VERSION 0.4 OPTIONAL) - if( HAVE_OCAML_CTYPES ) - message(STATUS "OCaml bindings enabled.") - find_ocamlfind_package(oUnit VERSION 2 OPTIONAL) - set(LLVM_BINDINGS "${LLVM_BINDINGS} ocaml") - - set(LLVM_OCAML_INSTALL_PATH "${OCAML_STDLIB_PATH}" CACHE STRING - "Install directory for LLVM OCaml packages") + if( OCAML_VERSION VERSION_LESS "4.00.0" ) + message(STATUS "OCaml bindings disabled, need OCaml >=4.00.0.") else() - message(STATUS "OCaml bindings disabled, need ctypes >=0.4.") + find_ocamlfind_package(ctypes VERSION 0.4 OPTIONAL) + if( HAVE_OCAML_CTYPES ) + message(STATUS "OCaml bindings enabled.") + find_ocamlfind_package(oUnit VERSION 2 OPTIONAL) + set(LLVM_BINDINGS "${LLVM_BINDINGS} ocaml") + + set(LLVM_OCAML_INSTALL_PATH "${OCAML_STDLIB_PATH}" CACHE STRING + "Install directory for LLVM OCaml packages") + else() + message(STATUS "OCaml bindings disabled, need ctypes >=0.4.") + endif() endif() endif() endif() -endif() -string(REPLACE " " ";" LLVM_BINDINGS_LIST "${LLVM_BINDINGS}") + string(REPLACE " " ";" LLVM_BINDINGS_LIST "${LLVM_BINDINGS}") +else() + message(STATUS "Bindings disabled.") +endif() function(find_python_module module) string(REPLACE "." "_" module_name ${module}) Index: docs/CMake.rst =================================================================== --- docs/CMake.rst +++ docs/CMake.rst @@ -505,6 +505,10 @@ either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to `share/doc/llvm/ocaml-html`. +**LLVM_BUILD_BINDINGS**:BOOL + If enabled, the targets for building the Go and OCaml bindings are added. + Either binding may not build if dependencies are not found. Defaults to ON. + **LLVM_CREATE_XCODE_TOOLCHAIN**:BOOL OS X Only: If enabled CMake will generate a target named 'install-xcode-toolchain'. This target will create a directory at