Merge pull request #24 from wiiaboo/ab-suite

Improving build with more options.

Building only static possible, uchardet command line tool build can be disabled, bindir can be customized…
This commit is contained in:
Jehan 2016-03-17 19:09:30 +01:00
commit d255184609
5 changed files with 35 additions and 21 deletions

View File

@ -34,9 +34,11 @@ set (DIR_LIBRARY ${DIR_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX})
set (DIR_LIBRARY_STATIC ${DIR_PREFIX}/${CMAKE_STATIC_LIBRARY_PREFIX})
set (DIR_INCLUDE ${DIR_PREFIX}/include)
set (DIR_SHARE ${DIR_PREFIX}/share)
set (DIR_BIN ${DIR_PREFIX}/bin)
set (DIR_ETC ${DIR_PREFIX}/etc)
set (CMAKE_INSTALL_BINDIR bin
CACHE STRING "Install location of executables")
if (DEFINED CMAKE_INSTALL_LIBDIR)
set (DIR_LIBRARY ${CMAKE_INSTALL_LIBDIR})
set (DIR_LIBRARY_STATIC ${CMAKE_INSTALL_LIBDIR})
@ -59,7 +61,13 @@ set (DIR_SHARE_LOCALE ${DIR_SHARE}/locale)
######## Configuration
option(BUILD_STATIC "Build static library"
option(BUILD_SHARED_LIBS "Build shared library and link executable against it"
ON)
if (BUILD_SHARED_LIBS)
option(BUILD_STATIC "Build static library"
ON)
endif (BUILD_SHARED_LIBS)
option(BUILD_BINARY "Build executable"
ON)
configure_file(

View File

@ -43,7 +43,9 @@ set(
)
set (UCHARDET_TARGET libuchardet)
if (BUILD_STATIC AND BUILD_SHARED_LIBS)
set (UCHARDET_STATIC_TARGET libuchardet_static)
endif ()
add_definitions(
-DPKGDATADIR="${DIR_SHARE_OPENCC}"
@ -55,17 +57,16 @@ add_definitions(
add_library(
${UCHARDET_TARGET}
SHARED
${UCHARDET_SOURCES}
)
if (BUILD_STATIC)
if (UCHARDET_STATIC_TARGET)
add_library(
${UCHARDET_STATIC_TARGET}
STATIC
${UCHARDET_SOURCES}
)
endif (BUILD_STATIC)
endif (UCHARDET_STATIC_TARGET)
set_target_properties(
${UCHARDET_TARGET}
@ -80,7 +81,7 @@ set_target_properties(
0
)
if (BUILD_STATIC)
if (UCHARDET_STATIC_TARGET)
set_target_properties(
${UCHARDET_STATIC_TARGET}
PROPERTIES
@ -89,7 +90,7 @@ if (BUILD_STATIC)
OUTPUT_NAME
uchardet
)
endif (BUILD_STATIC)
endif (UCHARDET_STATIC_TARGET)
if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(
@ -104,26 +105,28 @@ install(
${UCHARDET_TARGET}
LIBRARY DESTINATION
${DIR_LIBRARY}
ARCHIVE DESTINATION
${DIR_LIBRARY}
)
else (NOT WIN32)
install(
TARGETS
${UCHARDET_TARGET}
RUNTIME DESTINATION
${DIR_BIN}
${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION
${DIR_LIBRARY}
)
endif (NOT WIN32)
if (BUILD_STATIC)
if (UCHARDET_STATIC_TARGET)
install(
TARGETS
${UCHARDET_STATIC_TARGET}
ARCHIVE DESTINATION
${DIR_LIBRARY_STATIC}
)
endif (BUILD_STATIC)
endif (UCHARDET_STATIC_TARGET)
install(
FILES
@ -134,4 +137,6 @@ install(
include(symbols.cmake)
if (BUILD_BINARY)
add_subdirectory(tools)
endif (BUILD_BINARY)

View File

@ -25,7 +25,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
set(_version_script "${CMAKE_CURRENT_BINARY_DIR}/version.script")
file(WRITE ${_version_script} "${_symbols}\n")
set(LINK_FLAGS "${LINK_FLAGS} -Wl,--version-script,'${_version_script}'")
set(LINK_FLAGS "${LINK_FLAGS} -Wl,--version-script,${_version_script}")
endif (APPLE)

View File

@ -18,6 +18,6 @@ install(
uchardet
RUNTIME
DESTINATION
${DIR_BIN}
${CMAKE_INSTALL_BINDIR}
)

View File

@ -8,4 +8,5 @@ Description: An encoding detector library ported from Mozilla
Version: @UCHARDET_VERSION@
Requires:
Libs: -L${libdir} -luchardet
Libs.private: -lstdc++
Cflags: -I${includedir}/uchardet