2016-01-07 10:37:00 +00:00
|
|
|
# ################################################################
|
2016-09-03 05:11:49 +00:00
|
|
|
# Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
|
2016-01-07 10:37:00 +00:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
2017-08-31 18:24:54 +00:00
|
|
|
# This source code is licensed under both the BSD-style license (found in the
|
|
|
|
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
|
|
|
# in the COPYING file in the root directory of this source tree).
|
2016-01-07 10:37:00 +00:00
|
|
|
# ################################################################
|
2016-01-10 11:20:52 +00:00
|
|
|
|
2017-04-19 17:20:27 +00:00
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
|
2018-11-06 20:24:29 +00:00
|
|
|
|
|
|
|
PROJECT(zstd)
|
2017-04-20 22:35:56 +00:00
|
|
|
SET(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
2018-08-14 00:28:52 +00:00
|
|
|
|
2018-11-06 20:24:29 +00:00
|
|
|
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
message(STATUS "No build type selected, defaulting to Release")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
|
|
endif()
|
2018-08-14 00:28:52 +00:00
|
|
|
|
2017-04-20 22:46:44 +00:00
|
|
|
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
|
2018-01-15 19:48:46 +00:00
|
|
|
INCLUDE(GNUInstallDirs)
|
2016-01-07 10:37:00 +00:00
|
|
|
|
2017-03-17 14:36:37 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Add extra compilation flags
|
|
|
|
#-----------------------------------------------------------------------------
|
2017-04-20 22:46:44 +00:00
|
|
|
INCLUDE(AddZstdCompilationFlags)
|
|
|
|
ADD_ZSTD_COMPILATION_FLAGS()
|
2017-03-17 14:36:37 +00:00
|
|
|
|
2017-05-24 08:48:10 +00:00
|
|
|
# Always hide XXHash symbols
|
|
|
|
ADD_DEFINITIONS(-DXXH_NAMESPACE=ZSTD_)
|
|
|
|
|
2018-01-15 19:48:46 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Installation variables
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
MESSAGE(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
MESSAGE(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
|
|
|
|
|
2017-03-17 14:36:37 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Options
|
|
|
|
#-----------------------------------------------------------------------------
|
2018-01-17 07:27:52 +00:00
|
|
|
|
|
|
|
# Legacy support
|
2016-01-07 10:37:00 +00:00
|
|
|
OPTION(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
|
|
|
|
|
|
|
|
IF (ZSTD_LEGACY_SUPPORT)
|
2016-01-10 11:20:52 +00:00
|
|
|
MESSAGE(STATUS "ZSTD_LEGACY_SUPPORT defined!")
|
2017-03-13 21:44:08 +00:00
|
|
|
ADD_DEFINITIONS(-DZSTD_LEGACY_SUPPORT=4)
|
2016-01-07 10:37:00 +00:00
|
|
|
ELSE (ZSTD_LEGACY_SUPPORT)
|
2016-01-10 11:20:52 +00:00
|
|
|
MESSAGE(STATUS "ZSTD_LEGACY_SUPPORT not defined!")
|
|
|
|
ADD_DEFINITIONS(-DZSTD_LEGACY_SUPPORT=0)
|
2016-01-07 10:37:00 +00:00
|
|
|
ENDIF (ZSTD_LEGACY_SUPPORT)
|
|
|
|
|
2018-01-17 07:27:52 +00:00
|
|
|
# Multi-threading support
|
|
|
|
OPTION(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ON)
|
|
|
|
|
|
|
|
IF (ZSTD_MULTITHREAD_SUPPORT)
|
|
|
|
MESSAGE(STATUS "ZSTD_MULTITHREAD_SUPPORT is enabled")
|
|
|
|
ELSE (ZSTD_MULTITHREAD_SUPPORT)
|
|
|
|
MESSAGE(STATUS "ZSTD_MULTITHREAD_SUPPORT is disabled")
|
|
|
|
ENDIF (ZSTD_MULTITHREAD_SUPPORT)
|
|
|
|
|
|
|
|
OPTION(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" ON)
|
|
|
|
OPTION(ZSTD_BUILD_CONTRIB "BUILD CONTRIB" OFF)
|
|
|
|
OPTION(ZSTD_BUILD_TESTS "BUILD TESTS" OFF)
|
|
|
|
if (MSVC)
|
|
|
|
OPTION(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# External dependencies
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
IF (ZSTD_MULTITHREAD_SUPPORT AND UNIX)
|
|
|
|
SET(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
FIND_PACKAGE(Threads REQUIRED)
|
|
|
|
IF(CMAKE_USE_PTHREADS_INIT)
|
|
|
|
SET(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF (ZSTD_MULTITHREAD_SUPPORT AND UNIX)
|
|
|
|
|
2017-03-17 14:36:37 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Add source directories
|
|
|
|
#-----------------------------------------------------------------------------
|
2016-01-10 11:20:52 +00:00
|
|
|
ADD_SUBDIRECTORY(lib)
|
2017-03-20 14:47:28 +00:00
|
|
|
|
|
|
|
IF (ZSTD_BUILD_PROGRAMS)
|
2017-05-24 08:48:10 +00:00
|
|
|
IF (NOT ZSTD_BUILD_STATIC)
|
|
|
|
MESSAGE(SEND_ERROR "You need to build static library to build zstd CLI")
|
|
|
|
ENDIF (NOT ZSTD_BUILD_STATIC)
|
|
|
|
|
2017-03-20 14:47:28 +00:00
|
|
|
ADD_SUBDIRECTORY(programs)
|
|
|
|
ENDIF (ZSTD_BUILD_PROGRAMS)
|
|
|
|
|
|
|
|
IF (ZSTD_BUILD_TESTS)
|
|
|
|
IF (NOT ZSTD_BUILD_STATIC)
|
|
|
|
MESSAGE(SEND_ERROR "You need to build static library to build tests")
|
|
|
|
ENDIF (NOT ZSTD_BUILD_STATIC)
|
|
|
|
|
|
|
|
ADD_SUBDIRECTORY(tests)
|
|
|
|
ENDIF (ZSTD_BUILD_TESTS)
|
|
|
|
|
2017-02-09 14:10:24 +00:00
|
|
|
IF (ZSTD_BUILD_CONTRIB)
|
|
|
|
ADD_SUBDIRECTORY(contrib)
|
|
|
|
ENDIF (ZSTD_BUILD_CONTRIB)
|
2016-01-07 10:37:00 +00:00
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
2017-03-17 14:36:37 +00:00
|
|
|
# Add clean-all target
|
2016-01-07 10:37:00 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
2016-06-03 08:24:00 +00:00
|
|
|
ADD_CUSTOM_TARGET(clean-all
|
|
|
|
COMMAND ${CMAKE_BUILD_TOOL} clean
|
|
|
|
COMMAND rm -rf ${CMAKE_BINARY_DIR}/
|
|
|
|
)
|