Skip to content

Commit

Permalink
[brotli] Add unofficial targets
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Aug 31, 2018
1 parent 4aa3aab commit 33286f9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ports/brotli/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Source: brotli
Version: 1.0.2-3
Version: 1.0.2-4
Description: a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling.
56 changes: 56 additions & 0 deletions ports/brotli/install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ac55f6b..e016967 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -166,12 +166,11 @@ endforeach()

foreach(lib brotlicommon brotlidec brotlienc brotlicommon-static brotlidec-static brotlienc-static)
target_link_libraries(${lib} ${LIBM_LIBRARY})
- set_property(TARGET ${lib} APPEND PROPERTY INCLUDE_DIRECTORIES ${BROTLI_INCLUDE_DIRS})
set_target_properties(${lib} PROPERTIES
VERSION "${BROTLI_ABI_COMPATIBILITY}.${BROTLI_ABI_AGE}.${BROTLI_ABI_REVISION}"
SOVERSION "${BROTLI_ABI_COMPATIBILITY}"
POSITION_INDEPENDENT_CODE TRUE)
- set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIRS}")
+ set_property(TARGET ${lib} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${BROTLI_INCLUDE_DIRS}>" $<INSTALL_INTERFACE:include>)
endforeach()

target_link_libraries(brotlidec brotlicommon)
@@ -199,27 +198,35 @@ target_link_libraries(brotli ${BROTLI_LIBRARIES_STATIC})
if(NOT BROTLI_BUNDLED_MODE)
install(
TARGETS brotli
- RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ RUNTIME DESTINATION tools/brotli
+ CONFIGURATIONS Release
)

+ if(BUILD_SHARED_LIBS)
install(
TARGETS ${BROTLI_LIBRARIES_CORE}
+ EXPORT brotli
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
-
+ else()
install(
TARGETS ${BROTLI_LIBRARIES_CORE_STATIC}
+ EXPORT brotli
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
+ endif()

install(
DIRECTORY ${BROTLI_INCLUDE_DIRS}/brotli
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ CONFIGURATIONS Release
)
+
+ install(EXPORT brotli FILE unofficial-brotli-config.cmake NAMESPACE unofficial::brotli:: DESTINATION share/unofficial-brotli)
endif()

# Tests
25 changes: 3 additions & 22 deletions ports/brotli/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vcpkg_from_github(
REF v1.0.2
SHA512 b3ec98159e63b4169dea3e958d60d89247dc1c0f78aab27bfffb2ece659fa024df990d410aa15c12b2082d42e3785e32ec248dce2b116c7f34e98bb6337f9fc9
HEAD_REF master
PATCHES install.patch
)

vcpkg_configure_cmake(
Expand All @@ -16,30 +17,10 @@ vcpkg_configure_cmake(

vcpkg_install_cmake()

file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/brotli)
file(GLOB EXES ${CURRENT_PACKAGES_DIR}/bin/brotli ${CURRENT_PACKAGES_DIR}/bin/brotli.exe)
file(GLOB DEBUG_EXES ${CURRENT_PACKAGES_DIR}/debug/bin/brotli ${CURRENT_PACKAGES_DIR}/debug/bin/brotli.exe)
file(COPY ${EXES} DESTINATION ${CURRENT_PACKAGES_DIR}/tools/brotli)
file(REMOVE ${EXES} ${DEBUG_EXES})

vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/brotli)
vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-brotli TARGET_PATH share/unofficial-brotli)

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
file(GLOB STATIC_LIBS "${CURRENT_PACKAGES_DIR}/lib/*-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/*-static.lib")
file(REMOVE ${STATIC_LIBS})
else()
file(GLOB LIBS
"${CURRENT_PACKAGES_DIR}/lib/*.lib"
"${CURRENT_PACKAGES_DIR}/debug/lib/*.lib"
"${CURRENT_PACKAGES_DIR}/lib/*.a"
"${CURRENT_PACKAGES_DIR}/debug/lib/*.a"
)
list(FILTER LIBS EXCLUDE REGEX "-static\\.lib\$")
list(FILTER LIBS EXCLUDE REGEX "-static\\.a\$")
file(REMOVE_RECURSE ${LIBS} ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/unofficial-brotli)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/brotli RENAME copyright)

vcpkg_copy_pdbs()
11 changes: 11 additions & 0 deletions ports/brotli/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_find_package(${ARGS})
foreach(T brotlicommon brotlidec brotlienc)
if(TARGET unofficial::brotli::${T} AND NOT TARGET unofficial::brotli::${T}-static)
_add_library(unofficial::brotli::${T}-static INTERFACE IMPORTED)
set_target_properties(unofficial::brotli::${T}-static PROPERTIES INTERFACE_LINK_LIBRARIES "unofficial::brotli::${T}")
endif()
if(NOT TARGET unofficial::brotli::${T} AND TARGET unofficial::brotli::${T}-static)
_add_library(unofficial::brotli::${T} INTERFACE IMPORTED)
set_target_properties(unofficial::brotli::${T} PROPERTIES INTERFACE_LINK_LIBRARIES "unofficial::brotli::${T}-static")
endif()
endforeach()

0 comments on commit 33286f9

Please sign in to comment.