Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[glib] Enable static build #15034

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/cairo/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: cairo
Version: 1.16.0
Port-Version: 8
Port-Version: 9
Homepage: https://cairographics.org
Description: Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB.
Build-Depends: zlib, libpng, pixman, freetype, fontconfig
Expand Down
6 changes: 0 additions & 6 deletions ports/cairo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ if ("x11" IN_LIST FEATURES)
message(WARNING "You will need to install Xorg dependencies to use feature x11:\napt install libx11-dev libxft-dev\n")
endif()

if("gobject" IN_LIST FEATURES)
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(FATAL_ERROR "Feature gobject currently only supports dynamic build.")
endif()
endif()

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
x11 WITH_X11
gobject WITH_GOBJECT
Expand Down
1 change: 1 addition & 0 deletions ports/fluidsynth/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: fluidsynth
Version: 2.1.4
Port-Version: 1
Homepage: https://github.com/FluidSynth/fluidsynth
Description: FluidSynth reads and handles MIDI events from the MIDI input device. It is the software analogue of a MIDI synthesizer. FluidSynth can also play midifiles using a Soundfont.
Build-Depends: glib
30 changes: 30 additions & 0 deletions ports/fluidsynth/fix-dependency-glib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c933c8e..b5c29ad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -437,20 +437,14 @@ endif(ASTYLE)

if(NOT enable-pkgconfig)

- FIND_LIBRARY( GLIB_LIB NAMES glib glib-2.0 PATH GLIB_LIBRARY_DIR )
- FIND_LIBRARY( GTHREAD_LIB NAMES gthread gthread-2.0 PATH GTHREAD_LIBRARY_DIR )
- FIND_PATH( GLIBH_DIR glib.h PATH GLIB_INCLUDE_DIR )
- FIND_PATH( GLIBCONF_DIR glibconfig.h PATH GLIBCONF_INCLUDE_DIR )
-
- IF( GLIB_LIB MATCHES "GLIB_LIB-NOTFOUND" OR
- GTHREAD_LIB MATCHES "GTHREAD_LIB-NOTFOUND" OR
- GLIBH_DIR MATCHES "GLIBH_DIR-NOTFOUND" OR
- GLIBCONF_DIR MATCHES "GLIBCONF_DIR-NOTFOUND")
+ find_package(unofficial-glib CONFIG REQUIRED)
+
+ IF(0)
message( WARNING "Not sure if I found GLIB, continuing anyway.")
ENDIF()

- SET( GLIB_INCLUDE_DIRS ${GLIBH_DIR} ${GLIBCONF_DIR} )
- SET( GLIB_LIBRARIES ${GLIB_LIB} ${GTHREAD_LIB} )
+ get_target_property(GLIB_INCLUDE_DIRS unofficial::glib::glib INTERFACE_INCLUDE_DIRECTORIES)
+ SET( GLIB_LIBRARIES unofficial::glib::glib unofficial::glib::gthread unofficial::glib::gmodule)

message( STATUS "GLIB_INCLUDE_DIRS: " ${GLIB_INCLUDE_DIRS} )
message( STATUS "GLIB_LIBRARIES: " ${GLIB_LIBRARIES} )
1 change: 1 addition & 0 deletions ports/fluidsynth/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
force-x86-gentables.patch
fix-dependency-glib.patch
)

vcpkg_configure_cmake(
Expand Down
10 changes: 10 additions & 0 deletions ports/glib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if(BUILD_SHARED_LIBS)
add_definitions(-DDLL_EXPORT)
endif()

if (WIN32)
add_definitions(-DG_PLATFORM_WIN32 -DG_OS_WIN32)
endif()

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

# find dependencies
Expand Down Expand Up @@ -135,6 +139,9 @@ if(NOT WIN32)
endif()
add_library(glib ${GLIB_SOURCES})
target_compile_definitions(glib PRIVATE GLIB_COMPILATION G_LOG_DOMAIN="GLib" LIBDIR="")
if (NOT BUILD_SHARED_LIBS)
target_compile_definitions(glib PUBLIC GLIB_STATIC_COMPILATION)
endif()
target_link_libraries(glib PRIVATE ${PCRE_LIBRARY} Iconv::Iconv ${Intl_LIBRARIES})
if(WIN32)
target_compile_definitions(glib PRIVATE USE_SYSTEM_PCRE)
Expand Down Expand Up @@ -169,6 +176,9 @@ list(APPEND GLIB_TARGETS gthread)
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")
if (NOT BUILD_SHARED_LIBS)
target_compile_definitions(gobject PUBLIC GOBJECT_STATIC_COMPILATION)
endif()
target_link_libraries(gobject PRIVATE gthread glib ${FFI_LIBRARY})
target_include_directories(gobject PRIVATE ${FFI_INCLUDE_DIR} PUBLIC $<INSTALL_INTERFACE:include>)
list(APPEND GLIB_TARGETS gobject)
Expand Down
2 changes: 1 addition & 1 deletion ports/glib/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: glib
Version: 2.52.3
Port-Version: 23
Port-Version: 24
Homepage: https://developer.gnome.org/glib/
Description: Portable, general-purpose utility library.
Build-Depends: zlib, pcre, libffi, gettext, libiconv
Expand Down
1 change: 1 addition & 0 deletions ports/glib/cmake/unofficial-glib-config.in.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include(CMakeFindDependencyMacro)
find_dependency(Iconv)
find_dependency(ZLIB)
if(NOT WIN32)
find_dependency(Threads)
endif()
Expand Down
55 changes: 55 additions & 0 deletions ports/glib/disable-export-dllmain-on-static.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/glib/glib-init.c b/glib/glib-init.c
index 30a9654..31723d7 100644
--- a/glib/glib-init.c
+++ b/glib/glib-init.c
@@ -275,12 +275,14 @@ glib_init (void)

#if defined (G_OS_WIN32)

+HMODULE glib_dll;
+
+#if defined (DLL_EXPORT)
+
BOOL WINAPI DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved);

-HMODULE glib_dll;
-
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
@@ -317,6 +319,7 @@ DllMain (HINSTANCE hinstDLL,

return TRUE;
}
+#endif

#elif defined (G_HAS_CONSTRUCTORS)

diff --git a/glib/gutils.h b/glib/gutils.h
index f84fbcb..94c893e 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -330,7 +330,7 @@ void g_abort (void) G_GNUC_NORETURN G_ANALYZER_NORETURN;

#ifndef G_PLATFORM_WIN32
# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
-#else
+#elif defined (DLL_EXPORT)
# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \
static char *dll_name; \
\
diff --git a/gobject/gtype.c b/gobject/gtype.c
index f381a78..95b6dbd 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -4451,7 +4451,7 @@ gobject_init (void)
_g_signal_init ();
}

-#if defined (G_OS_WIN32)
+#if defined (G_OS_WIN32) && defined (DLL_EXPORT)

BOOL WINAPI DllMain (HINSTANCE hinstDLL,
DWORD fdwReason,
6 changes: 1 addition & 5 deletions ports/glib/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Glib uses winapi functions not available in WindowsStore
vcpkg_fail_port_install(ON_TARGET "UWP")

# Glib relies on DllMain on Windows
if (VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
endif()

set(GLIB_VERSION 2.52.3)
vcpkg_download_distfile(ARCHIVE
URLS "https://ftp.gnome.org/pub/gnome/sources/glib/2.52/glib-${GLIB_VERSION}.tar.xz"
Expand All @@ -20,6 +15,7 @@ vcpkg_extract_source_archive_ex(
use-libiconv-on-windows.patch
arm64-defines.patch
fix-arm-builds.patch
disable-export-dllmain-on-static.patch
)

configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt ${SOURCE_PATH}/CMakeLists.txt COPYONLY)
Expand Down
18 changes: 6 additions & 12 deletions ports/glibmm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@ project(glibmm)

set(CMAKE_CXX_STANDARD 17)

find_path(GLIB_INCLUDE_DIR NAMES glib.h)
find_library(GLIB_LIBRARY NAMES glib-2.0)
find_library(GIO_LIBRARY NAMES gio-2.0)
find_library(GOBJECT_LIBRARY NAMES gobject-2.0)
find_library(GMODULE_LIBRARY NAMES gmodule-2.0)
find_library(GTHREAD_LIBRARY NAMES gthread-2.0)
find_package(unofficial-glib CONFIG REQUIRED)
find_program(GLIB_COMPILE_SCHEMAS NAMES glib-compile-schemas)
find_library(PCRE_LIBRARY NAMES pcre)
find_library(SIGC_LIBRARY NAMES sigc-2.0)
find_library(FFI_LIBRARY NAMES ffi libffi)

include_directories(${GLIB_INCLUDE_DIR})
link_libraries(
${GIO_LIBRARY}
${GOBJECT_LIBRARY}
${GMODULE_LIBRARY}
${GTHREAD_LIBRARY}
${GLIB_LIBRARY}
unofficial::glib::gio
unofficial::glib::glib
unofficial::glib::gmodule
unofficial::glib::gobject
unofficial::glib::gthread
${PCRE_LIBRARY}
${SIGC_LIBRARY}
${FFI_LIBRARY}
Expand Down
2 changes: 1 addition & 1 deletion ports/glibmm/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: glibmm
Version: 2.52.1
Port-Version: 12
Port-Version: 13
Description: This is glibmm, a C++ API for parts of glib that are useful for C++.
Homepage: https://www.gtkmm.org.
Build-Depends: zlib, pcre, libffi, gettext, libiconv, glib, libsigcpp
Expand Down
2 changes: 1 addition & 1 deletion ports/lcm/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: lcm
Version: 1.4.0
Port-Version: 1
Port-Version: 2
Build-Depends: glib
Homepage: https://github.com/lcm-proj/lcm
Description: Lightweight Communications and Marshalling (LCM)
Expand Down
83 changes: 83 additions & 0 deletions ports/lcm/only-build-one-target.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da3bfc5..d95c5a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,10 @@ include(lcm-cmake/config.cmake NO_POLICY_SCOPE)
include(lcm-cmake/functions.cmake)
include(lcm-cmake/version.cmake)

+if (NOT BUILD_SHARED_LIBS)
+ add_definitions(-DLCM_PYTHON)
+endif()
+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (WIN32)
add_definitions(-DWIN32 -D_CRT_SECURE_NO_WARNINGS)
diff --git a/lcm-python/CMakeLists.txt b/lcm-python/CMakeLists.txt
index 9246575..aedf4f4 100644
--- a/lcm-python/CMakeLists.txt
+++ b/lcm-python/CMakeLists.txt
@@ -29,7 +29,7 @@ target_include_directories(lcm-python PRIVATE
)

target_link_libraries(lcm-python PRIVATE
- lcm-static
+ lcm
)

if(APPLE)
diff --git a/lcm/CMakeLists.txt b/lcm/CMakeLists.txt
index 414a90d..d92de46 100644
--- a/lcm/CMakeLists.txt
+++ b/lcm/CMakeLists.txt
@@ -23,8 +23,10 @@ set(lcm_install_headers
lcm_version.h
lcm-cpp.hpp
lcm-cpp-impl.hpp
- ${CMAKE_CURRENT_BINARY_DIR}/lcm_export.h
)
+if (BUILD_SHARED_LIBS)
+ list(APPEND lcm_install_headers ${CMAKE_CURRENT_BINARY_DIR}/lcm_export.h)
+endif()

if(WIN32)
list(APPEND lcm_sources
@@ -39,10 +41,9 @@ endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_library(lcm-coretypes INTERFACE)
-add_library(lcm-static STATIC ${lcm_sources})
-add_library(lcm SHARED ${lcm_sources})
+add_library(lcm ${lcm_sources})

-foreach(lcm_lib lcm lcm-static)
+foreach(lcm_lib lcm)
target_compile_definitions(${lcm_lib} PRIVATE
_FILE_OFFSET_BITS=64
_LARGEFILE_SOURCE
@@ -67,21 +68,16 @@ foreach(lcm_lib lcm lcm-static)
endif()
endforeach()

+if (BUILD_SHARED_LIBS)
generate_export_header(lcm STATIC_DEFINE LCM_STATIC)
-
-target_compile_definitions(lcm-static PUBLIC LCM_STATIC)
-if(NOT WIN32)
- set_target_properties(lcm-static PROPERTIES OUTPUT_NAME lcm)
+else()
+target_compile_definitions(lcm PUBLIC LCM_STATIC)
endif()

target_include_directories(lcm-coretypes INTERFACE
$<BUILD_INTERFACE:${lcm_SOURCE_DIR}>
)
-if(BUILD_SHARED_LIBS)
- set(INSTALL_TARGETS lcm)
-else()
- set(INSTALL_TARGETS lcm-static)
-endif()
+set(INSTALL_TARGETS lcm)
install(TARGETS lcm-coretypes ${INSTALL_TARGETS}
EXPORT lcmTargets
RUNTIME DESTINATION bin
1 change: 1 addition & 0 deletions ports/lcm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ vcpkg_from_github(
only-install-one-flavor.patch
fix-build-error.patch
fix-linux-build.patch
only-build-one-target.patch
)

vcpkg_configure_cmake(
Expand Down
4 changes: 2 additions & 2 deletions ports/libxmlpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 17)
find_path(GLIBMM_INCLUDE_DIR NAMES glibmm.h)
find_library(GLIBMM_LIBRARY NAMES glibmm)
find_library(GIOMM_LIBRARY NAMES giomm)
find_library(GLIB_LIBRARY NAMES glib glib-2.0)
find_package(unofficial-glib CONFIG REQUIRED)
find_library(GIO_LIBRARY NAMES gio gio-2.0)
find_library(GMODULE_LIBRARY NAMES gmodule gmodule-2.0)
find_library(GOBJECT_LIBRARY NAMES gobject gobject-2.0)
Expand Down Expand Up @@ -37,7 +37,7 @@ link_libraries(
${GMODULE_LIBRARY}
${GOBJECT_LIBRARY}
${GIO_LIBRARY}
${GLIB_LIBRARY}
unofficial::glib::glib
${SIGCPP_LIBRARY}
${FFI_LIBRARY}
${LIBXML2_LIBRARIES}
Expand Down
2 changes: 1 addition & 1 deletion ports/libxmlpp/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: libxmlpp
Version: 2.40.1
Port-Version: 6
Port-Version: 7
Description: a C++ wrapper for the libxml XML parser library.
Build-Depends: libxml2, glibmm
1 change: 1 addition & 0 deletions ports/openscap/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: openscap
Version: 1.3.1
Port-Version: 1
Homepage: https://github.com/OpenSCAP/openscap
Description: The oscap program is a command line tool that allows users to load, scan, validate, edit, and export SCAP documents.
Build-Depends: libxslt, libxml2, libzip, curl, pcre2, libpopt, pthread, glib, openssl, zlib
Expand Down
3 changes: 3 additions & 0 deletions ports/openscap/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Force to set SHARED to add_library on its CMakeLists.txt
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO OpenSCAP/openscap
Expand Down
4 changes: 2 additions & 2 deletions ports/pango/CONTROL
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: pango
Version: 1.40.11
Port-Version: 8
Port-Version: 9
Homepage: https://ftp.gnome.org/pub/GNOME/sources/pango/
Description: Text and font handling library.
Build-Depends: glib, gettext, cairo[gobject], fontconfig, freetype, harfbuzz[glib] (!(windows&static)&!osx)
Build-Depends: glib, gettext, cairo[gobject], fontconfig, freetype, harfbuzz[glib]
Loading