blob: d7144ea8f77fdbb103a7b389a9592c96eccd3b7e [file] [log] [blame]
Pascal Bachd5f87e12014-12-12 15:59:17 +01001#
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
21include(CMakeDependentOption)
22
23# Additional components
24option(BUILD_COMPILER "Build Thrift compiler" ON)
25option(BUILD_TESTING "Build with unit tests" ON)
26option(BUILD_EXAMPLES "Build examples" ON)
27option(BUILD_LIBRARIES "Build Thrfit libraries" ON)
28
29# Libraries to build
30
31# Each language library can be enabled or disabled using the WITH_<LANG> flag.
32# By default CMake checks if the required dependencies for a language are present
33# and enables the library if all are found. This means the default is to build as
34# much as possible but leaving out libraries if their dependencies are not met.
35
36# C++
37find_package(Boost 1.53 QUIET)
38CMAKE_DEPENDENT_OPTION(WITH_CPP "Build C++ library" ON
39 "BUILD_LIBRARIES;Boost_FOUND" OFF)
40# NOTE: Currently the following options are C++ specific,
41# but in future other libraries might reuse them.
42# So they are not dependent on WIHT_CPP but setting them without WITH_CPP currently
43# has no effect.
44find_package(ZLIB QUIET)
45CMAKE_DEPENDENT_OPTION(WITH_ZLIB "Build with ZLIB support" ON
46 "ZLIB_FOUND" OFF)
47find_package(Libevent QUIET)
48CMAKE_DEPENDENT_OPTION(WITH_LIBEVENT "Build with libevent support" ON
49 "Libevent_FOUND" OFF)
Nobuaki Sukegawa6304a532014-12-18 01:30:58 +090050find_package(Qt4 QUIET COMPONENTS QtCore QtNetwork)
Pascal Bachd5f87e12014-12-12 15:59:17 +010051CMAKE_DEPENDENT_OPTION(WITH_QT4 "Build with Qt4 support" ON
52 "QT4_FOUND" OFF)
Nobuaki Sukegawa66228772014-12-07 21:45:33 +090053find_package(Qt5 QUIET COMPONENTS Core Network)
54CMAKE_DEPENDENT_OPTION(WITH_QT5 "Build with Qt5 support" ON
55 "Qt5_FOUND" OFF)
56if(${WITH_QT4} AND ${WITH_QT5} AND ${CMAKE_MAJOR_VERSION} LESS 3)
57 # cmake < 3.0.0 causes conflict when building both Qt4 and Qt5
58 set(WITH_QT4 OFF)
59endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010060find_package(OpenSSL QUIET)
61CMAKE_DEPENDENT_OPTION(WITH_OPENSSL "Build with OpenSSL support" ON
62 "OpenSSL_FOUND" OFF)
63option(WITH_BOOSTTHREADS "Build with Boost thread support" OFF)
64option(WITH_STDTHREADS "Build with C++ std::thread support" OFF)
65
66# C GLib
67find_package(GLIB QUIET COMPONENTS gobject)
68CMAKE_DEPENDENT_OPTION(WITH_C_GLIB "Build C (GLib) library" ON
69 "BUILD_LIBRARIES;GLIB_FOUND" OFF)
70# Java
71find_package(Java QUIET)
72CMAKE_DEPENDENT_OPTION(WITH_JAVA "Build Java library" ON
73 "BUILD_LIBRARIES;JAVA_FOUND" OFF)
74
75# Common library options
76option(WITH_SHARED_LIB "Build shared libraries" ON)
77option(WITH_STATIC_LIB "Build static libraries" ON)
78
79#NOTE: C++ compiler options are defined in the lib/cpp/CMakeLists.txt
80
81# Visual Studio only options
82if(MSVC)
83option(WITH_MT "Build unsing MT instead of MT (MSVC only)" OFF)
84endif(MSVC)
85
86macro(PRINT_CONFIG_SUMMARY)
87message(STATUS "----------------------------------------------------------")
88message(STATUS "Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
89message(STATUS "Thrift package version: ${PACKAGE_VERSION}")
90message(STATUS "Build configuration Summary")
91message(STATUS " Build Thrift compiler: ${BUILD_COMPILER}")
92message(STATUS " Build with unit tests: ${BUILD_TESTING}")
93message(STATUS " Build examples: ${BUILD_EXAMPLES}")
94message(STATUS " Build Thrfit libraries: ${BUILD_LIBRARIES}")
95message(STATUS " Language libraries:")
96message(STATUS " Build C++ library: ${WITH_CPP}")
97message(STATUS " Build C (GLib) library: ${WITH_C_GLIB}")
98message(STATUS " Build Java library: ${WITH_JAVA}")
99message(STATUS " Library features:")
100message(STATUS " Build shared libraries: ${WITH_SHARED_LIB}")
101message(STATUS " Build static libraries: ${WITH_STATIC_LIB}")
102message(STATUS " Build with ZLIB support: ${WITH_ZLIB}")
103message(STATUS " Build with libevent support: ${WITH_LIBEVENT}")
104message(STATUS " Build with Qt4 support: ${WITH_QT4}")
Nobuaki Sukegawa66228772014-12-07 21:45:33 +0900105message(STATUS " Build with Qt5 support: ${WITH_QT5}")
Pascal Bachd5f87e12014-12-12 15:59:17 +0100106message(STATUS " Build with OpenSSL support: ${WITH_OPENSSL}")
107message(STATUS " Build with Boost thread support: ${WITH_BOOSTTHREADS}")
108message(STATUS " Build with C++ std::thread support: ${WITH_STDTHREADS}")
109message(STATUS "----------------------------------------------------------")
110endmacro(PRINT_CONFIG_SUMMARY)