mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-08 20:12:56 -04:00
build: factor out thrift setup from main CMakeLists.txt
This commit is contained in:
parent
2aa6a277ca
commit
1cc2484040
@ -193,7 +193,6 @@ if(ENABLE_STACKTRACE)
|
||||
endif()
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/version.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/thrift_library.cmake)
|
||||
|
||||
if(NOT PRJ_VERSION_FULL)
|
||||
message(FATAL_ERROR "PRJ_VERSION_FULL is not set")
|
||||
@ -342,9 +341,6 @@ endif()
|
||||
find_package(PkgConfig)
|
||||
|
||||
if(APPLE)
|
||||
# For whatever reason, thrift is unhappy if we don't do this
|
||||
find_package(OpenSSL 1.1.1 MODULE REQUIRED)
|
||||
|
||||
if(USE_HOMEBREW_LIBARCHIVE)
|
||||
find_program(HOMEBREW_EXE brew)
|
||||
execute_process(
|
||||
@ -402,14 +398,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
endif()
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/folly.cmake)
|
||||
|
||||
if(DWARFS_GIT_BUILD)
|
||||
set(THRIFT_COMPILER_ONLY
|
||||
ON
|
||||
CACHE BOOL "only build thrift compiler")
|
||||
|
||||
add_subdirectory(fbthrift EXCLUDE_FROM_ALL SYSTEM)
|
||||
endif()
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/thrift.cmake)
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/thrift_library.cmake)
|
||||
|
||||
if(WITH_TESTS)
|
||||
if(PREFER_SYSTEM_GTEST)
|
||||
@ -868,39 +858,6 @@ if(WITH_MAN_PAGES)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(DWARFS_GIT_BUILD)
|
||||
set(THRIFT_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else()
|
||||
set(THRIFT_GENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
dwarfs_thrift_lite OBJECT
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp/protocol/TProtocolException.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp/util/VarintUtils.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/FieldRef.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/frozen/Frozen.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/frozen/FrozenUtil.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/frozen/schema/MemorySchema.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/gen/module_types_cpp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/BinaryProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/CompactProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/DebugProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/JSONProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/JSONProtocolCommon.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/Protocol.cpp
|
||||
${THRIFT_GENERATED_DIR}/thrift/lib/thrift/gen-cpp2/frozen_data.cpp
|
||||
${THRIFT_GENERATED_DIR}/thrift/lib/thrift/gen-cpp2/frozen_types.cpp
|
||||
)
|
||||
|
||||
set_property(TARGET dwarfs_thrift_lite PROPERTY CXX_STANDARD 20)
|
||||
target_link_libraries(dwarfs_thrift_lite PUBLIC dwarfs_folly_lite)
|
||||
|
||||
target_include_directories(dwarfs_thrift_lite SYSTEM PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fbthrift>
|
||||
$<BUILD_INTERFACE:${THRIFT_GENERATED_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(dwarfs_common PRIVATE dwarfs_thrift_lite)
|
||||
|
||||
add_cpp2_thrift_library(fbthrift/thrift/lib/thrift/frozen.thrift
|
||||
|
60
cmake/thrift.cmake
Normal file
60
cmake/thrift.cmake
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# Copyright (c) Marcus Holland-Moritz
|
||||
#
|
||||
# This file is part of dwarfs.
|
||||
#
|
||||
# dwarfs is free software: you can redistribute it and/or modify it under the
|
||||
# terms of the GNU General Public License as published by the Free Software
|
||||
# Foundation, either version 3 of the License, or (at your option) any later
|
||||
# version.
|
||||
#
|
||||
# dwarfs is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with
|
||||
# dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.28.0)
|
||||
|
||||
if(APPLE)
|
||||
# For whatever reason, thrift is unhappy if we don't do this
|
||||
find_package(OpenSSL 1.1.1 MODULE REQUIRED)
|
||||
endif()
|
||||
|
||||
if(DWARFS_GIT_BUILD)
|
||||
set(THRIFT_COMPILER_ONLY ON CACHE BOOL "only build thrift compiler")
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fbthrift EXCLUDE_FROM_ALL SYSTEM)
|
||||
set(THRIFT_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else()
|
||||
set(THRIFT_GENERATED_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
dwarfs_thrift_lite OBJECT
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp/protocol/TProtocolException.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp/util/VarintUtils.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/FieldRef.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/frozen/Frozen.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/frozen/FrozenUtil.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/frozen/schema/MemorySchema.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/gen/module_types_cpp.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/BinaryProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/CompactProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/DebugProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/JSONProtocol.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/JSONProtocolCommon.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fbthrift/thrift/lib/cpp2/protocol/Protocol.cpp
|
||||
${THRIFT_GENERATED_DIR}/thrift/lib/thrift/gen-cpp2/frozen_data.cpp
|
||||
${THRIFT_GENERATED_DIR}/thrift/lib/thrift/gen-cpp2/frozen_types.cpp
|
||||
)
|
||||
|
||||
set_property(TARGET dwarfs_thrift_lite PROPERTY CXX_STANDARD 20)
|
||||
target_link_libraries(dwarfs_thrift_lite PUBLIC dwarfs_folly_lite)
|
||||
|
||||
target_include_directories(dwarfs_thrift_lite SYSTEM PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/fbthrift>
|
||||
$<BUILD_INTERFACE:${THRIFT_GENERATED_DIR}>
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user