Skip to content

Commit

Permalink
[glib] Add unofficial exports to propagate static dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Jul 17, 2018
1 parent b4422a1 commit 984d95f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 8 deletions.
31 changes: 26 additions & 5 deletions ports/glib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ else()
target_link_libraries(glib PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
endif()
target_include_directories(glib PRIVATE ${PCRE_INCLUDE_DIR} ${ICONV_INCLUDE_DIR})
target_include_directories(glib PUBLIC ${LIBINTL_INCLUDE_DIR})
target_include_directories(glib PUBLIC $<BUILD_INTERFACE:${LIBINTL_INCLUDE_DIR}> $<INSTALL_INTERFACE:include>)
list(APPEND GLIB_TARGETS glib)
if(NOT GLIB_SKIP_HEADERS)
install(FILES glib/glib.h glib/glib-object.h ${CMAKE_BINARY_DIR}/config/glib/glibconfig.h DESTINATION include)
Expand All @@ -151,7 +151,7 @@ extract_vcproj_sources(win32/vs14/gobject.vcxproj GOBJECT_SOURCES)
add_library(gobject ${GOBJECT_SOURCES})
target_compile_definitions(gobject PRIVATE GOBJECT_COMPILATION G_LOG_DOMAIN="GLib-GObject")
target_link_libraries(gobject PRIVATE gthread glib ${FFI_LIBRARY})
target_include_directories(gobject PRIVATE ${FFI_INCLUDE_DIR})
target_include_directories(gobject PRIVATE ${FFI_INCLUDE_DIR} PUBLIC $<INSTALL_INTERFACE:include>)
list(APPEND GLIB_TARGETS gobject)
if(NOT GLIB_SKIP_HEADERS)
file(GLOB GOBJECT_HEADERS gobject/*.h gobject/gobjectnotifyqueue.c)
Expand All @@ -164,7 +164,7 @@ add_library(gmodule gmodule/gmodule.c)
target_compile_definitions(gmodule PRIVATE G_LOG_DOMAIN="GModule")
target_link_libraries(gmodule PRIVATE glib ${LIBINTL_LIBRARY})
target_include_directories(gmodule PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gmodule>)
target_include_directories(gmodule PRIVATE ${LIBINTL_INCLUDE_DIR})
target_include_directories(gmodule PRIVATE ${LIBINTL_INCLUDE_DIR} PUBLIC $<INSTALL_INTERFACE:include>)
list(APPEND GLIB_TARGETS gmodule)
if(NOT GLIB_SKIP_HEADERS)
install(FILES gmodule/gmodule.h DESTINATION include)
Expand Down Expand Up @@ -232,7 +232,7 @@ endif()
add_library(gio ${GIO_SOURCES})
target_compile_definitions(gio PRIVATE GIO_COMPILATION G_LOG_DOMAIN="GLib-GIO")
target_link_libraries(gio PRIVATE glib gmodule gobject ZLIB::ZLIB ${LIBRESOLV_LIBRARY} ${LIBINTL_LIBRARY})
target_include_directories(gio PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gio>)
target_include_directories(gio PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/gio> $<INSTALL_INTERFACE:include/gio>)
if(WIN32)
target_link_libraries(gio PRIVATE ws2_32 shlwapi dnsapi iphlpapi)
elseif(APPLE)
Expand Down Expand Up @@ -297,7 +297,28 @@ if(NOT GLIB_SKIP_TOOLS)
install(TARGETS ${GLIB_TOOLS} RUNTIME DESTINATION tools/glib)
endif()

install(TARGETS ${GLIB_TARGETS} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
install(
TARGETS ${GLIB_TARGETS}
EXPORT glib
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(
EXPORT glib
NAMESPACE unofficial::glib::
FILE unofficial-glib-targets.cmake
DESTINATION share/unofficial-glib
)
configure_file(
cmake/unofficial-glib-config.in.cmake
cmake/unofficial-glib-config.cmake
@ONLY
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/unofficial-glib-config.cmake
DESTINATION share/unofficial-glib
)

message(STATUS "Link-time dependencies:")
message(STATUS " " ${ZLIB_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion ports/glib/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: glib
Version: 2.52.3-9
Version: 2.52.3-11
Description: Portable, general-purpose utility library.
Build-Depends: zlib, pcre, libffi, gettext, libiconv
7 changes: 7 additions & 0 deletions ports/glib/cmake/unofficial-glib-config.in.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
include(CMakeFindDependencyMacro)
find_dependency(Threads)
find_dependency(unofficial-iconv)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/unofficial-glib-targets.cmake")
4 changes: 3 additions & 1 deletion ports/glib/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ vcpkg_configure_cmake(
OPTIONS_DEBUG
-DGLIB_SKIP_HEADERS=ON
-DGLIB_SKIP_TOOLS=ON
)
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-glib TARGET_PATH share/unofficial-glib)

vcpkg_copy_pdbs()
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/glib)

Expand Down
2 changes: 1 addition & 1 deletion ports/harfbuzz/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: harfbuzz
Version: 1.8.2-2
Version: 1.8.2-3
Description: HarfBuzz OpenType text shaping engine
Build-Depends: freetype, ragel
Default-Features: ucdn
Expand Down
29 changes: 29 additions & 0 deletions ports/harfbuzz/glib-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c52731..8305f27 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -314,22 +314,12 @@ endif ()
if (HB_HAVE_GLIB)
add_definitions(-DHAVE_GLIB)

- # https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGLIB.cmake
- find_package(PkgConfig)
- pkg_check_modules(PC_GLIB QUIET glib-2.0)
-
- find_library(GLIB_LIBRARIES NAMES glib-2.0 HINTS ${PC_GLIB_LIBDIR} ${PC_GLIB_LIBRARY_DIRS})
- find_path(GLIBCONFIG_INCLUDE_DIR NAMES glibconfig.h HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0/include)
- find_path(GLIB_INCLUDE_DIR NAMES glib.h HINTS ${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS} PATH_SUFFIXES glib-2.0)
-
- include_directories(${GLIBCONFIG_INCLUDE_DIR} ${GLIB_INCLUDE_DIR})
+ find_package(unofficial-glib CONFIG REQUIRED)

list(APPEND project_sources ${PROJECT_SOURCE_DIR}/src/hb-glib.cc)
list(APPEND project_headers ${PROJECT_SOURCE_DIR}/src/hb-glib.h)

- list(APPEND THIRD_PARTY_LIBS ${GLIB_LIBRARIES})
-
- mark_as_advanced(GLIB_LIBRARIES GLIBCONFIG_INCLUDE_DIR GLIB_INCLUDE_DIR)
+ list(APPEND THIRD_PARTY_LIBS unofficial::glib::glib)
endif ()

if (HB_HAVE_ICU)
1 change: 1 addition & 0 deletions ports/harfbuzz/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ vcpkg_apply_patches(
PATCHES
"${CMAKE_CURRENT_LIST_DIR}/0001-fix-uwp-build.patch"
"${CMAKE_CURRENT_LIST_DIR}/find-package-freetype-2.patch"
"${CMAKE_CURRENT_LIST_DIR}/glib-cmake.patch"
)

SET(HB_HAVE_ICU "OFF")
Expand Down

0 comments on commit 984d95f

Please sign in to comment.