CMake structure reorganized;
install and uninstall targets added;
This commit is contained in:
parent
87e0837a98
commit
8665cdb213
8
.gitignore
vendored
8
.gitignore
vendored
@ -37,4 +37,10 @@ ipch/
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.cachefile
|
||||
|
||||
# IDEA solution files
|
||||
*.idea
|
||||
|
||||
# Other files
|
||||
.directory
|
@ -30,24 +30,25 @@
|
||||
# - zstd source repository : https://github.com/Cyan4973/zstd
|
||||
# - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
# ################################################################
|
||||
project(zstd)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
PROJECT(zstd)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
|
||||
|
||||
OPTION(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
|
||||
|
||||
IF (ZSTD_LEGACY_SUPPORT)
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT defined!")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=1)
|
||||
MESSAGE(STATUS "ZSTD_LEGACY_SUPPORT defined!")
|
||||
ADD_DEFINITIONS(-DZSTD_LEGACY_SUPPORT=1)
|
||||
ELSE (ZSTD_LEGACY_SUPPORT)
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT not defined!")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=0)
|
||||
MESSAGE(STATUS "ZSTD_LEGACY_SUPPORT not defined!")
|
||||
ADD_DEFINITIONS(-DZSTD_LEGACY_SUPPORT=0)
|
||||
ENDIF (ZSTD_LEGACY_SUPPORT)
|
||||
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(programs)
|
||||
ADD_SUBDIRECTORY(lib)
|
||||
ADD_SUBDIRECTORY(programs)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add extra compilation flags
|
||||
#-----------------------------------------------------------------------------
|
||||
include(CMakeModules/AddExtraCompilationFlags.cmake)
|
||||
INCLUDE(CMakeModules/AddExtraCompilationFlags.cmake)
|
||||
ADD_EXTRA_COMPILATION_FLAGS()
|
@ -188,6 +188,42 @@ MACRO(ADD_EXTRA_COMPILATION_FLAGS)
|
||||
else ()
|
||||
MESSAGE("Compiler flag ${WARNING_ALL} not allowed")
|
||||
endif (WARNING_ALL_ALLOWED)
|
||||
|
||||
set(RTC_FLAG "/RTC1")
|
||||
CHECK_C_COMPILER_FLAG(${RTC_FLAG} RTC_FLAG_ALLOWED)
|
||||
if (RTC_FLAG_ALLOWED)
|
||||
MESSAGE("Compiler flag ${RTC_FLAG} allowed")
|
||||
set(ACTIVATE_RTC_FLAG "ON" CACHE BOOL "activate /RTC1 flag")
|
||||
else ()
|
||||
MESSAGE("Compiler flag ${RTC_FLAG} not allowed")
|
||||
endif (RTC_FLAG_ALLOWED)
|
||||
|
||||
set(ZC_FLAG "/Zc:forScope")
|
||||
CHECK_C_COMPILER_FLAG(${ZC_FLAG} ZC_FLAG_ALLOWED)
|
||||
if (ZC_FLAG_ALLOWED)
|
||||
MESSAGE("Compiler flag ${ZC_FLAG} allowed")
|
||||
set(ACTIVATE_ZC_FLAG "ON" CACHE BOOL "activate /Zc:forScope flag")
|
||||
else ()
|
||||
MESSAGE("Compiler flag ${ZC_FLAG} not allowed")
|
||||
endif (ZC_FLAG_ALLOWED)
|
||||
|
||||
set(GD_FLAG "/Gd")
|
||||
CHECK_C_COMPILER_FLAG(${GD_FLAG} GD_FLAG_ALLOWED)
|
||||
if (GD_FLAG_ALLOWED)
|
||||
MESSAGE("Compiler flag ${GD_FLAG} allowed")
|
||||
set(ACTIVATE_GD_FLAG "ON" CACHE BOOL "activate /Gd flag")
|
||||
else ()
|
||||
MESSAGE("Compiler flag ${GD_FLAG} not allowed")
|
||||
endif (GD_FLAG_ALLOWED)
|
||||
|
||||
set(ANALYZE_FLAG "/analyze:stacksize25000")
|
||||
CHECK_C_COMPILER_FLAG(${ANALYZE_FLAG} ANALYZE_FLAG_ALLOWED)
|
||||
if (ANALYZE_FLAG_ALLOWED)
|
||||
MESSAGE("Compiler flag ${ANALYZE_FLAG} allowed")
|
||||
set(ACTIVATE_ANALYZE_FLAG "ON" CACHE BOOL "activate /ANALYZE flag")
|
||||
else ()
|
||||
MESSAGE("Compiler flag ${ANALYZE_FLAG} not allowed")
|
||||
endif (ANALYZE_FLAG_ALLOWED)
|
||||
|
||||
if (ACTIVATE_WARNING_ALL)
|
||||
list(APPEND CMAKE_CXX_FLAGS ${WARNING_ALL})
|
||||
@ -195,7 +231,41 @@ MACRO(ADD_EXTRA_COMPILATION_FLAGS)
|
||||
else ()
|
||||
string(REPLACE ${WARNING_ALL} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE ${WARNING_ALL} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
endif ()
|
||||
endif (ACTIVATE_WARNING_ALL)
|
||||
|
||||
# Only for DEBUG version
|
||||
if (ACTIVATE_RTC_FLAG)
|
||||
list(APPEND CMAKE_CXX_FLAGS_DEBUG ${RTC_FLAG})
|
||||
list(APPEND CMAKE_C_FLAGS_DEBUG ${RTC_FLAG})
|
||||
else ()
|
||||
string(REPLACE ${RTC_FLAG} "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
string(REPLACE ${RTC_FLAG} "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
||||
endif (ACTIVATE_RTC_FLAG)
|
||||
|
||||
if (ACTIVATE_ZC_FLAG)
|
||||
list(APPEND CMAKE_CXX_FLAGS ${ZC_FLAG})
|
||||
list(APPEND CMAKE_C_FLAGS ${ZC_FLAG})
|
||||
else ()
|
||||
string(REPLACE ${ZC_FLAG} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE ${ZC_FLAG} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
endif (ACTIVATE_ZC_FLAG)
|
||||
|
||||
if (ACTIVATE_GD_FLAG)
|
||||
list(APPEND CMAKE_CXX_FLAGS ${GD_FLAG})
|
||||
list(APPEND CMAKE_C_FLAGS ${GD_FLAG})
|
||||
else ()
|
||||
string(REPLACE ${GD_FLAG} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE ${GD_FLAG} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
endif (ACTIVATE_GD_FLAG)
|
||||
|
||||
if (ACTIVATE_ANALYZE_FLAG)
|
||||
list(APPEND CMAKE_CXX_FLAGS ${ANALYZE_FLAG})
|
||||
list(APPEND CMAKE_C_FLAGS ${ANALYZE_FLAG})
|
||||
else ()
|
||||
string(REPLACE ${ANALYZE_FLAG} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE ${ANALYZE_FLAG} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
endif (ACTIVATE_ANALYZE_FLAG)
|
||||
|
||||
if (MSVC80 OR MSVC90 OR MSVC10 OR MSVC11)
|
||||
# To avoid compiler warning (level 4) C4571, compile with /EHa if you still want
|
||||
# your catch(...) blocks to catch structured exceptions.
|
||||
@ -216,30 +286,34 @@ MACRO(ADD_EXTRA_COMPILATION_FLAGS)
|
||||
|
||||
#For exceptions
|
||||
list(APPEND CMAKE_CXX_FLAGS "/EHsc")
|
||||
list(APPEND CMAKE_C_FLAGS "/EHsc")
|
||||
|
||||
# UNICODE SUPPORT
|
||||
list(APPEND CMAKE_CXX_FLAGS "/D_UNICODE /DUNICODE")
|
||||
list(APPEND CMAKE_C_FLAGS "/D_UNICODE /DUNICODE")
|
||||
endif ()
|
||||
|
||||
# Remove duplicates compilation flags
|
||||
separate_arguments(CMAKE_CXX_FLAGS)
|
||||
list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS)
|
||||
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "common C++ build flags" FORCE)
|
||||
|
||||
separate_arguments(CMAKE_C_FLAGS)
|
||||
list(REMOVE_DUPLICATES CMAKE_C_FLAGS)
|
||||
string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "common C build flags" FORCE)
|
||||
FOREACH (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
separate_arguments(${flag_var})
|
||||
list(REMOVE_DUPLICATES ${flag_var})
|
||||
string(REPLACE ";" " " ${flag_var} "${${flag_var}}")
|
||||
set(${flag_var} "${${flag_var}}" CACHE STRING "common build flags" FORCE)
|
||||
ENDFOREACH (flag_var)
|
||||
|
||||
if (MSVC)
|
||||
# Replace /MT to /MD flag
|
||||
FOREACH (flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
STRING(REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
|
||||
ENDFOREACH (flag_var)
|
||||
|
||||
# Replace /O2 to /O3 flag
|
||||
FOREACH (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
STRING(REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
|
||||
ENDFOREACH (flag_var)
|
||||
STRING(REGEX REPLACE "/O2" "/Ox" ${flag_var} "${${flag_var}}")
|
||||
ENDFOREACH (flag_var)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Updated flags" FORCE)
|
22
contib/cmake/cmake_uninstall.cmake.in
Normal file
22
contib/cmake/cmake_uninstall.cmake.in
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
203
contib/cmake/lib/CMakeLists.txt
Normal file
203
contib/cmake/lib/CMakeLists.txt
Normal file
@ -0,0 +1,203 @@
|
||||
# ################################################################
|
||||
# zstd - Makefile
|
||||
# Copyright (C) Yann Collet 2014-2015
|
||||
# All rights reserved.
|
||||
#
|
||||
# BSD license
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
# list of conditions and the following disclaimer in the documentation and/or
|
||||
# other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# You can contact the author at :
|
||||
# - zstd source repository : https://github.com/Cyan4973/zstd
|
||||
# - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
# ################################################################
|
||||
|
||||
# Get library version based on information from input content (use regular exp)
|
||||
function(GetLibraryVersion _content _outputVar1 _outputVar2 _outputVar3)
|
||||
string(REGEX MATCHALL ".*define ZSTD_VERSION_MAJOR+.* ([0-9]+).*define ZSTD_VERSION_MINOR+.* ([0-9]+).*define ZSTD_VERSION_RELEASE+.* ([0-9]+)" VERSION_REGEX "${_content}")
|
||||
SET(${_outputVar1} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
||||
SET(${_outputVar2} ${CMAKE_MATCH_2} PARENT_SCOPE)
|
||||
SET(${_outputVar3} ${CMAKE_MATCH_3} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
PROJECT(libzstd)
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
|
||||
# Define project root directory
|
||||
SET(ROOT_DIR ../../..)
|
||||
|
||||
# Define library directory, where sources and header files are located
|
||||
SET(LIBRARY_DIR ${ROOT_DIR}/lib)
|
||||
INCLUDE_DIRECTORIES(${LIBRARY_DIR})
|
||||
|
||||
# Read file content
|
||||
FILE(READ ${LIBRARY_DIR}/zstd.h HEADER_CONTENT)
|
||||
|
||||
# Parse version
|
||||
GetLibraryVersion("${HEADER_CONTENT}" LIBVER_MAJOR LIBVER_MINOR LIBVER_RELEASE)
|
||||
MESSAGE("ZSTD VERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}")
|
||||
|
||||
SET(Sources
|
||||
${LIBRARY_DIR}/fse.c
|
||||
${LIBRARY_DIR}/huff0.c
|
||||
${LIBRARY_DIR}/zstd_buffered.c
|
||||
${LIBRARY_DIR}/zstd_compress.c
|
||||
${LIBRARY_DIR}/zstd_decompress.c)
|
||||
|
||||
SET(Headers
|
||||
${LIBRARY_DIR}/bitstream.h
|
||||
${LIBRARY_DIR}/error.h
|
||||
${LIBRARY_DIR}/fse.h
|
||||
${LIBRARY_DIR}/fse_static.h
|
||||
${LIBRARY_DIR}/huff0.h
|
||||
${LIBRARY_DIR}/huff0_static.h
|
||||
${LIBRARY_DIR}/mem.h
|
||||
${LIBRARY_DIR}/zstd_buffered_static.h
|
||||
${LIBRARY_DIR}/zstd_buffered.h
|
||||
${LIBRARY_DIR}/zstd_internal.h
|
||||
${LIBRARY_DIR}/zstd_static.h
|
||||
${LIBRARY_DIR}/zstd.h)
|
||||
|
||||
IF (ZSTD_LEGACY_SUPPORT)
|
||||
SET(LIBRARY_LEGACY_DIR ${LIBRARY_DIR}/legacy)
|
||||
INCLUDE_DIRECTORIES(${LIBRARY_LEGACY_DIR})
|
||||
|
||||
SET(Sources ${Sources}
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v01.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v02.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v03.c)
|
||||
|
||||
SET(Headers ${Headers}
|
||||
${LIBRARY_LEGACY_DIR}/zstd_legacy.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v01.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v02.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v03.h)
|
||||
ENDIF (ZSTD_LEGACY_SUPPORT)
|
||||
|
||||
IF (MSVC)
|
||||
SET(MSVC_RESOURCE_DIR ${ROOT_DIR}/visual/2013/zstdlib)
|
||||
SET(PlatformDependResources ${MSVC_RESOURCE_DIR}/resource.h ${MSVC_RESOURCE_DIR}/zstdlib.rc)
|
||||
ENDIF (MSVC)
|
||||
|
||||
# Split project to static and shared libraries build
|
||||
ADD_LIBRARY(libzstd_static STATIC ${Sources} ${Headers} ${PlatformDependResources})
|
||||
ADD_LIBRARY(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
|
||||
|
||||
# Add specific compile definitions for MSVC project
|
||||
IF (MSVC)
|
||||
SET_TARGET_PROPERTIES(libzstd_static PROPERTIES COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
|
||||
SET_TARGET_PROPERTIES(libzstd_shared PROPERTIES COMPILE_DEFINITIONS "ZSTD_DLL_EXPORT=1;ZSTD_HEAPMODE=0;_CONSOLE;_CRT_SECURE_NO_WARNINGS")
|
||||
ENDIF (MSVC)
|
||||
|
||||
TARGET_INCLUDE_DIRECTORIES(libzstd_static PUBLIC ${LIBRARY_DIR})
|
||||
TARGET_INCLUDE_DIRECTORIES(libzstd_shared PUBLIC ${LIBRARY_DIR})
|
||||
|
||||
IF (ZSTD_LEGACY_SUPPORT)
|
||||
TARGET_INCLUDE_DIRECTORIES(libzstd_static PUBLIC ${LIBRARY_LEGACY_DIR})
|
||||
TARGET_INCLUDE_DIRECTORIES(libzstd_shared PUBLIC ${LIBRARY_LEGACY_DIR})
|
||||
ENDIF (ZSTD_LEGACY_SUPPORT)
|
||||
|
||||
# Define library base name
|
||||
IF (UNIX)
|
||||
SET(LIBRARY_BASE_NAME libzstd)
|
||||
ELSEIF (MSVC)
|
||||
SET(LIBRARY_BASE_NAME zstdlib)
|
||||
ELSE ()
|
||||
MESSAGE(FATAL_ERROR "Unsupported build type")
|
||||
ENDIF (UNIX)
|
||||
|
||||
# Define static and shared library names
|
||||
SET(STATIC_LIBRARY_OUTPUT_NAME ${LIBRARY_BASE_NAME})
|
||||
SET(SHARED_LIBRARY_OUTPUT_NAME ${LIBRARY_BASE_NAME}.${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE})
|
||||
|
||||
IF (MSVC)
|
||||
IF (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
SET(STATIC_LIBRARY_OUTPUT_NAME ${STATIC_LIBRARY_OUTPUT_NAME}_x64)
|
||||
SET(SHARED_LIBRARY_OUTPUT_NAME ${SHARED_LIBRARY_OUTPUT_NAME}_x64)
|
||||
ELSE ()
|
||||
SET(STATIC_LIBRARY_OUTPUT_NAME ${STATIC_LIBRARY_OUTPUT_NAME}_x86)
|
||||
SET(SHARED_LIBRARY_OUTPUT_NAME ${SHARED_LIBRARY_OUTPUT_NAME}_x86)
|
||||
ENDIF (CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||
ENDIF (MSVC)
|
||||
|
||||
SET_TARGET_PROPERTIES(
|
||||
libzstd_static
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME ${STATIC_LIBRARY_OUTPUT_NAME})
|
||||
|
||||
SET_TARGET_PROPERTIES(
|
||||
libzstd_shared
|
||||
PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME ${SHARED_LIBRARY_OUTPUT_NAME})
|
||||
|
||||
IF (UNIX)
|
||||
SET(PREFIX /usr/local)
|
||||
SET(INSTALL_LIBRARY_DIR ${PREFIX}/lib)
|
||||
SET(INSTALL_INCLUDE_DIR ${PREFIX}/include)
|
||||
|
||||
# install target
|
||||
INSTALL(FILES ${LIBRARY_DIR}/zstd.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})
|
||||
|
||||
if (EXISTS ${SHARED_LIBRARY_SYMLINK1_PATH})
|
||||
FILE(REMOVE ${SHARED_LIBRARY_SYMLINK1_PATH})
|
||||
endif (EXISTS ${SHARED_LIBRARY_SYMLINK1_PATH})
|
||||
|
||||
if (EXISTS ${SHARED_LIBRARY_SYMLINK2_PATH})
|
||||
FILE(REMOVE ${SHARED_LIBRARY_SYMLINK2_PATH})
|
||||
endif (EXISTS ${SHARED_LIBRARY_SYMLINK2_PATH})
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET libzstd_shared POST_BUILD
|
||||
COMMAND ln -s ${SHARED_LIBRARY_LINK} ${SHARED_LIBRARY_SYMLINK1}
|
||||
DEPENDS ${SHARED_LIBRARY_LINK_PATH}
|
||||
COMMENT "Generating symbolic link")
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET libzstd_shared POST_BUILD
|
||||
COMMAND ln -s ${SHARED_LIBRARY_LINK} ${SHARED_LIBRARY_SYMLINK2}
|
||||
DEPENDS ${SHARED_LIBRARY_LINK_PATH}
|
||||
COMMENT "Generating symbolic link")
|
||||
|
||||
INSTALL(FILES ${SHARED_LIBRARY_SYMLINK1_PATH} DESTINATION ${INSTALL_LIBRARY_DIR})
|
||||
INSTALL(FILES ${SHARED_LIBRARY_SYMLINK2_PATH} DESTINATION ${INSTALL_LIBRARY_DIR})
|
||||
|
||||
# uninstall target
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
ADD_CUSTOM_TARGET(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
ENDIF (UNIX)
|
@ -31,39 +31,45 @@
|
||||
# - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
# ################################################################
|
||||
|
||||
project(programs)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
PROJECT(programs)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
|
||||
# Define project root directory
|
||||
SET(ROOT_DIR ../../..)
|
||||
|
||||
# Define зкщпкфьы directory, where sources and header files are located
|
||||
SET(PROGRAMS_DIR ${ROOT_DIR}/programs)
|
||||
INCLUDE_DIRECTORIES(${PROGRAMS_DIR})
|
||||
|
||||
IF (ZSTD_LEGACY_SUPPORT)
|
||||
include_directories(legacy)
|
||||
SET(ZSTD_FILEIO_LEGACY legacy/fileio_legacy.c)
|
||||
SET(PROGRAMS_LEGACY_DIR ${PROGRAMS_DIR}/legacy)
|
||||
INCLUDE_DIRECTORIES(${PROGRAMS_LEGACY_DIR})
|
||||
|
||||
SET(ZSTD_FILEIO_LEGACY ${PROGRAMS_LEGACY_DIR}/fileio_legacy.c)
|
||||
ENDIF (ZSTD_LEGACY_SUPPORT)
|
||||
|
||||
SET(Sources_zstd zstdcli.c fileio.c ${ZSTD_FILEIO_LEGACY} bench.c xxhash.c datagen.c)
|
||||
ADD_EXECUTABLE(zstd ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/bench.c ${PROGRAMS_DIR}/xxhash.c ${PROGRAMS_DIR}/datagen.c ${ZSTD_FILEIO_LEGACY})
|
||||
TARGET_LINK_LIBRARIES(zstd libzstd_static)
|
||||
|
||||
add_executable(zstd ${Sources_zstd})
|
||||
target_link_libraries(zstd libzstd_static)
|
||||
ADD_EXECUTABLE(fullbench ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/fullbench.c)
|
||||
TARGET_LINK_LIBRARIES(fullbench libzstd_static)
|
||||
|
||||
add_executable(zstd-noBench zstdcli.c fileio.c ${ZSTD_FILEIO_LEGACY})
|
||||
target_link_libraries(zstd-noBench libzstd_static)
|
||||
set_target_properties(zstd-noBench PROPERTIES COMPILE_DEFINITIONS "ZSTD_NOBENCH")
|
||||
ADD_EXECUTABLE(fuzzer ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/xxhash.c ${PROGRAMS_DIR}/fuzzer.c)
|
||||
TARGET_LINK_LIBRARIES(fuzzer libzstd_static)
|
||||
|
||||
add_executable(fullbench datagen.c fullbench.c)
|
||||
target_link_libraries(fullbench libzstd_static)
|
||||
IF (UNIX)
|
||||
ADD_EXECUTABLE(zstd-noBench ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/fileio.c ${ZSTD_FILEIO_LEGACY})
|
||||
TARGET_LINK_LIBRARIES(zstd-noBench libzstd_static)
|
||||
SET_TARGET_PROPERTIES(zstd-noBench PROPERTIES COMPILE_DEFINITIONS "ZSTD_NOBENCH")
|
||||
|
||||
add_executable(fuzzer datagen.c xxhash.c fuzzer.c)
|
||||
target_link_libraries(fuzzer libzstd_static)
|
||||
ADD_EXECUTABLE(zbufftest ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/xxhash.c ${PROGRAMS_DIR}/zbufftest.c)
|
||||
TARGET_LINK_LIBRARIES(zbufftest libzstd_static)
|
||||
|
||||
add_executable(zbufftest datagen.c xxhash.c zbufftest.c)
|
||||
target_link_libraries(zbufftest libzstd_static)
|
||||
ADD_EXECUTABLE(paramgrill ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/xxhash.c ${PROGRAMS_DIR}/paramgrill.c)
|
||||
TARGET_LINK_LIBRARIES(paramgrill libzstd_static)
|
||||
SET_TARGET_PROPERTIES(paramgrill PROPERTIES LINK_FLAGS "-lm")
|
||||
|
||||
add_executable(paramgrill datagen.c xxhash.c paramgrill.c)
|
||||
target_link_libraries(paramgrill libzstd_static)
|
||||
IF (NOT MSVC)
|
||||
set_target_properties(paramgrill PROPERTIES LINK_FLAGS "-lm")
|
||||
ENDIF (NOT MSVC)
|
||||
|
||||
add_executable(datagen datagen.c datagencli.c)
|
||||
target_link_libraries(datagen libzstd_static)
|
||||
ADD_EXECUTABLE(datagen ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/datagencli.c)
|
||||
TARGET_LINK_LIBRARIES(datagen libzstd_static)
|
||||
ENDIF (UNIX)
|
@ -1,116 +0,0 @@
|
||||
# ################################################################
|
||||
# zstd - Makefile
|
||||
# Copyright (C) Yann Collet 2014-2015
|
||||
# All rights reserved.
|
||||
#
|
||||
# BSD license
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice, this
|
||||
# list of conditions and the following disclaimer in the documentation and/or
|
||||
# other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# You can contact the author at :
|
||||
# - zstd source repository : https://github.com/Cyan4973/zstd
|
||||
# - Public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||
# ################################################################
|
||||
|
||||
function(ExtractVersion _content _outputVar1 _outputVar2 _outputVar3)
|
||||
string(REGEX MATCHALL ".*define ZSTD_VERSION_MAJOR+.* ([0-9]+).*define ZSTD_VERSION_MINOR+.* ([0-9]+).*define ZSTD_VERSION_RELEASE+.* ([0-9]+)" VERSION_REGEX "${_content}")
|
||||
SET(${_outputVar1} ${CMAKE_MATCH_1} PARENT_SCOPE)
|
||||
SET(${_outputVar2} ${CMAKE_MATCH_2} PARENT_SCOPE)
|
||||
SET(${_outputVar3} ${CMAKE_MATCH_3} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
project(libzstd)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
|
||||
file(READ zstd.h HEADER_CONTENT)
|
||||
|
||||
ExtractVersion("${HEADER_CONTENT}" LIBVER_MAJOR LIBVER_MINOR LIBVER_RELEASE)
|
||||
message("ZSTD VERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}")
|
||||
|
||||
SET(Sources
|
||||
fse.c
|
||||
huff0.c
|
||||
zstd_buffered.c
|
||||
zstd_compress.c
|
||||
zstd_decompress.c)
|
||||
|
||||
SET(Headers
|
||||
bitstream.h
|
||||
error.h
|
||||
fse.h
|
||||
fse_static.h
|
||||
huff0.h
|
||||
huff0_static.h
|
||||
mem.h
|
||||
zstd_buffered_static.h
|
||||
zstd_buffered.h
|
||||
zstd_internal.h
|
||||
zstd_static.h
|
||||
zstd.h)
|
||||
|
||||
IF (ZSTD_LEGACY_SUPPORT)
|
||||
include_directories(legacy)
|
||||
|
||||
SET(Sources ${Sources}
|
||||
legacy/zstd_v01.c
|
||||
legacy/zstd_v02.c
|
||||
legacy/zstd_v03.c)
|
||||
|
||||
SET(Headers ${Headers}
|
||||
legacy/zstd_legacy.h
|
||||
legacy/zstd_v01.h
|
||||
legacy/zstd_v02.h
|
||||
legacy/zstd_v03.h)
|
||||
ENDIF (ZSTD_LEGACY_SUPPORT)
|
||||
|
||||
IF (MSVC)
|
||||
SET(PlatformDependResources msvc/resource.h msvc/zstdlib.rc)
|
||||
ENDIF (MSVC)
|
||||
|
||||
add_library(libzstd_static STATIC ${Sources} ${Headers} ${PlatformDependResources})
|
||||
add_library(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
|
||||
|
||||
IF (MSVC)
|
||||
set_target_properties(libzstd_static PROPERTIES COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
|
||||
set_target_properties(libzstd_shared PROPERTIES COMPILE_DEFINITIONS "ZSTD_DLL_EXPORT=1;ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
|
||||
set_target_properties(libzstd_shared PROPERTIES COMPILE_DEFINITIONS "-DBUILD_SHARED_LIBS=TRUE")
|
||||
ENDIF (MSVC)
|
||||
|
||||
target_include_directories(libzstd_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(libzstd_shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
IF (ZSTD_LEGACY_SUPPORT)
|
||||
target_include_directories(libzstd_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/legacy)
|
||||
target_include_directories(libzstd_shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/legacy)
|
||||
ENDIF (ZSTD_LEGACY_SUPPORT)
|
||||
|
||||
SET_TARGET_PROPERTIES(
|
||||
libzstd_shared
|
||||
PROPERTIES
|
||||
OUTPUT_NAME libzstd_shared.${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE})
|
||||
|
||||
SET_TARGET_PROPERTIES(
|
||||
libzstd_static
|
||||
PROPERTIES
|
||||
OUTPUT_NAME libzstd_static.${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE})
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user