Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
made cmake process less invasive.
Browse files Browse the repository at this point in the history
All configured headers will now be configured to the build directory
  • Loading branch information
sykmschmieder committed Dec 10, 2016
1 parent 274016c commit 4ea7a23
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 40 deletions.
58 changes: 35 additions & 23 deletions CMakeLists.txt
Expand Up @@ -11,36 +11,42 @@ include ( configure )

# Options
option ( ENABLE_EXTRA "Enable a few rarely used encodings" OFF)
option ( ENABLE_NLS "Translation of program messages to the user's native
language is requested" OFF)
option ( ENABLE_NLS "Translation of program messages to the user's native language is requested" OFF)
#option ( ENABLE_RELOCATABLE "The package shall run at any location in the file system" ON )

# iconv.h
set ( USE_MBSTATE_T 1 )
set ( BROKEN_WCHAR_H 0 )
set ( HAVE_WCHAR_T 0)

configure_file ( config.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h )
# setup default include directories
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)

if(MSVC)
iconv_configure_file (LIBRARY_NAME libiconv
INPUT include/iconv.h.build.in
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/iconv.h )
configure_file ( config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )

iconv_configure_file (LIBRARY_NAME libcharset
INPUT libcharset/include/libcharset.h.in
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/libcharset.h )

configure_file (srclib/alloca.in.h ${CMAKE_CURRENT_SOURCE_DIR}/srclib/alloca.h )
configure_file (srclib/unistd.in.h ${CMAKE_CURRENT_SOURCE_DIR}/srclib/unistd.h @ONLY)
else()
configure_file (include/iconv.h.build.in ${CMAKE_CURRENT_SOURCE_DIR}/include/iconv.h )
configure_file (libcharset/include/libcharset.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/libcharset.h )
endif()
iconv_configure_file (LIBRARY_NAME libiconv
INPUT include/iconv.h.build.in
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/iconv.h )

iconv_configure_file (LIBRARY_NAME libiconv
INPUT srclib/alloca.in.h
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/srclib/alloca.h )

iconv_configure_file (LIBRARY_NAME libiconv
INPUT include/iconv.h.build.in
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/iconv.h )

configure_file (srclib/uniwidth.in.h ${CMAKE_CURRENT_SOURCE_DIR}/srclib/uniwidth.h )
configure_file (srclib/unitypes.in.h ${CMAKE_CURRENT_SOURCE_DIR}/srclib/unitypes.h )
iconv_configure_file (LIBRARY_NAME libiconv
INPUT srclib/unistd.in.h
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/srclib/unistd.h)

iconv_configure_file (LIBRARY_NAME libiconv
INPUT srclib/unitypes.in.h
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/srclib/unitypes.h )

iconv_configure_file (LIBRARY_NAME libcharset
INPUT libcharset/include/libcharset.h.in
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/libcharset.h )

# Dirty fix for MinGW
if ( MINGW )
Expand All @@ -49,16 +55,21 @@ if ( MINGW )
endif ()

include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} include srclib )
add_definitions ( -Dset_relocation_prefix=libcharset_set_relocation_prefix -Drelocate=libcharset_relocate -DHAVE_CONFIG_H -DINSTALLPREFIX=NULL -DNO_XMALLOC -DBUILDING_LIBCHARSET -DINSTALLDIR="" -DLIBDIR="" -DENABLE_RELOCATABLE=1 -DBUILDING_DLL -DIN_LIBRARY )
add_definitions ( -Dset_relocation_prefix=libcharset_set_relocation_prefix -Drelocate=libcharset_relocate -DHAVE_CONFIG_H -DINSTALLPREFIX=NULL -DNO_XMALLOC -DBUILDING_LIBCHARSET -DINSTALLDIR="" -DLIBDIR="" -DENABLE_RELOCATABLE=1 -DIN_LIBRARY )

# libcharset
set ( SRC_LIBCHARSET
libcharset/lib/localcharset.c
libcharset/lib/relocatable.c
)

add_library ( charset STATIC ${SRC_LIBCHARSET} )
set_target_properties ( charset PROPERTIES COMPILE_FLAGS -DBUILDING_LIBCHARSET)
if (MSVC)
add_library ( charset STATIC ${SRC_LIBCHARSET} )
else()
add_library ( charset ${SRC_LIBCHARSET} )
target_compile_options(charset PRIVATE -DBUILDING_DLL)
endif()
target_compile_options ( charset PRIVATE -DBUILDING_LIBCHARSET)

if (NOT MSVC)
# libicrt
Expand Down Expand Up @@ -101,5 +112,6 @@ if(NOT MSVC)
endif()

install_library ( iconv charset )
install_header ( include/iconv.h )
install_header ( ${CMAKE_CURRENT_BINARY_DIR}/include/iconv.h )
install_header ( ${CMAKE_CURRENT_BINARY_DIR}/include/libcharset.h )
install_data ( README AUTHORS COPYING )
25 changes: 12 additions & 13 deletions cmake/dist.cmake
Expand Up @@ -328,18 +328,17 @@ macro(iconv_configure_file)
set(multiValueArgs)
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

string(TOUPPER ${arg_LIBRARY_NAME} arg_library_name_upper)
set(HAVE_VISIBILITY
"WIN32
#if defined(${arg_LIBRARY_NAME}_EXPORTS)
#define ${arg_library_name_upper}_DLL_EXPORTED __declspec(dllexport)
#else
#define ${arg_library_name_upper}_DLL_EXPORTED __declspec(dllimport)
#endif
#elif true"
)
configure_file(
${arg_INPUT}
${arg_OUTPUT}
if(MSVC)
string(TOUPPER ${arg_LIBRARY_NAME} arg_library_name_upper)
set(HAVE_VISIBILITY
"WIN32
#if defined(${arg_LIBRARY_NAME}_EXPORTS)
#define ${arg_library_name_upper}_DLL_EXPORTED __declspec(dllexport)
#else
#define ${arg_library_name_upper}_DLL_EXPORTED __declspec(dllimport)
#endif
#elif true"
)
endif()
configure_file(${arg_INPUT} ${arg_OUTPUT} @ONLY)
endmacro()
4 changes: 0 additions & 4 deletions libcharset/lib/relocatable.h
Expand Up @@ -32,11 +32,7 @@ extern "C" {
this is a private .h file, we don't need to use __declspec(dllimport)
in any case. */
#if HAVE_VISIBILITY && BUILDING_DLL
# if !_MSC_VER
# define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default")))
# else
# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
# endif
#elif defined _MSC_VER && BUILDING_DLL
# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
#else
Expand Down

0 comments on commit 4ea7a23

Please sign in to comment.