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 | cmake_minimum_required(VERSION 2.8) |
| 22 | |
| 23 | project(thrift) |
| 24 | |
| 25 | set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake") |
| 26 | |
| 27 | # TODO: add `git rev-parse --short HEAD` |
| 28 | # Read the version information from the Autoconf file |
| 29 | file (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 |
| 32 | string(REGEX REPLACE "AC_INIT\\(\\[.*\\], \\[([0-9]+\\.[0-9]+\\.[0-9]+(-dev)?)\\]\\)" "\\1" PACKAGE_VERSION ${CONFIGURE_AC}) |
| 33 | message(STATUS "Parsed Thrift package version: ${PACKAGE_VERSION}") |
| 34 | |
| 35 | # These are internal to CMake |
| 36 | string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)(-dev)?" "\\1" thrift_VERSION ${PACKAGE_VERSION}) |
| 37 | string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" thrift_VERSION_MAJOR ${thrift_VERSION}) |
| 38 | string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" thrift_VERSION_MINOR ${thrift_VERSION}) |
| 39 | string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${thrift_VERSION}) |
| 40 | message(STATUS "Parsed Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})") |
| 41 | |
| 42 | # Some default settings |
| 43 | include(DefineCMakeDefaults) |
| 44 | |
| 45 | # Build time options are defined here |
| 46 | include(DefineOptions) |
| 47 | include(DefineInstallationPaths) |
| 48 | |
| 49 | # Based on the options set some platform specifics |
| 50 | include(DefinePlatformSpecifc) |
| 51 | |
| 52 | # Generate the config.h file |
| 53 | include(ConfigureChecks) |
| 54 | |
| 55 | # Package it |
| 56 | include(CPackConfig) |
| 57 | |
| 58 | |
| 59 | find_package(Threads) |
| 60 | |
| 61 | include(CTest) |
| 62 | if(BUILD_TESTING) |
| 63 | message(STATUS "Building with unittests") |
| 64 | else () |
| 65 | message(STATUS "Building without tests") |
| 66 | endif () |
| 67 | if(BUILD_COMPILER) |
| 68 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp) |
| 69 | endif() |
| 70 | |
| 71 | if(WITH_CPP) |
| 72 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp) |
| 73 | endif() |
| 74 | |
| 75 | if(WITH_C_GLIB) |
| 76 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib) |
| 77 | endif() |
| 78 | |
| 79 | if(WITH_JAVA) |
| 80 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java) |
| 81 | endif() |
| 82 | |
| 83 | PRINT_CONFIG_SUMMARY() |