Much easier way of installing libraries with correct names
parent
c2430434df
commit
0d3daffa2f
|
@ -100,71 +100,33 @@ ENDIF (MSVC)
|
|||
|
||||
# Define library base name
|
||||
IF (MSVC)
|
||||
SET(LIBRARY_BASE_NAME zstdlib)
|
||||
|
||||
IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
SET(LIBRARY_ARCH_SUFFIX "_x64")
|
||||
SET(LIBRARY_BASE_NAME "zstdlib_x64")
|
||||
ELSE ()
|
||||
SET(LIBRARY_ARCH_SUFFIX "_x86")
|
||||
SET(LIBRARY_BASE_NAME "zstdlib_x86")
|
||||
ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
ELSE ()
|
||||
SET(LIBRARY_BASE_NAME libzstd)
|
||||
|
||||
SET(LIBRARY_ARCH_SUFFIX "")
|
||||
SET(LIBRARY_BASE_NAME zstd)
|
||||
ENDIF (MSVC)
|
||||
|
||||
# Define static and shared library names
|
||||
SET(STATIC_LIBRARY_OUTPUT_NAME ${LIBRARY_BASE_NAME}${LIBRARY_ARCH_SUFFIX} CACHE STRING "Static library output name")
|
||||
SET(SHARED_LIBRARY_OUTPUT_NAME ${LIBRARY_BASE_NAME}.${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}${LIBRARY_ARCH_SUFFIX} CACHE STRING "Shared library output name")
|
||||
|
||||
SET_TARGET_PROPERTIES(
|
||||
libzstd_static
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME ${STATIC_LIBRARY_OUTPUT_NAME})
|
||||
OUTPUT_NAME ${LIBRARY_BASE_NAME})
|
||||
|
||||
SET_TARGET_PROPERTIES(
|
||||
libzstd_shared
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME ${SHARED_LIBRARY_OUTPUT_NAME})
|
||||
OUTPUT_NAME ${LIBRARY_BASE_NAME}
|
||||
SOVERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE})
|
||||
|
||||
IF (UNIX)
|
||||
IF ("${PREFIX}" STREQUAL "")
|
||||
SET(PREFIX /usr/local)
|
||||
ENDIF()
|
||||
MESSAGE("the variable PREFIX=${PREFIX}")
|
||||
SET(INSTALL_LIBRARY_DIR ${PREFIX}/lib)
|
||||
SET(INSTALL_INCLUDE_DIR ${PREFIX}/include)
|
||||
|
||||
# install target
|
||||
INSTALL(FILES ${LIBRARY_DIR}/zstd.h ${LIBRARY_DIR}/deprecated/zbuff.h ${LIBRARY_DIR}/dictBuilder/zdict.h DESTINATION ${INSTALL_INCLUDE_DIR})
|
||||
INSTALL(TARGETS libzstd_static DESTINATION ${INSTALL_LIBRARY_DIR})
|
||||
INSTALL(TARGETS libzstd_shared LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR})
|
||||
|
||||
# Create symlinks and setup this files
|
||||
SET(SHARED_LIBRARY_LINK ${SHARED_LIBRARY_OUTPUT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
SET(SHARED_LIBRARY_SYMLINK1 ${LIBRARY_BASE_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
SET(SHARED_LIBRARY_SYMLINK2 ${LIBRARY_BASE_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${LIBVER_MAJOR})
|
||||
|
||||
SET(SHARED_LIBRARY_LINK_PATH ${CMAKE_CURRENT_BINARY_DIR}/${SHARED_LIBRARY_LINK})
|
||||
SET(SHARED_LIBRARY_SYMLINK1_PATH ${CMAKE_CURRENT_BINARY_DIR}/${SHARED_LIBRARY_SYMLINK1})
|
||||
SET(SHARED_LIBRARY_SYMLINK2_PATH ${CMAKE_CURRENT_BINARY_DIR}/${SHARED_LIBRARY_SYMLINK2})
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET libzstd_shared POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${SHARED_LIBRARY_LINK} ${SHARED_LIBRARY_SYMLINK1}
|
||||
DEPENDS ${SHARED_LIBRARY_LINK_PATH}
|
||||
COMMENT "Generating symbolic link ${SHARED_LIBRARY_LINK} -> ${SHARED_LIBRARY_SYMLINK1}")
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET libzstd_shared POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${SHARED_LIBRARY_LINK} ${SHARED_LIBRARY_SYMLINK2}
|
||||
DEPENDS ${SHARED_LIBRARY_LINK_PATH}
|
||||
COMMENT "Generating symbolic link ${SHARED_LIBRARY_LINK} -> ${SHARED_LIBRARY_SYMLINK2}")
|
||||
|
||||
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${SHARED_LIBRARY_SYMLINK1};${SHARED_LIBRARY_SYMLINK2}")
|
||||
|
||||
INSTALL(FILES ${SHARED_LIBRARY_SYMLINK1_PATH} DESTINATION ${INSTALL_LIBRARY_DIR})
|
||||
INSTALL(FILES ${SHARED_LIBRARY_SYMLINK2_PATH} DESTINATION ${INSTALL_LIBRARY_DIR})
|
||||
INSTALL(FILES ${LIBRARY_DIR}/zstd.h ${LIBRARY_DIR}/deprecated/zbuff.h ${LIBRARY_DIR}/dictBuilder/zdict.h DESTINATION "include")
|
||||
INSTALL(TARGETS libzstd_static ARCHIVE DESTINATION "lib")
|
||||
INSTALL(TARGETS libzstd_shared LIBRARY DESTINATION "lib")
|
||||
|
||||
# uninstall target
|
||||
CONFIGURE_FILE(
|
||||
|
|
Loading…
Reference in New Issue