mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 14:43:04 +08:00
[libiconv] Make built libraries relocatable (#9229)
This is required to build libintl (gettext) with iconv support (see #8484). Also updated to the latest version 1.16.
This commit is contained in:
parent
2c7ff757a1
commit
9d706789ce
@ -1,34 +0,0 @@
|
|||||||
diff --git "a/include/iconv.h.build.in" "b/include/iconv.h.build.in"
|
|
||||||
index 0feb068..74e5613 100644
|
|
||||||
--- "a/include/iconv.h.build.in"
|
|
||||||
+++ "b/include/iconv.h.build.in"
|
|
||||||
@@ -27,6 +27,12 @@
|
|
||||||
#define LIBICONV_DLL_EXPORTED __attribute__((__visibility__("default")))
|
|
||||||
+#elif defined(_WIN32) && @LIBICONV_DYNAMIC@
|
|
||||||
+ #if defined(libiconv_EXPORTS)
|
|
||||||
+ #define LIBICONV_DLL_EXPORTED __declspec(dllexport)
|
|
||||||
+ #else
|
|
||||||
+ #define LIBICONV_DLL_EXPORTED __declspec(dllimport)
|
|
||||||
+ #endif
|
|
||||||
#else
|
|
||||||
#define LIBICONV_DLL_EXPORTED
|
|
||||||
#endif
|
|
||||||
extern LIBICONV_DLL_EXPORTED @DLL_VARIABLE@ int _libiconv_version; /* Likewise */
|
|
||||||
|
|
||||||
diff --git "a/libcharset/include/localcharset.h.build.in" "b/libcharset/include/localcharset.h.build.in"
|
|
||||||
index c691359..2a23585 100644
|
|
||||||
--- "a/libcharset/include/localcharset.h.build.in"
|
|
||||||
+++ "b/libcharset/include/localcharset.h.build.in"
|
|
||||||
@@ -24,6 +24,12 @@
|
|
||||||
#define LIBCHARSET_DLL_EXPORTED __attribute__((__visibility__("default")))
|
|
||||||
+#elif defined(_WIN32) && @LIBICONV_DYNAMIC@
|
|
||||||
+ #if defined(libcharset_EXPORTS)
|
|
||||||
+ #define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)
|
|
||||||
+ #else
|
|
||||||
+ #define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)
|
|
||||||
+ #endif
|
|
||||||
#else
|
|
||||||
#define LIBCHARSET_DLL_EXPORTED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
12
ports/libiconv/0003-Add-export.patch
Normal file
12
ports/libiconv/0003-Add-export.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
diff -uNr libiconv-1.16/libcharset/include/libcharset.h.in libiconv-1.16-work/libcharset/include/libcharset.h.in
|
||||||
|
--- libiconv-1.16/libcharset/include/libcharset.h.in 2018-09-17 19:07:42.000000000 +0300
|
||||||
|
+++ libiconv-1.16-work/libcharset/include/libcharset.h.in 2019-12-04 17:15:50.000000000 +0300
|
||||||
|
@@ -33,7 +33,7 @@
|
||||||
|
by the corresponding pathname with the current prefix instead. Both
|
||||||
|
prefixes should be directory names without trailing slash (i.e. use ""
|
||||||
|
instead of "/"). */
|
||||||
|
-extern void libcharset_set_relocation_prefix (const char *orig_prefix,
|
||||||
|
+extern void LIBCHARSET_DLL_EXPORTED libcharset_set_relocation_prefix (const char *orig_prefix,
|
||||||
|
const char *curr_prefix);
|
||||||
|
|
||||||
|
|
@ -25,10 +25,31 @@ if(WIN32)
|
|||||||
string(REPLACE "#undef ICONV_CONST" "#define ICONV_CONST const" _contents "${_contents}")
|
string(REPLACE "#undef ICONV_CONST" "#define ICONV_CONST const" _contents "${_contents}")
|
||||||
string(REPLACE "#undef EILSEQ" "" _contents "${_contents}")
|
string(REPLACE "#undef EILSEQ" "" _contents "${_contents}")
|
||||||
string(REPLACE "#undef WORDS_LITTLEENDIAN" "#define WORDS_LITTLEENDIAN 1" _contents "${_contents}")
|
string(REPLACE "#undef WORDS_LITTLEENDIAN" "#define WORDS_LITTLEENDIAN 1" _contents "${_contents}")
|
||||||
|
string(REPLACE "#undef ENABLE_RELOCATABLE" "#define ENABLE_RELOCATABLE 1" _contents "${_contents}")
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" "${_contents}")
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/config.h" "${_contents}")
|
||||||
|
|
||||||
configure_file(libcharset/include/localcharset.h.build.in localcharset.h)
|
configure_file(libcharset/include/localcharset.h.build.in localcharset.h)
|
||||||
|
configure_file(libcharset/include/libcharset.h.in libcharset.h)
|
||||||
configure_file(include/iconv.h.build.in iconv.h)
|
configure_file(include/iconv.h.build.in iconv.h)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(/wd4018)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_definitions(
|
||||||
|
-D_CRT_SECURE_NO_WARNINGS
|
||||||
|
-DLIBDIR=${LIBDIR}
|
||||||
|
-DINSTALLDIR=${INSTALLDIR}
|
||||||
|
-DNO_XMALLOC=1
|
||||||
|
-DENABLE_RELOCATABLE=1
|
||||||
|
-DIN_LIBRARY=1
|
||||||
|
)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
add_definitions(
|
||||||
|
-DBUILDING_LIBCHARSET=1
|
||||||
|
-DBUILDING_LIBICONV=1
|
||||||
|
-DBUILDING_DLL=1)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
set(STATIC_SHARED --enable-shared --disable-static)
|
set(STATIC_SHARED --enable-shared --disable-static)
|
||||||
@ -43,19 +64,23 @@ else()
|
|||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/autoconf
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/autoconf
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_BINARY_DIR}/autoconf/config.h config.h @ONLY)
|
configure_file(${CMAKE_CURRENT_BINARY_DIR}/autoconf/lib/config.h config.h @ONLY)
|
||||||
configure_file(${CMAKE_CURRENT_BINARY_DIR}/autoconf/include/iconv.h iconv.h @ONLY)
|
configure_file(${CMAKE_CURRENT_BINARY_DIR}/autoconf/include/iconv.h iconv.h @ONLY)
|
||||||
configure_file(${CMAKE_CURRENT_BINARY_DIR}/autoconf/libcharset/include/localcharset.h localcharset.h @ONLY)
|
configure_file(${CMAKE_CURRENT_BINARY_DIR}/autoconf/libcharset/include/localcharset.h localcharset.h @ONLY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_definitions(-DLIBDIR -D_CRT_SECURE_NO_WARNINGS)
|
add_library(libcharset libcharset/lib/localcharset.c libcharset/lib/relocatable-stub.c)
|
||||||
|
|
||||||
add_library(libcharset libcharset/lib/localcharset.c)
|
|
||||||
target_include_directories(libcharset PUBLIC $<INSTALL_INTERFACE:include>)
|
target_include_directories(libcharset PUBLIC $<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
add_library(libiconv lib/iconv.c)
|
add_library(libiconv lib/iconv.c lib/relocatable.c)
|
||||||
|
if(WIN32)
|
||||||
|
target_compile_definitions(libiconv PRIVATE
|
||||||
|
-Dset_relocation_prefix=libiconv_set_relocation_prefix
|
||||||
|
-Drelocate=libiconv_relocate -Drelocate2=libiconv_relocate2
|
||||||
|
)
|
||||||
|
endif()
|
||||||
target_link_libraries(libiconv PRIVATE libcharset)
|
target_link_libraries(libiconv PRIVATE libcharset)
|
||||||
target_include_directories(libiconv PUBLIC $<INSTALL_INTERFACE:include>)
|
target_include_directories(libiconv PUBLIC $<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Source: libiconv
|
Source: libiconv
|
||||||
Version: 1.15-6
|
Version: 1.16-1
|
||||||
Homepage: https://www.gnu.org/software/libiconv/
|
Homepage: https://www.gnu.org/software/libiconv/
|
||||||
Description: GNU Unicode text conversion
|
Description: GNU Unicode text conversion
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
if(NOT VCPKG_TARGET_IS_WINDOWS)
|
||||||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
||||||
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/unofficial-iconv)
|
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/unofficial-iconv)
|
||||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/unofficial-iconv-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/unofficial-iconv)
|
file(COPY ${CMAKE_CURRENT_LIST_DIR}/unofficial-iconv-config.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/unofficial-iconv)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(vcpkg_common_functions)
|
set(LIBICONV_VERSION 1.16)
|
||||||
|
|
||||||
set(LIBICONV_VERSION 1.15)
|
|
||||||
|
|
||||||
vcpkg_download_distfile(ARCHIVE
|
vcpkg_download_distfile(ARCHIVE
|
||||||
URLS "https://ftp.gnu.org/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz" "https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz"
|
URLS "https://ftp.gnu.org/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz" "https://www.mirrorservice.org/sites/ftp.gnu.org/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz"
|
||||||
FILENAME "libiconv-${LIBICONV_VERSION}.tar.gz"
|
FILENAME "libiconv-${LIBICONV_VERSION}.tar.gz"
|
||||||
SHA512 1233fe3ca09341b53354fd4bfe342a7589181145a1232c9919583a8c9979636855839049f3406f253a9d9829908816bb71fd6d34dd544ba290d6f04251376b1a
|
SHA512 365dac0b34b4255a0066e8033a8b3db4bdb94b9b57a9dca17ebf2d779139fe935caf51a465d17fd8ae229ec4b926f3f7025264f37243432075e5583925bb77b7
|
||||||
)
|
)
|
||||||
vcpkg_extract_source_archive_ex(
|
vcpkg_extract_source_archive_ex(
|
||||||
OUT_SOURCE_PATH SOURCE_PATH
|
OUT_SOURCE_PATH SOURCE_PATH
|
||||||
ARCHIVE ${ARCHIVE}
|
ARCHIVE ${ARCHIVE}
|
||||||
REF ${LIBICONV_VERSION}
|
REF ${LIBICONV_VERSION}
|
||||||
PATCHES
|
PATCHES
|
||||||
0001-Add-export-definitions.patch
|
|
||||||
0002-Config-for-MSVC.patch
|
0002-Config-for-MSVC.patch
|
||||||
|
0003-Add-export.patch
|
||||||
)
|
)
|
||||||
|
|
||||||
#Since libiconv uses automake, make and configure, we use a custom CMake file
|
#Since libiconv uses automake, make and configure, we use a custom CMake file
|
||||||
@ -29,6 +27,7 @@ file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
|||||||
vcpkg_configure_cmake(
|
vcpkg_configure_cmake(
|
||||||
SOURCE_PATH ${SOURCE_PATH}
|
SOURCE_PATH ${SOURCE_PATH}
|
||||||
PREFER_NINJA
|
PREFER_NINJA
|
||||||
|
OPTIONS -DINSTALLDIR=\"\" -DLIBDIR=\"\"
|
||||||
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
|
OPTIONS_DEBUG -DDISABLE_INSTALL_HEADERS=ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user