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.
|
|
|
|
#
|
|
|
|
|
2019-01-11 17:17:44 +00:00
|
|
|
cmake_minimum_required(VERSION 3.4)
|
2017-04-04 17:04:29 +00:00
|
|
|
|
2019-01-07 21:46:45 +00:00
|
|
|
if(POLICY CMP0048)
|
|
|
|
cmake_policy(SET CMP0048 NEW) # package version behavior added in cmake 3.0
|
|
|
|
endif()
|
|
|
|
if(POLICY CMP0074)
|
|
|
|
cmake_policy(SET CMP0074 NEW) # find_package behavior added in cmake 3.12
|
|
|
|
endif()
|
2014-12-12 14:59:17 +00:00
|
|
|
|
2019-01-07 21:46:45 +00:00
|
|
|
# PACKAGE_VERSION is used by cpack scripts currently
|
|
|
|
# Both thrift_VERSION and PACKAGE_VERSION should be the same for now
|
2023-07-08 10:49:11 +00:00
|
|
|
set(thrift_VERSION "0.20.0")
|
2019-01-07 21:46:45 +00:00
|
|
|
set(PACKAGE_VERSION ${thrift_VERSION})
|
2014-12-12 14:59:17 +00:00
|
|
|
|
2019-01-07 21:46:45 +00:00
|
|
|
project("thrift" VERSION ${PACKAGE_VERSION})
|
|
|
|
message(STATUS "Configuring ${CMAKE_PROJECT_NAME} ${thrift_VERSION}")
|
2014-12-12 14:59:17 +00:00
|
|
|
|
|
|
|
|
2019-01-07 21:46:45 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
|
2014-12-12 14:59:17 +00:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2019-02-07 14:27:33 +00:00
|
|
|
# Add CMake targets for static code analysis
|
|
|
|
include(StaticCodeAnalysis)
|
|
|
|
|
2014-12-12 14:59:17 +00:00
|
|
|
# Generate the config.h file
|
|
|
|
include(ConfigureChecks)
|
|
|
|
|
2019-03-15 11:35:18 +00:00
|
|
|
# Generate the ThriftConfig.cmake module
|
|
|
|
include(GenerateConfigModule)
|
|
|
|
|
2019-01-07 21:46:45 +00:00
|
|
|
# Packaging
|
2014-12-12 14:59:17 +00:00
|
|
|
include(CPackConfig)
|
|
|
|
|
2019-01-07 21:46:45 +00:00
|
|
|
# Dependencies
|
|
|
|
include(BoostMacros)
|
2014-12-12 14:59:17 +00:00
|
|
|
find_package(Threads)
|
|
|
|
include(CTest)
|
2019-01-07 21:46:45 +00:00
|
|
|
|
2014-12-12 14:59:17 +00:00
|
|
|
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 ()
|
2015-11-13 15:23:40 +00:00
|
|
|
|
2014-12-12 14:59:17 +00:00
|
|
|
if(BUILD_COMPILER)
|
2015-11-13 15:23:40 +00:00
|
|
|
if(NOT EXISTS ${THRIFT_COMPILER})
|
|
|
|
set(THRIFT_COMPILER $<TARGET_FILE:thrift-compiler>)
|
|
|
|
endif()
|
2014-12-12 14:59:17 +00:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/compiler/cpp)
|
2016-09-10 05:02:19 +00:00
|
|
|
elseif(EXISTS ${THRIFT_COMPILER})
|
|
|
|
add_executable(thrift-compiler IMPORTED)
|
|
|
|
set_property(TARGET thrift-compiler PROPERTY IMPORTED_LOCATION ${THRIFT_COMPILER})
|
2014-12-12 14:59:17 +00:00
|
|
|
endif()
|
|
|
|
|
2015-04-20 20:49:48 +00:00
|
|
|
if(BUILD_CPP)
|
2014-12-12 14:59:17 +00:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/cpp)
|
2015-07-15 13:11:57 +00:00
|
|
|
if(BUILD_TUTORIALS)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tutorial/cpp)
|
2015-11-13 15:23:40 +00:00
|
|
|
endif()
|
2015-04-12 14:10:35 +00:00
|
|
|
if(BUILD_TESTING)
|
2015-04-15 19:22:41 +00:00
|
|
|
if(WITH_LIBEVENT AND WITH_ZLIB AND WITH_OPENSSL)
|
2015-04-15 18:46:48 +00:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/cpp)
|
|
|
|
else()
|
2015-04-15 19:22:41 +00:00
|
|
|
message(WARNING "libevent and/or ZLIB and/or OpenSSL not found or disabled; will not build some tests")
|
2015-04-15 18:46:48 +00:00
|
|
|
endif()
|
2015-04-12 14:10:35 +00:00
|
|
|
endif()
|
2014-12-12 14:59:17 +00:00
|
|
|
endif()
|
|
|
|
|
2015-04-20 20:49:48 +00:00
|
|
|
if(BUILD_C_GLIB)
|
2014-12-12 14:59:17 +00:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/c_glib)
|
2019-02-07 14:27:33 +00:00
|
|
|
if(BUILD_TESTING)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/c_glib)
|
|
|
|
endif()
|
2014-12-12 14:59:17 +00:00
|
|
|
endif()
|
|
|
|
|
2015-04-20 20:49:48 +00:00
|
|
|
if(BUILD_JAVA)
|
2014-12-12 14:59:17 +00:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/java)
|
|
|
|
endif()
|
|
|
|
|
2019-10-23 15:32:34 +00:00
|
|
|
if(BUILD_JAVASCRIPT)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/js)
|
|
|
|
endif()
|
|
|
|
|
2022-04-06 08:49:09 +00:00
|
|
|
if(BUILD_KOTLIN)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/kotlin)
|
|
|
|
endif()
|
|
|
|
|
2019-10-23 15:32:34 +00:00
|
|
|
if(BUILD_NODEJS)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/nodejs)
|
|
|
|
endif()
|
|
|
|
|
2015-04-20 20:49:48 +00:00
|
|
|
if(BUILD_PYTHON)
|
2015-04-12 14:10:35 +00:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/py)
|
2015-06-04 10:47:31 +00:00
|
|
|
if(BUILD_TESTING)
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test/py)
|
|
|
|
endif()
|
2015-04-12 14:10:35 +00:00
|
|
|
endif()
|
|
|
|
|
2020-03-23 08:48:35 +00:00
|
|
|
# Create the uninstall target
|
|
|
|
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${PROJECT_SOURCE_DIR}/build/cmake/uninstall.cmake")
|
|
|
|
|
2014-12-12 14:59:17 +00:00
|
|
|
PRINT_CONFIG_SUMMARY()
|