Add a BUILD_STATIC CMake option to optionally build a static library.

It is still ON by default, which means both shared and static libs will
be built and installed (current behavior), but it makes it possible to
disable the build of a static lib.
Closes https://github.com/BYVoid/uchardet/issues/1.
This commit is contained in:
Jehan 2015-11-17 18:12:44 +01:00
parent 9172b763d1
commit ad4dfc4be4
2 changed files with 29 additions and 12 deletions

View File

@ -59,6 +59,9 @@ set (DIR_SHARE_LOCALE ${DIR_SHARE}/locale)
######## Configuration
option(BUILD_STATIC "Build static library"
ON)
configure_file(
uchardet.pc.in
uchardet.pc

View File

@ -51,15 +51,16 @@ add_library(
${UCHARDET_SOURCES}
)
add_library(
${UCHARDET_STATIC_TARGET}
STATIC
${UCHARDET_SOURCES}
)
if (BUILD_STATIC)
add_library(
${UCHARDET_STATIC_TARGET}
STATIC
${UCHARDET_SOURCES}
)
endif (BUILD_STATIC)
set_target_properties(
${UCHARDET_TARGET}
${UCHARDET_STATIC_TARGET}
PROPERTIES
LINKER_LANGUAGE
CXX
@ -71,6 +72,17 @@ set_target_properties(
0
)
if (BUILD_STATIC)
set_target_properties(
${UCHARDET_STATIC_TARGET}
PROPERTIES
LINKER_LANGUAGE
CXX
OUTPUT_NAME
uchardet
)
endif (BUILD_STATIC)
if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(
-O0
@ -96,12 +108,14 @@ install(
)
endif (NOT WIN32)
install(
TARGETS
${UCHARDET_STATIC_TARGET}
ARCHIVE DESTINATION
${DIR_LIBRARY_STATIC}
)
if (BUILD_STATIC)
install(
TARGETS
${UCHARDET_STATIC_TARGET}
ARCHIVE DESTINATION
${DIR_LIBRARY_STATIC}
)
endif (BUILD_STATIC)
install(
FILES