Browse Source

ability create static library

add msvc "/Wall"
pull/85/head
nicolaichuk 8 years ago
parent
commit
7f42070c0a
  1. 48
      CMakeLists.txt
  2. 12
      utf8proc.h

48
CMakeLists.txt

@ -13,19 +13,55 @@ set(SO_MAJOR 2)
set(SO_MINOR 0)
set(SO_PATCH 2)
add_definitions (
-DUTF8PROC_EXPORTS
)
# configure build type
set(_utf8proc_is_set_build_shared_libs TRUE)
if(DEFINED BUILD_SHARED_LIBS)
set(_utf8proc_is_set_build_shared_libs ${BUILD_SHARED_LIBS})
endif(DEFINED BUILD_SHARED_LIBS)
set(UTF8PROC_BUILD_AS_SHARED ${_utf8proc_is_set_build_shared_libs} CACHE BOOL "If present and true, this will cause utf8proc to be built shared unless the utf8proc was explicitly added as a static library.")
# set additional defined
if (NOT MSVC)
if(NOT DEFINED _utf8proc_additional_defined)
set(_utf8proc_additional_defined )
endif(NOT DEFINED _utf8proc_additional_defined)
if(UTF8PROC_BUILD_AS_SHARED)
list(APPEND _utf8proc_additional_defined
"-DUTF8PROC_EXPORTS"
)
set(_utf8proc_build_type "SHARED")
else(UTF8PROC_BUILD_AS_SHARED)
list(APPEND _utf8proc_additional_defined
"-DUTF8PROC_BUILD_AS_LIB"
)
set(_utf8proc_build_type "STATIC")
endif(UTF8PROC_BUILD_AS_SHARED)
list(REMOVE_DUPLICATES _utf8proc_additional_defined)
add_definitions("${_utf8proc_additional_defined}")
# other config
if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=c99 -pedantic -Wall")
endif ()
endif()
add_library (utf8proc
add_library (utf8proc ${_utf8proc_build_type}
utf8proc.c
utf8proc.h
)
if(MSVC)
get_target_property(_utf8proc_msvc_build_prop_val utf8proc COMPILE_FLAGS)
if(${_utf8proc_msvc_build_prop_val} STREQUAL "_utf8proc_msvc_build_prop_val-NOTFOUND")
set_target_properties(utf8proc PROPERTIES COMPILE_FLAGS "/Wall")
else(${_utf8proc_msvc_build_prop_val} STREQUAL "_utf8proc_msvc_build_prop_val-NOTFOUND")
set_target_properties(utf8proc PROPERTIES COMPILE_FLAGS "${_utf8proc_msvc_build_prop_val} /Wall")
endif(${_utf8proc_msvc_build_prop_val} STREQUAL "_utf8proc_msvc_build_prop_val-NOTFOUND")
endif()
set_target_properties (utf8proc PROPERTIES
POSITION_INDEPENDENT_CODE ON
VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}"

12
utf8proc.h

@ -113,16 +113,24 @@ typedef bool utf8proc_bool;
#endif
#include <limits.h>
#ifdef _WIN32
#ifndef UTF8PROC_BUILD_AS_LIB
# ifdef _WIN32
# ifdef UTF8PROC_EXPORTS
# define UTF8PROC_DLLEXPORT __declspec(dllexport)
# else
# define UTF8PROC_DLLEXPORT __declspec(dllimport)
# endif
#elif __GNUC__ >= 4
# elif defined(__GNUC__) && __GNUC__ >= 4
# define UTF8PROC_DLLEXPORT __attribute__ ((visibility("default")))
# else
# define UTF8PROC_DLLEXPORT
# endif
#else
# if defined(__GNUC__) && __GNUC__ >= 4
# define UTF8PROC_DLLEXPORT __attribute__ ((visibility("hidden")))
# else
# define UTF8PROC_DLLEXPORT
# endif
#endif
#ifdef __cplusplus

Loading…
Cancel
Save