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

add libiconv port #118

Merged
merged 1 commit into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all 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
128 changes: 128 additions & 0 deletions ports/libiconv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
##
## CMake support for libiconv
## based on the work here: https://github.com/vovythevov/libiconv-cmake
##

cmake_minimum_required(VERSION 3.0.0)
project(Libiconv)

#
# Options
#
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries, Always ON since this code is LGPL" FORCE)

# Config file
configure_file(
${Libiconv_SOURCE_DIR}/new_config.h.in
${Libiconv_BINARY_DIR}/config.h
)
include_directories(${Libiconv_SOURCE_DIR} ${Libiconv_BINARY_DIR})

macro(header_injection_hack)
include(CMakeParseArguments)
set(options)
set(oneValueArgs LIBRARY_NAME INPUT OUTPUT)
set(multiValueArgs)
cmake_parse_arguments(hack
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}
)
string(TOUPPER ${hack_LIBRARY_NAME} hack_library_name_upper)
set(HAVE_VISIBILITY
"WIN32
#if defined(${hack_LIBRARY_NAME}_EXPORTS)
#define ${hack_library_name_upper}_DLL_EXPORTED __declspec(dllexport)
#else
#define ${hack_library_name_upper}_DLL_EXPORTED __declspec(dllimport)
#endif
#elif true"
)
configure_file(
${hack_INPUT}
${hack_OUTPUT}
)
endmacro()
#
# Build libcharset
#
set(libname libcharset)
set(libcharset_source_dir ${Libiconv_SOURCE_DIR}/libcharset)

if(WIN32)
add_definitions(-DLIBDIR)
endif()

# Hack: to be able to configure the localcharset.h.build.in correctly, we
# inject code in the variable have visibility
header_injection_hack(
LIBRARY_NAME ${libname}
INPUT ${Libiconv_SOURCE_DIR}/libcharset/include/localcharset.h.build.in
OUTPUT ${Libiconv_BINARY_DIR}/localcharset.h
)

set(${libname}_sources
${libcharset_source_dir}/lib/relocatable.c
${libcharset_source_dir}/lib/relocatable.h
${libcharset_source_dir}/lib/localcharset.c
${Libiconv_BINARY_DIR}/localcharset.h
)

add_library(${libname} ${${libname}_sources})
list(APPEND Libiconv_TARGETS ${libname})
list(APPEND Libiconv_headers ${Libiconv_BINARY_DIR}/localcharset.h)

#
# Build libiconv
#
set(libname libiconv)

# Hack: same hack than for libcharset
set(HAVE_WCHAR_T "HAVE_WCHAR_T")
set(USE_MBSTATE_T "USE_MBSTATE_T")
set(BROKEN_WCHAR_H "BROKEN_WCHAR_H")

header_injection_hack(
LIBRARY_NAME ${libname}
INPUT ${Libiconv_SOURCE_DIR}/include/iconv.h.build.in
OUTPUT ${Libiconv_BINARY_DIR}/iconv.h
)

list(APPEND simple_header_config
uniwidth
unitypes
)
foreach(header ${simple_header_config})
configure_file(
${Libiconv_SOURCE_DIR}/srclib/${header}.in.h
${Libiconv_BINARY_DIR}/${header}.h
)
endforeach()

set(${libname}_sources
${Libiconv_SOURCE_DIR}/lib/iconv.c
${Libiconv_BINARY_DIR}/iconv.h
)

add_library(${libname} ${${libname}_sources})
target_link_libraries(${libname} libcharset)
list(APPEND Libiconv_TARGETS ${libname})
list(APPEND Libiconv_headers ${Libiconv_BINARY_DIR}/iconv.h)

#
# Export targets
#
install(TARGETS ${Libiconv_TARGETS}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

install(FILES ${Libiconv_headers} DESTINATION include)

set(Libiconv_TARGETS_FILE ${Libiconv_BINARY_DIR}/LibiconvTargets.cmake)
export(TARGETS ${Libiconv_TARGETS} FILE ${Libiconv_TARGETS_FILE})

configure_file(
${Libiconv_SOURCE_DIR}/LibiconvConfig.cmake.in
${Libiconv_BINARY_DIR}/LibiconvConfig.cmake
@ONLY
)
3 changes: 3 additions & 0 deletions ports/libiconv/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Source: libiconv
Version: 1.14
Description: GNU Unicode text conversion
12 changes: 12 additions & 0 deletions ports/libiconv/LibiconvConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Use file for libiconv. Auto-generated, any change here might be overwritten
# without any warning.
#

set(Libiconv_SOURCE_DIR "@Libiconv_SOURCE_DIR@")
set(Libiconv_BINARY_DIR "@Libiconv_BINARY_DIR@")
set(Libiconv_LIBRARIES "@Libiconv_TARGETS@")

if(EXISTS "@Libiconv_TARGETS_FILE@" AND NOT TARGET libcharset)
include("@Libiconv_TARGETS_FILE@")
endif()
Loading