mirror of
https://gitlab.freedesktop.org/uchardet/uchardet.git
synced 2025-12-06 08:46:40 +08:00
Merge pull request #30 from Coacher/use-gnuinstalldirs-cmake-module
Use GNUInstallDirs cmake module, fix library filename bug, minor cleanups.
This commit is contained in:
commit
74b4f6a62b
@ -1,5 +1,5 @@
|
||||
######## Project settings
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 2.8.5)
|
||||
set (PACKAGE_NAME uchardet)
|
||||
project (${PACKAGE_NAME} CXX C)
|
||||
enable_testing()
|
||||
@ -12,7 +12,7 @@ set (UCHARDET_VERSION_MINOR 0)
|
||||
set (UCHARDET_VERSION_REVISION 5)
|
||||
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set (version_suffix .Debug)
|
||||
set (version_suffix .debug)
|
||||
endif (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
|
||||
set (
|
||||
@ -29,43 +29,16 @@ set (
|
||||
|
||||
######## Directory
|
||||
|
||||
set (DIR_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
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_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})
|
||||
endif (DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
|
||||
if (DEFINED SHARE_INSTALL_PREFIX)
|
||||
set (DIR_SHARE ${SHARE_INSTALL_PREFIX})
|
||||
endif (DEFINED SHARE_INSTALL_PREFIX)
|
||||
|
||||
if (DEFINED INCLUDE_INSTALL_DIR)
|
||||
set (DIR_INCLUDE ${INCLUDE_INSTALL_DIR})
|
||||
endif (DEFINED INCLUDE_INSTALL_DIR)
|
||||
|
||||
if (DEFINED SYSCONF_INSTALL_DIR)
|
||||
set (DIR_ETC ${SYSCONF_INSTALL_DIR})
|
||||
endif (DEFINED SYSCONF_INSTALL_DIR)
|
||||
|
||||
set (DIR_SHARE_UCHARDET ${DIR_SHARE}/${PACKAGE_NAME})
|
||||
set (DIR_SHARE_LOCALE ${DIR_SHARE}/locale)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
######## Configuration
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared library and link executable against it"
|
||||
ON)
|
||||
option(BUILD_BINARY "Build executable" ON)
|
||||
option(BUILD_SHARED_LIBS "Build shared library and link executable to 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(
|
||||
uchardet.pc.in
|
||||
@ -77,7 +50,7 @@ install(
|
||||
FILES
|
||||
${CMAKE_BINARY_DIR}/uchardet.pc
|
||||
DESTINATION
|
||||
${DIR_LIBRARY}/pkgconfig
|
||||
${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
||||
)
|
||||
|
||||
######## Subdirectories
|
||||
|
||||
@ -2,5 +2,5 @@ install(
|
||||
FILES
|
||||
uchardet.1
|
||||
DESTINATION
|
||||
${DIR_SHARE}/man/man1
|
||||
${CMAKE_INSTALL_MANDIR}/man1
|
||||
)
|
||||
|
||||
@ -41,56 +41,18 @@ set(
|
||||
uchardet.cpp
|
||||
)
|
||||
|
||||
set (UCHARDET_TARGET libuchardet)
|
||||
set (UCHARDET_LIBRARY libuchardet)
|
||||
set (UCHARDET_LIBRARY libuchardet PARENT_SCOPE)
|
||||
|
||||
if (BUILD_STATIC AND BUILD_SHARED_LIBS)
|
||||
set (UCHARDET_STATIC_TARGET libuchardet_static)
|
||||
set (UCHARDET_STATIC_LIBRARY libuchardet_static)
|
||||
endif ()
|
||||
|
||||
add_definitions(
|
||||
-DPKGDATADIR="${DIR_SHARE_UCHARDET}"
|
||||
-DLOCALEDIR="${DIR_SHARE_LOCALE}"
|
||||
-DVERSION="${UCHARDET_VERSION}"
|
||||
-DPACKAGE_NAME="${PACKAGE_NAME}"
|
||||
-Wall
|
||||
)
|
||||
|
||||
add_library(
|
||||
${UCHARDET_TARGET}
|
||||
${UCHARDET_SOURCES}
|
||||
)
|
||||
|
||||
if (UCHARDET_STATIC_TARGET)
|
||||
add_library(
|
||||
${UCHARDET_STATIC_TARGET}
|
||||
STATIC
|
||||
${UCHARDET_SOURCES}
|
||||
)
|
||||
endif (UCHARDET_STATIC_TARGET)
|
||||
|
||||
set_target_properties(
|
||||
${UCHARDET_TARGET}
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE
|
||||
CXX
|
||||
OUTPUT_NAME
|
||||
uchardet
|
||||
VERSION
|
||||
0.0.0
|
||||
SOVERSION
|
||||
0
|
||||
)
|
||||
|
||||
if (UCHARDET_STATIC_TARGET)
|
||||
set_target_properties(
|
||||
${UCHARDET_STATIC_TARGET}
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE
|
||||
CXX
|
||||
OUTPUT_NAME
|
||||
uchardet
|
||||
)
|
||||
endif (UCHARDET_STATIC_TARGET)
|
||||
|
||||
if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
add_definitions(
|
||||
-O0
|
||||
@ -98,40 +60,77 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
)
|
||||
endif (CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
|
||||
add_library(
|
||||
${UCHARDET_LIBRARY}
|
||||
${UCHARDET_SOURCES}
|
||||
)
|
||||
|
||||
if (UCHARDET_STATIC_LIBRARY)
|
||||
add_library(
|
||||
${UCHARDET_STATIC_LIBRARY}
|
||||
STATIC
|
||||
${UCHARDET_SOURCES}
|
||||
)
|
||||
endif (UCHARDET_STATIC_LIBRARY)
|
||||
|
||||
set_target_properties(
|
||||
${UCHARDET_LIBRARY}
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE
|
||||
CXX
|
||||
OUTPUT_NAME
|
||||
${PACKAGE_NAME}
|
||||
VERSION
|
||||
${UCHARDET_VERSION}
|
||||
SOVERSION
|
||||
${UCHARDET_VERSION_MAJOR}
|
||||
)
|
||||
|
||||
if (UCHARDET_STATIC_LIBRARY)
|
||||
set_target_properties(
|
||||
${UCHARDET_STATIC_LIBRARY}
|
||||
PROPERTIES
|
||||
LINKER_LANGUAGE
|
||||
CXX
|
||||
OUTPUT_NAME
|
||||
${PACKAGE_NAME}
|
||||
)
|
||||
endif (UCHARDET_STATIC_LIBRARY)
|
||||
|
||||
if (NOT WIN32)
|
||||
install(
|
||||
TARGETS
|
||||
${UCHARDET_TARGET}
|
||||
${UCHARDET_LIBRARY}
|
||||
LIBRARY DESTINATION
|
||||
${DIR_LIBRARY}
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION
|
||||
${DIR_LIBRARY}
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
else (NOT WIN32)
|
||||
install(
|
||||
TARGETS
|
||||
${UCHARDET_TARGET}
|
||||
${UCHARDET_LIBRARY}
|
||||
RUNTIME DESTINATION
|
||||
${CMAKE_INSTALL_BINDIR}
|
||||
ARCHIVE DESTINATION
|
||||
${DIR_LIBRARY}
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
endif (NOT WIN32)
|
||||
|
||||
if (UCHARDET_STATIC_TARGET)
|
||||
if (UCHARDET_STATIC_LIBRARY)
|
||||
install(
|
||||
TARGETS
|
||||
${UCHARDET_STATIC_TARGET}
|
||||
${UCHARDET_STATIC_LIBRARY}
|
||||
ARCHIVE DESTINATION
|
||||
${DIR_LIBRARY_STATIC}
|
||||
${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
endif (UCHARDET_STATIC_TARGET)
|
||||
endif (UCHARDET_STATIC_LIBRARY)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${UCHARDET_HEADERS}
|
||||
DESTINATION
|
||||
${DIR_INCLUDE}/uchardet
|
||||
${CMAKE_INSTALL_INCLUDEDIR}/${PACKAGE_NAME}
|
||||
)
|
||||
|
||||
include(symbols.cmake)
|
||||
|
||||
@ -11,7 +11,7 @@ set(
|
||||
set (LINK_FLAGS "")
|
||||
|
||||
if (APPLE)
|
||||
# Create a symbols_list file for the darwin linker.
|
||||
# Create a symbols_list file for the Darwin linker.
|
||||
string(REPLACE ";" "\n_" _symbols "${UCHARDET_SYMBOLS}")
|
||||
set(_symbols_list "${CMAKE_CURRENT_BINARY_DIR}/symbols.list")
|
||||
file(WRITE ${_symbols_list} "_${_symbols}\n")
|
||||
@ -19,7 +19,7 @@ if (APPLE)
|
||||
set(LINK_FLAGS
|
||||
"${LINK_FLAGS} -Wl,-exported_symbols_list,'${_symbols_list}'")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||
# Create a version script for GNU ld.
|
||||
# Create a version script for the GNU ld.
|
||||
set(_symbols "{ global: ${UCHARDET_SYMBOLS}; local: *; };")
|
||||
set(_version_script "${CMAKE_CURRENT_BINARY_DIR}/version.script")
|
||||
file(WRITE ${_version_script} "${_symbols}\n")
|
||||
@ -28,7 +28,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||
endif (APPLE)
|
||||
|
||||
set_target_properties(
|
||||
${UCHARDET_TARGET}
|
||||
${UCHARDET_LIBRARY}
|
||||
PROPERTIES
|
||||
LINK_FLAGS
|
||||
"${LINK_FLAGS}"
|
||||
|
||||
@ -3,19 +3,21 @@ set(
|
||||
uchardet.cpp
|
||||
)
|
||||
|
||||
set(UCHARDET_BINARY uchardet)
|
||||
|
||||
add_executable(
|
||||
uchardet
|
||||
${UCHARDET_BINARY}
|
||||
${UCHARDET_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
uchardet
|
||||
${UCHARDET_TARGET}
|
||||
${UCHARDET_BINARY}
|
||||
${UCHARDET_LIBRARY}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS
|
||||
uchardet
|
||||
${UCHARDET_BINARY}
|
||||
RUNTIME DESTINATION
|
||||
${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
@ -10,7 +10,7 @@ add_executable(
|
||||
|
||||
target_link_libraries(
|
||||
uchardet-tests
|
||||
libuchardet
|
||||
${UCHARDET_LIBRARY}
|
||||
)
|
||||
|
||||
set_target_properties(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user