Merge pull request #575 from Majlen/cmake-improvement
Cmake improvement
This commit is contained in:
commit
c896735b8d
@ -11,6 +11,8 @@ PROJECT(zstd)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7)
|
||||
|
||||
OPTION(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
|
||||
OPTION(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ON)
|
||||
OPTION(ZSTD_BUILD_CONTRIB "BUILD CONTRIB" OFF)
|
||||
|
||||
IF (ZSTD_LEGACY_SUPPORT)
|
||||
MESSAGE(STATUS "ZSTD_LEGACY_SUPPORT defined!")
|
||||
@ -23,6 +25,9 @@ ENDIF (ZSTD_LEGACY_SUPPORT)
|
||||
ADD_SUBDIRECTORY(lib)
|
||||
ADD_SUBDIRECTORY(programs)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
IF (ZSTD_BUILD_CONTRIB)
|
||||
ADD_SUBDIRECTORY(contrib)
|
||||
ENDIF (ZSTD_BUILD_CONTRIB)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add extra compilation flags
|
||||
|
@ -132,10 +132,8 @@ MACRO(ADD_EXTRA_COMPILATION_FLAGS)
|
||||
endif (ACTIVATE_WARNING_CAST_ALIGN)
|
||||
|
||||
if (ACTIVATE_WARNING_STRICT_PROTOTYPES)
|
||||
list(APPEND CMAKE_CXX_FLAGS ${WARNING_STRICT_PROTOTYPES})
|
||||
list(APPEND CMAKE_C_FLAGS ${WARNING_STRICT_PROTOTYPES})
|
||||
else ()
|
||||
string(REPLACE ${WARNING_STRICT_PROTOTYPES} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE ${WARNING_STRICT_PROTOTYPES} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
endif (ACTIVATE_WARNING_STRICT_PROTOTYPES)
|
||||
|
||||
|
16
build/cmake/contrib/CMakeLists.txt
Normal file
16
build/cmake/contrib/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# ################################################################
|
||||
# * Copyright (c) 2015-present, Yann Collet, Facebook, Inc.
|
||||
# * All rights reserved.
|
||||
# *
|
||||
# * This source code is licensed under the BSD-style license found in the
|
||||
# * LICENSE file in the root directory of this source tree. An additional grant
|
||||
# * of patent rights can be found in the PATENTS file in the same directory.
|
||||
#
|
||||
# You can contact the author at :
|
||||
# - zstd homepage : http://www.zstd.net/
|
||||
# ################################################################
|
||||
|
||||
PROJECT(contrib)
|
||||
|
||||
ADD_SUBDIRECTORY(pzstd)
|
||||
|
30
build/cmake/contrib/pzstd/CMakeLists.txt
Normal file
30
build/cmake/contrib/pzstd/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
||||
# ################################################################
|
||||
# * Copyright (c) 2015-present, Yann Collet, Facebook, Inc.
|
||||
# * All rights reserved.
|
||||
# *
|
||||
# * This source code is licensed under the BSD-style license found in the
|
||||
# * LICENSE file in the root directory of this source tree. An additional grant
|
||||
# * of patent rights can be found in the PATENTS file in the same directory.
|
||||
#
|
||||
# You can contact the author at :
|
||||
# - zstd homepage : http://www.zstd.net/
|
||||
# ################################################################
|
||||
|
||||
PROJECT(pzstd)
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
||||
|
||||
# Define project root directory
|
||||
SET(ROOT_DIR ../../../..)
|
||||
|
||||
# Define programs directory, where sources and header files are located
|
||||
SET(LIBRARY_DIR ${ROOT_DIR}/lib)
|
||||
SET(PROGRAMS_DIR ${ROOT_DIR}/programs)
|
||||
SET(PZSTD_DIR ${ROOT_DIR}/contrib/pzstd)
|
||||
INCLUDE_DIRECTORIES(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${PZSTD_DIR})
|
||||
|
||||
ADD_EXECUTABLE(pzstd ${PZSTD_DIR}/main.cpp ${PZSTD_DIR}/Options.cpp ${PZSTD_DIR}/Pzstd.cpp ${PZSTD_DIR}/SkippableFrame.cpp)
|
||||
TARGET_LINK_LIBRARIES(pzstd libzstd_static pthread)
|
||||
SET_TARGET_PROPERTIES(pzstd PROPERTIES COMPILE_DEFINITIONS "NDEBUG")
|
||||
SET_TARGET_PROPERTIES(pzstd PROPERTIES COMPILE_OPTIONS "-Wno-shadow")
|
||||
|
@ -166,23 +166,17 @@ IF (UNIX)
|
||||
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 ${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 ln -s ${SHARED_LIBRARY_LINK} ${SHARED_LIBRARY_SYMLINK1}
|
||||
DEPENDS ${SHARED_LIBRARY_LINK_PATH}
|
||||
COMMENT "Generating symbolic link")
|
||||
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}")
|
||||
|
||||
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")
|
||||
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})
|
||||
|
@ -34,9 +34,17 @@ ENDIF (MSVC)
|
||||
|
||||
ADD_EXECUTABLE(zstd ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/bench.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/dibio.c ${PlatformDependResources})
|
||||
TARGET_LINK_LIBRARIES(zstd libzstd_static)
|
||||
|
||||
IF (UNIX)
|
||||
ADD_EXECUTABLE(zstd-frugal ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/fileio.c)
|
||||
TARGET_LINK_LIBRARIES(zstd-frugal libzstd_static)
|
||||
SET_TARGET_PROPERTIES(zstd-frugal PROPERTIES COMPILE_DEFINITIONS "ZSTD_NOBENCH;ZSTD_NODICT")
|
||||
ENDIF (UNIX)
|
||||
|
||||
IF (ZSTD_MULTITHREAD_SUPPORT)
|
||||
ADD_EXECUTABLE(zstdmt ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/bench.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/dibio.c ${PlatformDependResources})
|
||||
SET_TARGET_PROPERTIES(zstdmt PROPERTIES COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
|
||||
TARGET_LINK_LIBRARIES(zstdmt libzstd_static)
|
||||
IF (UNIX)
|
||||
TARGET_LINK_LIBRARIES(zstdmt pthread)
|
||||
ENDIF (UNIX)
|
||||
ENDIF (ZSTD_MULTITHREAD_SUPPORT)
|
||||
|
Loading…
Reference in New Issue
Block a user