diff --git a/CMakeLists.txt b/CMakeLists.txt index ad32ffc..e3df71c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b36fd0..42574ce 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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