Skip to content

Commit

Permalink
[Thrift] Make Thrift static again (#7302)
Browse files Browse the repository at this point in the history
* Make thrift static

* Update CONTROL

* Thrift able to build statically and dynamically

* Clean up bin dir in static

* Changes as per discussion

* Remove comment

* Better comment
  • Loading branch information
philjdf authored and dan-shaw committed Jul 25, 2019
1 parent 8255ef3 commit 8522c79
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ports/thrift/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: thrift
Version: 2019-05-07-2
Version: 2019-05-07-3
Build-Depends: zlib, libevent, openssl, boost-range, boost-smart-ptr, boost-date-time, boost-locale, boost-scope-exit
Homepage: https://github.com/apache/thrift
Description: Apache Thrift is a software project spanning a variety of programming languages and use cases. Our goal is to make reliable, performant communication and data serialization across languages as efficient and seamless as possible.
24 changes: 21 additions & 3 deletions ports/thrift/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
include(vcpkg_common_functions)

# We currently insist on static only because:
# - Thrift doesn't yet support building as a DLL on Windows,
# - x64-linux only builds static anyway.
# From https://github.com/apache/thrift/blob/master/CHANGES.md
# it looks like it will be supported in v0.13.
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_find_acquire_program(FLEX)
Expand All @@ -13,11 +18,15 @@ vcpkg_from_github(
HEAD_REF master
)

# note we specify values for WITH_STATIC_LIB and WITH_SHARED_LIB because even though
# they're marked as deprecated, Thrift incorrectly hard-codes a value for BUILD_SHARED_LIBS.
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
NO_CHARSET_FLAG
OPTIONS
-DWITH_SHARED_LIB=off
-DWITH_STATIC_LIB=on
-DWITH_STDTHREADS=ON
-DBUILD_TESTING=off
-DBUILD_JAVA=off
Expand All @@ -38,14 +47,23 @@ file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/th
# Move CMake config files to the right place
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/thrift)

file(GLOB COMPILER "${CURRENT_PACKAGES_DIR}/bin/thrift*")
file(GLOB COMPILER "${CURRENT_PACKAGES_DIR}/bin/thrift" "${CURRENT_PACKAGES_DIR}/bin/thrift.exe")
if(COMPILER)
file(COPY ${COMPILER} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/thrift)
file(REMOVE ${COMPILER})
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/thrift)
endif()

file(GLOB COMPILERD "${CURRENT_PACKAGES_DIR}/debug/bin/thrift" "${CURRENT_PACKAGES_DIR}/debug/bin/thrift.exe")
if(COMPILERD)
file(REMOVE ${COMPILERD})
endif()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)

if ("${VCPKG_LIBRARY_LINKAGE}" STREQUAL "static")
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
endif()

vcpkg_copy_pdbs()

0 comments on commit 8522c79

Please sign in to comment.