forked from zraorg/ZRA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
58 lines (44 loc) · 2.01 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
cmake_minimum_required(VERSION 3.16)
project(ZRA)
include(GenerateExportHeader)
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
add_compile_definitions(NDEBUG)
endif ()
if (WIN32 AND NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(LINK_OPTIONS "${LINK_OPTIONS} --allow-multiple-definition")
endif ()
if ((CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas")
endif ()
option(OUT_DIRECTORY "If to output to a fixed 'out' directory" FALSE)
if (OUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}/out/")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}/out/")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/")
endif ()
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(ZSTD_BUILD_PROGRAMS OFF CACHE BOOL "" FORCE)
set(ZSTD_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ZSTD_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(ZSTD_BUILD_STATIC ON CACHE BOOL "" FORCE)
set(ZSTD_LEGACY_SUPPORT OFF CACHE BOOL "" FORCE)
option(ZRA_MULTITHREAD "If ZSTD should be built with ZSTD_MULTITHREAD_SUPPORT" TRUE)
if (ZRA_MULTITHREAD)
set(ZSTD_MULTITHREAD_SUPPORT ON CACHE BOOL "" FORCE)
endif ()
add_subdirectory(submodule/zstd/build/cmake)
include_directories("include")
add_library(zra source/zra.cpp)
target_link_libraries(zra PRIVATE libzstd_static)
target_compile_definitions(zra PUBLIC ZRA_EXPORT_HEADER=true)
target_include_directories(zra PUBLIC ${CMAKE_BINARY_DIR}/exports PRIVATE submodule/zstd/lib PRIVATE submodule/zstd/lib/common PRIVATE submodule/CRCpp/inc)
GENERATE_EXPORT_HEADER(zra EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/exports/zra_export.h)
option(BUILD_ZRATOOL "If ZraTool is build or not" FALSE)
if (BUILD_ZRATOOL)
add_executable(ZraTool programs/zratool.cpp)
target_link_libraries(ZraTool zra)
endif ()