Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 1 | # |
| 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
| 19 | |
| 20 | |
| 21 | include(CMakeDependentOption) |
| 22 | |
| 23 | # Additional components |
| 24 | option(BUILD_COMPILER "Build Thrift compiler" ON) |
| 25 | option(BUILD_TESTING "Build with unit tests" ON) |
| 26 | option(BUILD_EXAMPLES "Build examples" ON) |
ben-craig | 1f64ea9 | 2015-07-15 08:11:57 -0500 | [diff] [blame] | 27 | option(BUILD_TUTORIALS "Build Thrift tutorials" ON) |
Marco Molteni | 7f47792 | 2015-04-15 20:46:48 +0200 | [diff] [blame] | 28 | option(BUILD_LIBRARIES "Build Thrift libraries" ON) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 29 | |
| 30 | # Libraries to build |
| 31 | |
| 32 | # Each language library can be enabled or disabled using the WITH_<LANG> flag. |
| 33 | # By default CMake checks if the required dependencies for a language are present |
| 34 | # and enables the library if all are found. This means the default is to build as |
| 35 | # much as possible but leaving out libraries if their dependencies are not met. |
| 36 | |
| 37 | # C++ |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 38 | option(WITH_CPP "Build C++ Thrift library" ON) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 39 | find_package(Boost 1.53 QUIET) |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 40 | CMAKE_DEPENDENT_OPTION(BUILD_CPP "Build C++ library" ON |
| 41 | "BUILD_LIBRARIES;WITH_CPP;Boost_FOUND" OFF) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 42 | # NOTE: Currently the following options are C++ specific, |
| 43 | # but in future other libraries might reuse them. |
Marco Molteni | 8349425 | 2015-04-16 13:50:20 +0200 | [diff] [blame] | 44 | # So they are not dependent on WITH_CPP but setting them without WITH_CPP currently |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 45 | # has no effect. |
| 46 | find_package(ZLIB QUIET) |
| 47 | CMAKE_DEPENDENT_OPTION(WITH_ZLIB "Build with ZLIB support" ON |
| 48 | "ZLIB_FOUND" OFF) |
| 49 | find_package(Libevent QUIET) |
| 50 | CMAKE_DEPENDENT_OPTION(WITH_LIBEVENT "Build with libevent support" ON |
| 51 | "Libevent_FOUND" OFF) |
Nobuaki Sukegawa | 6304a53 | 2014-12-18 01:30:58 +0900 | [diff] [blame] | 52 | find_package(Qt4 QUIET COMPONENTS QtCore QtNetwork) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 53 | CMAKE_DEPENDENT_OPTION(WITH_QT4 "Build with Qt4 support" ON |
| 54 | "QT4_FOUND" OFF) |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 55 | find_package(Qt5 QUIET COMPONENTS Core Network) |
| 56 | CMAKE_DEPENDENT_OPTION(WITH_QT5 "Build with Qt5 support" ON |
| 57 | "Qt5_FOUND" OFF) |
| 58 | if(${WITH_QT4} AND ${WITH_QT5} AND ${CMAKE_MAJOR_VERSION} LESS 3) |
| 59 | # cmake < 3.0.0 causes conflict when building both Qt4 and Qt5 |
| 60 | set(WITH_QT4 OFF) |
| 61 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 62 | find_package(OpenSSL QUIET) |
| 63 | CMAKE_DEPENDENT_OPTION(WITH_OPENSSL "Build with OpenSSL support" ON |
Nobuaki Sukegawa | c444fb5 | 2015-01-02 23:16:55 +0900 | [diff] [blame] | 64 | "OPENSSL_FOUND" OFF) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 65 | option(WITH_STDTHREADS "Build with C++ std::thread support" OFF) |
Sergei Nikulov | 34e0bb6 | 2015-09-02 13:06:22 +0300 | [diff] [blame] | 66 | CMAKE_DEPENDENT_OPTION(WITH_BOOSTTHREADS "Build with Boost threads support" OFF |
| 67 | "NOT WITH_STDTHREADS;Boost_FOUND" OFF) |
| 68 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 69 | |
| 70 | # C GLib |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 71 | option(WITH_C_GLIB "Build C (GLib) Thrift library" ON) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 72 | find_package(GLIB QUIET COMPONENTS gobject) |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 73 | CMAKE_DEPENDENT_OPTION(BUILD_C_GLIB "Build C (GLib) library" ON |
| 74 | "BUILD_LIBRARIES;WITH_C_GLIB;GLIB_FOUND" OFF) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 75 | # Java |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 76 | option(WITH_JAVA "Build Java Thrift library" ON) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 77 | find_package(Java QUIET) |
Sergei Nikulov | 9d8c1bf | 2015-01-30 13:29:33 +0300 | [diff] [blame] | 78 | find_package(Ant QUIET) |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 79 | CMAKE_DEPENDENT_OPTION(BUILD_JAVA "Build Java library" ON |
| 80 | "BUILD_LIBRARIES;WITH_JAVA;JAVA_FOUND;ANT_FOUND" OFF) |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 81 | |
| 82 | # Python |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 83 | option(WITH_PYTHON "Build Python Thrift library" ON) |
| 84 | find_package(PythonInterp QUIET) # for Python executable |
| 85 | find_package(PythonLibs QUIET) # for Python.h |
| 86 | CMAKE_DEPENDENT_OPTION(BUILD_PYTHON "Build Python library" ON |
| 87 | "BUILD_LIBRARIES;WITH_PYTHON;PYTHONLIBS_FOUND" OFF) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 88 | |
Nobuaki Sukegawa | 27378fa | 2015-10-29 00:41:39 +0900 | [diff] [blame^] | 89 | # Haskell |
| 90 | option(WITH_HASKELL "Build Haskell Thrift library" ON) |
| 91 | find_package(GHC QUIET) |
| 92 | find_package(Cabal QUIET) |
| 93 | CMAKE_DEPENDENT_OPTION(BUILD_HASKELL "Build GHC library" ON |
| 94 | "BUILD_LIBRARIES;WITH_HASKELL;GHC_FOUND;CABAL_FOUND" OFF) |
| 95 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 96 | # Common library options |
| 97 | option(WITH_SHARED_LIB "Build shared libraries" ON) |
| 98 | option(WITH_STATIC_LIB "Build static libraries" ON) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 99 | if (NOT WITH_SHARED_LIB AND NOT WITH_STATIC_LIB) |
| 100 | message(FATAL_ERROR "Cannot build with both shared and static outputs disabled!") |
| 101 | endif() |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 102 | |
| 103 | #NOTE: C++ compiler options are defined in the lib/cpp/CMakeLists.txt |
| 104 | |
| 105 | # Visual Studio only options |
| 106 | if(MSVC) |
Jim King | 9de9b1f | 2015-04-30 16:03:34 -0400 | [diff] [blame] | 107 | option(WITH_MT "Build using MT instead of MD (MSVC only)" OFF) |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 108 | endif(MSVC) |
| 109 | |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 110 | macro(MESSAGE_DEP flag summary) |
| 111 | if(NOT ${flag}) |
| 112 | message(STATUS " - ${summary}") |
| 113 | endif() |
| 114 | endmacro(MESSAGE_DEP flag summary) |
| 115 | |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 116 | macro(PRINT_CONFIG_SUMMARY) |
| 117 | message(STATUS "----------------------------------------------------------") |
| 118 | message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})") |
| 119 | message(STATUS "Thrift package version: ${PACKAGE_VERSION}") |
| 120 | message(STATUS "Build configuration Summary") |
| 121 | message(STATUS " Build Thrift compiler: ${BUILD_COMPILER}") |
| 122 | message(STATUS " Build with unit tests: ${BUILD_TESTING}") |
| 123 | message(STATUS " Build examples: ${BUILD_EXAMPLES}") |
Roger Meier | 2659381 | 2015-04-12 16:10:35 +0200 | [diff] [blame] | 124 | message(STATUS " Build Thrift libraries: ${BUILD_LIBRARIES}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 125 | message(STATUS " Language libraries:") |
Roger Meier | 3b99c97 | 2015-04-20 22:49:48 +0200 | [diff] [blame] | 126 | message(STATUS " Build C++ library: ${BUILD_CPP}") |
| 127 | MESSAGE_DEP(WITH_CPP "Disabled by via WITH_CCP=OFF") |
| 128 | MESSAGE_DEP(Boost_FOUND "Boost headers missing") |
| 129 | message(STATUS " Build C (GLib) library: ${BUILD_C_GLIB}") |
| 130 | MESSAGE_DEP(WITH_C_GLIB "Disabled by via WITH_C_GLIB=OFF") |
| 131 | MESSAGE_DEP(GLIB_FOUND "GLib missing") |
| 132 | message(STATUS " Build Java library: ${BUILD_JAVA}") |
| 133 | MESSAGE_DEP(WITH_JAVA "Disabled by via WITH_JAVA=OFF") |
| 134 | MESSAGE_DEP(JAVA_FOUND "Java Runtime missing") |
| 135 | MESSAGE_DEP(ANT_FOUND "Ant missing") |
| 136 | message(STATUS " Build Python library: ${BUILD_PYTHON}") |
| 137 | MESSAGE_DEP(WITH_PYTHON "Disabled by via WITH_PYTHON=OFF") |
| 138 | MESSAGE_DEP(PYTHONLIBS_FOUND "Python libraries missing") |
Nobuaki Sukegawa | 27378fa | 2015-10-29 00:41:39 +0900 | [diff] [blame^] | 139 | message(STATUS " Build Haskell library: ${BUILD_HASKELL}") |
| 140 | MESSAGE_DEP(WITH_HASKELL "Disabled by via WITH_HASKELL=OFF") |
| 141 | MESSAGE_DEP(GHC_FOUND "GHC missing") |
| 142 | MESSAGE_DEP(CABAL_FOUND "Cabal missing") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 143 | message(STATUS " Library features:") |
| 144 | message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}") |
| 145 | message(STATUS " Build static libraries: ${WITH_STATIC_LIB}") |
| 146 | message(STATUS " Build with ZLIB support: ${WITH_ZLIB}") |
| 147 | message(STATUS " Build with libevent support: ${WITH_LIBEVENT}") |
| 148 | message(STATUS " Build with Qt4 support: ${WITH_QT4}") |
Nobuaki Sukegawa | 6622877 | 2014-12-07 21:45:33 +0900 | [diff] [blame] | 149 | message(STATUS " Build with Qt5 support: ${WITH_QT5}") |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 150 | message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}") |
| 151 | message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}") |
| 152 | message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}") |
| 153 | message(STATUS "----------------------------------------------------------") |
| 154 | endmacro(PRINT_CONFIG_SUMMARY) |