blob: 5e5636a379699a61f1c3626e00be0a1d45b4e288 [file] [log] [blame]
Roger Meier81b3c442015-04-12 21:06:11 +02001
2
Pascal Bachd5f87e12014-12-12 15:59:17 +01003#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License. You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21
22
Roger Meier81b3c442015-04-12 21:06:11 +020023cmake_minimum_required(VERSION 3.0.2)
Pascal Bachd5f87e12014-12-12 15:59:17 +010024
25project(thrift)
26
jfarrelle03f7e82015-02-18 23:25:54 -050027set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
Pascal Bachd5f87e12014-12-12 15:59:17 +010028
29# TODO: add `git rev-parse --short HEAD`
30# Read the version information from the Autoconf file
31file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" CONFIGURE_AC REGEX "AC_INIT\\(.*\\)" )
32
33# The following variable is used in the version.h.in file
34string(REGEX REPLACE "AC_INIT\\(\\[.*\\], \\[([0-9]+\\.[0-9]+\\.[0-9]+(-dev)?)\\]\\)" "\\1" PACKAGE_VERSION ${CONFIGURE_AC})
35message(STATUS "Parsed Thrift package version: ${PACKAGE_VERSION}")
36
37# These are internal to CMake
38string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)(-dev)?" "\\1" thrift_VERSION ${PACKAGE_VERSION})
39string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" thrift_VERSION_MAJOR ${thrift_VERSION})
40string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" thrift_VERSION_MINOR ${thrift_VERSION})
41string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${thrift_VERSION})
42message(STATUS "Parsed Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
43
44# Some default settings
45include(DefineCMakeDefaults)
46
47# Build time options are defined here
48include(DefineOptions)
49include(DefineInstallationPaths)
50
51# Based on the options set some platform specifics
52include(DefinePlatformSpecifc)
53
54# Generate the config.h file
55include(ConfigureChecks)
56
57# Package it
58include(CPackConfig)
59
60
61find_package(Threads)
62
63include(CTest)
64if(BUILD_TESTING)
65 message(STATUS "Building with unittests")
Roger Meier26593812015-04-12 16:10:35 +020066
67 enable_testing()
68 # Define "make check" as alias for "make test"
69 add_custom_target(check COMMAND ctest)
Pascal Bachd5f87e12014-12-12 15:59:17 +010070else ()
71 message(STATUS "Building without tests")
72endif ()
73if(BUILD_COMPILER)
74 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
75endif()
76
77if(WITH_CPP)
78 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
Roger Meier26593812015-04-12 16:10:35 +020079 if(BUILD_TESTING)
80 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
81 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010082endif()
83
84if(WITH_C_GLIB)
85 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
86endif()
87
88if(WITH_JAVA)
89 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
90endif()
91
Roger Meier26593812015-04-12 16:10:35 +020092if(WITH_PYTHON)
93 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/py)
94endif()
95
Pascal Bachd5f87e12014-12-12 15:59:17 +010096PRINT_CONFIG_SUMMARY()