blob: e9ebbab9388b725531a0208b1bcce0ebc6e9a1a2 [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
James E. King III278528c2019-01-11 12:17:44 -050020cmake_minimum_required(VERSION 3.4)
James E. King, III43e959b2017-04-04 13:04:29 -040021
James E. King IIIc9ac8d22019-01-07 16:46:45 -050022if(POLICY CMP0048)
23 cmake_policy(SET CMP0048 NEW) # package version behavior added in cmake 3.0
24endif()
25if(POLICY CMP0074)
26 cmake_policy(SET CMP0074 NEW) # find_package behavior added in cmake 3.12
27endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010028
James E. King IIIc9ac8d22019-01-07 16:46:45 -050029# PACKAGE_VERSION is used by cpack scripts currently
30# Both thrift_VERSION and PACKAGE_VERSION should be the same for now
31set(thrift_VERSION "1.0.0")
32set(PACKAGE_VERSION ${thrift_VERSION})
33
34project("thrift" VERSION ${PACKAGE_VERSION})
35message(STATUS "Configuring ${CMAKE_PROJECT_NAME} ${thrift_VERSION}")
36
Pascal Bachd5f87e12014-12-12 15:59:17 +010037
jfarrelle03f7e82015-02-18 23:25:54 -050038set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
Pascal Bachd5f87e12014-12-12 15:59:17 +010039
Pascal Bachd5f87e12014-12-12 15:59:17 +010040# Some default settings
41include(DefineCMakeDefaults)
42
43# Build time options are defined here
44include(DefineOptions)
45include(DefineInstallationPaths)
46
47# Based on the options set some platform specifics
48include(DefinePlatformSpecifc)
49
50# Generate the config.h file
51include(ConfigureChecks)
52
James E. King IIIc9ac8d22019-01-07 16:46:45 -050053# Packaging
Pascal Bachd5f87e12014-12-12 15:59:17 +010054include(CPackConfig)
55
James E. King IIIc9ac8d22019-01-07 16:46:45 -050056# Dependencies
57include(BoostMacros)
Pascal Bachd5f87e12014-12-12 15:59:17 +010058find_package(Threads)
Pascal Bachd5f87e12014-12-12 15:59:17 +010059include(CTest)
James E. King IIIc9ac8d22019-01-07 16:46:45 -050060
Pascal Bachd5f87e12014-12-12 15:59:17 +010061if(BUILD_TESTING)
62 message(STATUS "Building with unittests")
Roger Meier26593812015-04-12 16:10:35 +020063
64 enable_testing()
65 # Define "make check" as alias for "make test"
66 add_custom_target(check COMMAND ctest)
Pascal Bachd5f87e12014-12-12 15:59:17 +010067else ()
68 message(STATUS "Building without tests")
69endif ()
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090070
Pascal Bachd5f87e12014-12-12 15:59:17 +010071if(BUILD_COMPILER)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090072 if(NOT EXISTS ${THRIFT_COMPILER})
73 set(THRIFT_COMPILER $<TARGET_FILE:thrift-compiler>)
74 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010075 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +090076elseif(EXISTS ${THRIFT_COMPILER})
77 add_executable(thrift-compiler IMPORTED)
78 set_property(TARGET thrift-compiler PROPERTY IMPORTED_LOCATION ${THRIFT_COMPILER})
Pascal Bachd5f87e12014-12-12 15:59:17 +010079endif()
80
Roger Meier3b99c972015-04-20 22:49:48 +020081if(BUILD_CPP)
Pascal Bachd5f87e12014-12-12 15:59:17 +010082 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
ben-craig1f64ea92015-07-15 08:11:57 -050083 if(BUILD_TUTORIALS)
84 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tutorial/cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090085 endif()
Roger Meier26593812015-04-12 16:10:35 +020086 if(BUILD_TESTING)
Marco Moltenifdf01982015-04-15 21:22:41 +020087 if(WITH_LIBEVENT AND WITH_ZLIB AND WITH_OPENSSL)
Marco Molteni7f477922015-04-15 20:46:48 +020088 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
89 else()
Marco Moltenifdf01982015-04-15 21:22:41 +020090 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 +020091 endif()
Roger Meier26593812015-04-12 16:10:35 +020092 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010093endif()
94
James E. King IIIb1d63e72019-01-22 14:16:39 -050095if(BUILD_AS3)
96 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/as3)
97endif()
98
Roger Meier3b99c972015-04-20 22:49:48 +020099if(BUILD_C_GLIB)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100100 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
101endif()
102
Roger Meier3b99c972015-04-20 22:49:48 +0200103if(BUILD_JAVA)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100104 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
105endif()
106
Roger Meier3b99c972015-04-20 22:49:48 +0200107if(BUILD_PYTHON)
Roger Meier26593812015-04-12 16:10:35 +0200108 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/py)
Roger Meier211b82d2015-06-04 12:47:31 +0200109 if(BUILD_TESTING)
110 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/py)
111 endif()
Roger Meier26593812015-04-12 16:10:35 +0200112endif()
113
Nobuaki Sukegawa27378fa2015-10-29 00:41:39 +0900114if(BUILD_HASKELL)
115 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/hs)
116 if(BUILD_TESTING)
117 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/hs)
118 endif()
119endif()
120
Pascal Bachd5f87e12014-12-12 15:59:17 +0100121PRINT_CONFIG_SUMMARY()