1set(FORCE_ALL_COMPONENTS OFF CACHE BOOL "Fails cmake if not all dependencies are found")
2
3################################################################################
4# LibreSSL
5################################################################################
6
7set(DISABLE_TLS OFF CACHE BOOL "Don't try to find LibreSSL and always build without TLS support")
8if(DISABLE_TLS)
9  set(WITH_TLS OFF)
10else()
11  set(LIBRESSL_USE_STATIC_LIBS TRUE)
12  find_package(LibreSSL)
13  if(LibreSSL_FOUND)
14    set(WITH_TLS ON)
15    add_compile_options(-DHAVE_OPENSSL)
16  else()
17    message(STATUS "LibreSSL NOT Found - Will compile without TLS Support")
18    message(STATUS "You can set LibreSSL_ROOT to the LibreSSL install directory to help cmake find it")
19    set(WITH_TLS OFF)
20  endif()
21endif()
22
23################################################################################
24# Java Bindings
25################################################################################
26
27set(WITH_JAVA OFF)
28find_package(JNI 1.8 REQUIRED)
29find_package(Java 1.8 COMPONENTS Development)
30if(JNI_FOUND AND Java_FOUND AND Java_Development_FOUND)
31  set(WITH_JAVA ON)
32  include(UseJava)
33  enable_language(Java)
34else()
35  set(WITH_JAVA OFF)
36endif()
37
38################################################################################
39# Python Bindings
40################################################################################
41
42find_package(Python COMPONENTS Interpreter)
43if(Python_Interpreter_FOUND)
44  set(WITH_PYTHON ON)
45else()
46  message(FATAL_ERROR "Could not found a suitable python interpreter")
47  set(WITH_PYTHON OFF)
48endif()
49
50################################################################################
51# Pip
52################################################################################
53
54find_package(Virtualenv)
55if (Virtualenv_FOUND)
56  set(WITH_DOCUMENTATION ON)
57else()
58  set(WITH_DOCUMENTATION OFF)
59endif()
60
61################################################################################
62# GO
63################################################################################
64
65find_program(GO_EXECUTABLE go)
66# building the go binaries is currently not supported on Windows
67if(GO_EXECUTABLE AND NOT WIN32)
68  set(WITH_GO ON)
69else()
70  set(WITH_GO OFF)
71endif()
72
73################################################################################
74# Ruby
75################################################################################
76
77find_program(GEM_EXECUTABLE gem)
78set(WITH_RUBY OFF)
79if(GEM_EXECUTABLE)
80  set(GEM_COMMAND ${RUBY_EXECUTABLE} ${GEM_EXECUTABLE})
81  set(WITH_RUBY ON)
82endif()
83
84file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages)
85add_custom_target(packages)
86
87function(print_components)
88  message(STATUS "=========================================")
89  message(STATUS "   Components Build Overview ")
90  message(STATUS "=========================================")
91  message(STATUS "Build Java Bindings:                  ${WITH_JAVA}")
92  message(STATUS "Build with TLS support:               ${WITH_TLS}")
93  message(STATUS "Build Go bindings:                    ${WITH_GO}")
94  message(STATUS "Build Ruby bindings:                  ${WITH_RUBY}")
95  message(STATUS "Build Python sdist (make package):    ${WITH_PYTHON}")
96  message(STATUS "Build Documentation (make html):      ${WITH_DOCUMENTATION}")
97  message(STATUS "=========================================")
98endfunction()
99
100if(FORCE_ALL_COMPONENTS)
101  if(NOT WITH_JAVA OR NOT WITH_TLS OR NOT WITH_GO OR NOT WITH_RUBY OR NOT WITH_PYTHON OR NOT WITH_DOCUMENTATION)
102    print_components()
103    message(FATAL_ERROR "FORCE_ALL_COMPONENTS is set but not all dependencies could be found")
104  endif()
105endif()
106