blob: 18e52f638fb5a87376fe819d582647d3894f0c40 [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
Jens Geyere02559f2019-10-17 00:11:59 +020031set(thrift_VERSION "0.14.0")
James E. King IIIc9ac8d22019-01-07 16:46:45 -050032set(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
cyya6a3a782019-02-07 22:27:33 +080050# Add CMake targets for static code analysis
51include(StaticCodeAnalysis)
52
Pascal Bachd5f87e12014-12-12 15:59:17 +010053# Generate the config.h file
54include(ConfigureChecks)
55
soroshsabz0c4e96f2019-03-15 15:05:18 +033056# Generate the ThriftConfig.cmake module
57include(GenerateConfigModule)
58
James E. King IIIc9ac8d22019-01-07 16:46:45 -050059# Packaging
Pascal Bachd5f87e12014-12-12 15:59:17 +010060include(CPackConfig)
61
James E. King IIIc9ac8d22019-01-07 16:46:45 -050062# Dependencies
63include(BoostMacros)
Pascal Bachd5f87e12014-12-12 15:59:17 +010064find_package(Threads)
Pascal Bachd5f87e12014-12-12 15:59:17 +010065include(CTest)
James E. King IIIc9ac8d22019-01-07 16:46:45 -050066
Pascal Bachd5f87e12014-12-12 15:59:17 +010067if(BUILD_TESTING)
68 message(STATUS "Building with unittests")
Roger Meier26593812015-04-12 16:10:35 +020069
70 enable_testing()
71 # Define "make check" as alias for "make test"
72 add_custom_target(check COMMAND ctest)
Pascal Bachd5f87e12014-12-12 15:59:17 +010073else ()
74 message(STATUS "Building without tests")
75endif ()
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090076
Pascal Bachd5f87e12014-12-12 15:59:17 +010077if(BUILD_COMPILER)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090078 if(NOT EXISTS ${THRIFT_COMPILER})
79 set(THRIFT_COMPILER $<TARGET_FILE:thrift-compiler>)
80 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010081 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
Nobuaki Sukegawa11da87e2016-09-10 14:02:19 +090082elseif(EXISTS ${THRIFT_COMPILER})
83 add_executable(thrift-compiler IMPORTED)
84 set_property(TARGET thrift-compiler PROPERTY IMPORTED_LOCATION ${THRIFT_COMPILER})
Pascal Bachd5f87e12014-12-12 15:59:17 +010085endif()
86
Roger Meier3b99c972015-04-20 22:49:48 +020087if(BUILD_CPP)
Pascal Bachd5f87e12014-12-12 15:59:17 +010088 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
ben-craig1f64ea92015-07-15 08:11:57 -050089 if(BUILD_TUTORIALS)
90 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tutorial/cpp)
Nobuaki Sukegawaca939362015-11-14 00:23:40 +090091 endif()
Roger Meier26593812015-04-12 16:10:35 +020092 if(BUILD_TESTING)
Marco Moltenifdf01982015-04-15 21:22:41 +020093 if(WITH_LIBEVENT AND WITH_ZLIB AND WITH_OPENSSL)
Marco Molteni7f477922015-04-15 20:46:48 +020094 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
95 else()
Marco Moltenifdf01982015-04-15 21:22:41 +020096 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 +020097 endif()
Roger Meier26593812015-04-12 16:10:35 +020098 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +010099endif()
100
James E. King IIIb1d63e72019-01-22 14:16:39 -0500101if(BUILD_AS3)
102 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/as3)
103endif()
104
Roger Meier3b99c972015-04-20 22:49:48 +0200105if(BUILD_C_GLIB)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100106 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
cyya6a3a782019-02-07 22:27:33 +0800107 if(BUILD_TESTING)
108 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/c_glib)
109 endif()
Pascal Bachd5f87e12014-12-12 15:59:17 +0100110endif()
111
Roger Meier3b99c972015-04-20 22:49:48 +0200112if(BUILD_JAVA)
Pascal Bachd5f87e12014-12-12 15:59:17 +0100113 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
114endif()
115
Mario Emmenlauer93171d22019-10-23 17:32:34 +0200116if(BUILD_JAVASCRIPT)
117 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/js)
118endif()
119
120if(BUILD_NODEJS)
121 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/nodejs)
122endif()
123
Roger Meier3b99c972015-04-20 22:49:48 +0200124if(BUILD_PYTHON)
Roger Meier26593812015-04-12 16:10:35 +0200125 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/py)
Roger Meier211b82d2015-06-04 12:47:31 +0200126 if(BUILD_TESTING)
127 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/py)
128 endif()
Roger Meier26593812015-04-12 16:10:35 +0200129endif()
130
Nobuaki Sukegawa27378fa2015-10-29 00:41:39 +0900131if(BUILD_HASKELL)
132 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/hs)
133 if(BUILD_TESTING)
134 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/hs)
135 endif()
136endif()
137
Pascal Bachd5f87e12014-12-12 15:59:17 +0100138PRINT_CONFIG_SUMMARY()