Merge pull request #1318 from codicodi/utf8proc

[utf8proc] new port
This commit is contained in:
Robert Schumacher 2017-06-20 14:52:54 -07:00 committed by GitHub
commit 1bebd8d40d
3 changed files with 79 additions and 0 deletions

3
ports/utf8proc/CONTROL Normal file
View File

@ -0,0 +1,3 @@
Source: utf8proc
Version: 2.1.0
Description: Clean C library for processing UTF-8 Unicode data.

View File

@ -0,0 +1,48 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index be676ba..7a2b6d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,9 +13,9 @@ set(SO_MAJOR 2)
set(SO_MINOR 1)
set(SO_PATCH 0)
-add_definitions (
- -DUTF8PROC_EXPORTS
-)
+if(BUILD_SHARED_LIBS)
+ add_definitions(-DUTF8PROC_EXPORTS -DUTF8PROC_SHARED)
+endif()
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=c99 -pedantic -Wall")
@@ -31,3 +31,10 @@ set_target_properties (utf8proc PROPERTIES
VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}"
SOVERSION ${SO_MAJOR}
)
+
+install(TARGETS utf8proc
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib)
+
+install(FILES utf8proc.h DESTINATION include)
diff --git a/utf8proc.h b/utf8proc.h
index edf46d4..7b3f11a 100644
--- a/utf8proc.h
+++ b/utf8proc.h
@@ -120,13 +120,13 @@ typedef bool utf8proc_bool;
#endif
#include <limits.h>
-#ifdef _WIN32
+#if defined _WIN32 && defined UTF8PROC_SHARED
# ifdef UTF8PROC_EXPORTS
# define UTF8PROC_DLLEXPORT __declspec(dllexport)
# else
# define UTF8PROC_DLLEXPORT __declspec(dllimport)
# endif
-#elif __GNUC__ >= 4
+#elif __GNUC__ >= 4 && defined UTF8PROC_SHARED
# define UTF8PROC_DLLEXPORT __attribute__ ((visibility("default")))
#else
# define UTF8PROC_DLLEXPORT

View File

@ -0,0 +1,28 @@
include(vcpkg_common_functions)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO JuliaLang/utf8proc
REF v2.1.0
SHA512 72b7f377fa6a62018d3eeab8723a27e25db3d1f794ae0bf21fff62ec1a7439bec52e7c93d2a00c218de6ff518097fb4a7a87c56e61ba8c98e689aa8f7171c812)
vcpkg_apply_patches(SOURCE_PATH ${SOURCE_PATH}
PATCHES ${CMAKE_CURRENT_LIST_DIR}/fix-buildsystem.patch)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(READ ${CURRENT_PACKAGES_DIR}/include/utf8proc.h UTF8PROC_H)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
string(REPLACE "defined UTF8PROC_SHARED" "0" UTF8PROC_H "${UTF8PROC_H}")
else()
string(REPLACE "defined UTF8PROC_SHARED" "1" UTF8PROC_H "${UTF8PROC_H}")
endif()
file(WRITE ${CURRENT_PACKAGES_DIR}/include/utf8proc.h "${UTF8PROC_H}")
file(COPY ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/utf8proc)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/utf8proc/LICENSE.md ${CURRENT_PACKAGES_DIR}/share/utf8proc/copyright)