blob: 386a63db9238a36804ed966726f1d937bf8f460f [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
Roger Meier8f271892015-04-14 22:05:50 +020021cmake_minimum_required(VERSION 2.8.12)
Pascal Bachd5f87e12014-12-12 15:59:17 +010022
23project(thrift)
24
jfarrelle03f7e82015-02-18 23:25:54 -050025set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
Pascal Bachd5f87e12014-12-12 15:59:17 +010026
27# TODO: add `git rev-parse --short HEAD`
28# Read the version information from the Autoconf file
29file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" CONFIGURE_AC REGEX "AC_INIT\\(.*\\)" )
30
31# The following variable is used in the version.h.in file
32string(REGEX REPLACE "AC_INIT\\(\\[.*\\], \\[([0-9]+\\.[0-9]+\\.[0-9]+(-dev)?)\\]\\)" "\\1" PACKAGE_VERSION ${CONFIGURE_AC})
33message(STATUS "Parsed Thrift package version: ${PACKAGE_VERSION}")
34
35# These are internal to CMake
36string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)(-dev)?" "\\1" thrift_VERSION ${PACKAGE_VERSION})
37string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" thrift_VERSION_MAJOR ${thrift_VERSION})
38string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" thrift_VERSION_MINOR ${thrift_VERSION})
39string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${thrift_VERSION})
40message(STATUS "Parsed Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
41
42# Some default settings
43include(DefineCMakeDefaults)
44
45# Build time options are defined here
46include(DefineOptions)
47include(DefineInstallationPaths)
48
49# Based on the options set some platform specifics
50include(DefinePlatformSpecifc)
51
52# Generate the config.h file
53include(ConfigureChecks)
54
55# Package it
56include(CPackConfig)
57
58
59find_package(Threads)
60
61include(CTest)
62if(BUILD_TESTING)
63 message(STATUS "Building with unittests")
Roger Meier26593812015-04-12 16:10:35 +020064
65 enable_testing()
66 # Define "make check" as alias for "make test"
67 add_custom_target(check COMMAND ctest)
Pascal Bachd5f87e12014-12-12 15:59:17 +010068else ()
69 message(STATUS "Building without tests")
70endif ()
71if(BUILD_COMPILER)
72 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
73endif()
74
75if(WITH_CPP)
76 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
Roger Meier26593812015-04-12 16:10:35 +020077 if(BUILD_TESTING)
Marco Moltenifdf01982015-04-15 21:22:41 +020078 if(WITH_LIBEVENT AND WITH_ZLIB AND WITH_OPENSSL)
Marco Molteni7f477922015-04-15 20:46:48 +020079 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
80 else()
Marco Moltenifdf01982015-04-15 21:22:41 +020081 message(WARNING "libevent and/or ZLIB and/or OpenSSL not found or disabled; will not build some tests")
Marco Molteni7f477922015-04-15 20:46:48 +020082 endif()
Roger Meier26593812015-04-12 16:10:35 +020083 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010084endif()
85
86if(WITH_C_GLIB)
87 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
88endif()
89
90if(WITH_JAVA)
91 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
92endif()
93
Roger Meier26593812015-04-12 16:10:35 +020094if(WITH_PYTHON)
95 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/py)
96endif()
97
Pascal Bachd5f87e12014-12-12 15:59:17 +010098PRINT_CONFIG_SUMMARY()