Skip to content

Commit

Permalink
add overrideable version to shared libraries
Browse files Browse the repository at this point in the history
Summary:
Shared libraries should be versioned instead of just plain `*.so`.

Since upstream doesn't currently guarantee ABI stability, we want to let
downstream distributions override the version themselves when they
update fbthrift.

Reviewed By: vitaut

Differential Revision: D24577614

fbshipit-source-id: 29ee02c3944c3904062f771b7fc45214cbf80d35
  • Loading branch information
michel-slm authored and facebook-github-bot committed Oct 28, 2020
1 parent cf16ffe commit 9da0a20
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 11 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
cmake_minimum_required(VERSION 3.1.3 FATAL_ERROR)

# Package information
project("fbthrift" C CXX)
if (NOT DEFINED PACKAGE_VERSION)
set(PACKAGE_VERSION "1.0.0")
endif()
project("fbthrift" VERSION ${PACKAGE_VERSION} LANGUAGES C CXX)

if (NOT DEFINED CPACK_GENERATOR)
set(CPACK_GENERATOR "RPM")
Expand Down
10 changes: 9 additions & 1 deletion thrift/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ add_library(
compiler_generators

${GENERATOR_FILES}
$<TARGET_OBJECTS:compiler_generate_templates>
)
target_link_libraries(
compiler_generators

compiler_generate_templates
compiler_base
compiler_lib
mustache_lib
Expand Down Expand Up @@ -162,6 +162,14 @@ if(MSVC)
)
endif(MSVC)

if (BUILD_SHARED_LIBS)
# all but thrift1 since it's a binary
set_target_properties(compiler_ast compiler_base compiler_lib mustache_lib
compiler_generators
PROPERTIES VERSION ${PROJECT_VERSION}
)
endif()

install(
TARGETS
thrift1
Expand Down
10 changes: 1 addition & 9 deletions thrift/compiler/generate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,7 @@ add_custom_command(

add_library(
compiler_generate_templates
OBJECT

${CMAKE_CURRENT_BINARY_DIR}/templates.cc
)

install(
TARGETS
compiler_generate_templates
EXPORT fbthrift-exports
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
)
7 changes: 7 additions & 0 deletions thrift/lib/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ foreach(dir ${THRIFT1_HEADER_DIRS})
FILES_MATCHING PATTERN "*.tcc")
endforeach()

if (BUILD_SHARED_LIBS)
# all but thrift since it's an interface
set_target_properties(thrift-core concurrency protocol transport async
PROPERTIES VERSION ${PROJECT_VERSION}
)
endif()

install(
TARGETS
thrift-core
Expand Down
7 changes: 7 additions & 0 deletions thrift/lib/cpp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ install(
FILES_MATCHING PATTERN "*.h" PATTERN "*.tcc"
)

if (BUILD_SHARED_LIBS)
set_target_properties(rpcmetadata thriftmetadata thriftfrozen2 thriftprotocol
thriftcpp2
PROPERTIES VERSION ${PROJECT_VERSION}
)
endif()

install(
TARGETS
rpcmetadata
Expand Down

0 comments on commit 9da0a20

Please sign in to comment.