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_LIBRARY_STATIC ${DIR_PREFIX}/${CMAKE_STATIC_LIBRARY_PREFIX})
set (DIR_INCLUDE ${DIR_PREFIX}/include) set (DIR_INCLUDE ${DIR_PREFIX}/include)
set (DIR_SHARE ${DIR_PREFIX}/share) set (DIR_SHARE ${DIR_PREFIX}/share)
set (DIR_BIN ${DIR_PREFIX}/bin)
set (DIR_ETC ${DIR_PREFIX}/etc) set (DIR_ETC ${DIR_PREFIX}/etc)
set (CMAKE_INSTALL_BINDIR bin
CACHE STRING "Install location of executables")
if (DEFINED CMAKE_INSTALL_LIBDIR) if (DEFINED CMAKE_INSTALL_LIBDIR)
set (DIR_LIBRARY ${CMAKE_INSTALL_LIBDIR}) set (DIR_LIBRARY ${CMAKE_INSTALL_LIBDIR})
set (DIR_LIBRARY_STATIC ${CMAKE_INSTALL_LIBDIR}) set (DIR_LIBRARY_STATIC ${CMAKE_INSTALL_LIBDIR})
@ -59,7 +61,13 @@ set (DIR_SHARE_LOCALE ${DIR_SHARE}/locale)
######## Configuration ######## 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) ON)
configure_file( configure_file(

View File

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

View File

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

View File

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