2014-12-12 14:59:17 +00:00
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2015-04-14 20:05:50 +00:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2014-12-12 14:59:17 +00:00
|
|
|
|
|
|
|
project(thrift)
|
|
|
|
|
2015-02-19 04:25:54 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
|
2014-12-12 14:59:17 +00:00
|
|
|
|
|
|
|
# TODO: add `git rev-parse --short HEAD`
|
|
|
|
# Read the version information from the Autoconf file
|
|
|
|
file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" CONFIGURE_AC REGEX "AC_INIT\\(.*\\)" )
|
|
|
|
|
|
|
|
# The following variable is used in the version.h.in file
|
|
|
|
string(REGEX REPLACE "AC_INIT\\(\\[.*\\], \\[([0-9]+\\.[0-9]+\\.[0-9]+(-dev)?)\\]\\)" "\\1" PACKAGE_VERSION ${CONFIGURE_AC})
|
|
|
|
message(STATUS "Parsed Thrift package version: ${PACKAGE_VERSION}")
|
|
|
|
|
|
|
|
# These are internal to CMake
|
|
|
|
string(REGEX REPLACE "([0-9]+\\.[0-9]+\\.[0-9]+)(-dev)?" "\\1" thrift_VERSION ${PACKAGE_VERSION})
|
|
|
|
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" thrift_VERSION_MAJOR ${thrift_VERSION})
|
|
|
|
string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" thrift_VERSION_MINOR ${thrift_VERSION})
|
|
|
|
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" thrift_VERSION_PATCH ${thrift_VERSION})
|
|
|
|
message(STATUS "Parsed Thrift version: ${thrift_VERSION} (${thrift_VERSION_MAJOR}.${thrift_VERSION_MINOR}.${thrift_VERSION_PATCH})")
|
|
|
|
|
|
|
|
# Some default settings
|
|
|
|
include(DefineCMakeDefaults)
|
|
|
|
|
|
|
|
# Build time options are defined here
|
|
|
|
include(DefineOptions)
|
|
|
|
include(DefineInstallationPaths)
|
|
|
|
|
|
|
|
# Based on the options set some platform specifics
|
|
|
|
include(DefinePlatformSpecifc)
|
|
|
|
|
|
|
|
# Generate the config.h file
|
|
|
|
include(ConfigureChecks)
|
|
|
|
|
|
|
|
# Package it
|
|
|
|
include(CPackConfig)
|
|
|
|
|
|
|
|
|
|
|
|
find_package(Threads)
|
|
|
|
|
|
|
|
include(CTest)
|
|
|
|
if(BUILD_TESTING)
|
|
|
|
message(STATUS "Building with unittests")
|
2015-04-12 14:10:35 +00:00
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
# Define "make check" as alias for "make test"
|
|
|
|
add_custom_target(check COMMAND ctest)
|
2014-12-12 14:59:17 +00:00
|
|
|
else ()
|
|
|
|
message(STATUS "Building without tests")
|
|
|
|
endif ()
|
|
|
|
if(BUILD_COMPILER)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_CPP)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
|
2015-04-12 14:10:35 +00:00
|
|
|
if(BUILD_TESTING)
|
2015-04-15 18:46:48 +00:00
|
|
|
if(WITH_LIBEVENT)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
|
|
|
|
else()
|
|
|
|
message(WARNING "libevent not found or disabled; will not build some tests")
|
|
|
|
endif()
|
2015-04-12 14:10:35 +00:00
|
|
|
endif()
|
2014-12-12 14:59:17 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_C_GLIB)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(WITH_JAVA)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
|
|
|
|
endif()
|
|
|
|
|
2015-04-12 14:10:35 +00:00
|
|
|
if(WITH_PYTHON)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/py)
|
|
|
|
endif()
|
|
|
|
|
2014-12-12 14:59:17 +00:00
|
|
|
PRINT_CONFIG_SUMMARY()
|