blob: 3fe0f92c1a4bfef65e0f32b1b36c3b4f022fd6b8 [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
21cmake_minimum_required(VERSION 2.8)
22
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")
64else ()
65 message(STATUS "Building without tests")
66endif ()
67if(BUILD_COMPILER)
68 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
69endif()
70
71if(WITH_CPP)
72 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
73endif()
74
75if(WITH_C_GLIB)
76 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
77endif()
78
79if(WITH_JAVA)
80 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
81endif()
82
83PRINT_CONFIG_SUMMARY()