-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
127 lines (103 loc) · 3.9 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
cmake_minimum_required(VERSION 3.19)
# Disable default MSVC warning level so we can set it ourselves.
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
# Default to release for single target generators if nothing specified.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE)
endif()
# We don't support in tree builds, so help people make the right choice.
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
include(FeatureSummary)
project(LZHL VERSION 1.0.0 LANGUAGES CXX)
# Make sure symbols are not exported by default.
if (NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET AND
NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
endif ()
# configuration options
if(DEFINED LZHL_SHARED_LIBS)
set(BUILD_SHARED_LIBS "${LZHL_SHARED_LIBS}")
endif()
add_feature_info(SharedLibs LZHL_SHARED_LIBS "Generate a shared library for LZHL")
include(GNUInstallDirs)
include(TargetExports)
add_library(lzhl
include/lzhl/lzhl.h
src/huff.cpp
src/lz.cpp
src/lzhl.cpp
src/_huff.h
src/_lz.h
src/_lzhl.h
)
add_library(LZHL::LZHL ALIAS lzhl)
if(BUILD_SHARED_LIBS)
set_target_properties(lzhl PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(lzhl PROPERTIES ARCHIVE_OUTPUT_NAME lzhl.dll)
endif()
# Set the compiler features expected/required
target_compile_features(lzhl PUBLIC cxx_std_11)
set_target_properties(lzhl PROPERTIES SOVERSION ${LZHL_VERSION_MAJOR} VERSION ${LZHL_VERSION})
target_include_directories(lzhl PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>")
target_exports(lzhl SYMBOLS
LZHLCreateCompressor
LZHLCompressorCalcMaxBuf
LZHLCompress
LZHLDestroyCompressor
LZHLCreateDecompressor
LZHLDecompress
LZHLDecompressReset
LZHLDestroyDecompressor
)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" is_top_level)
option(LZHL_INCLUDE_PACKAGING "Include packaging rules for LZHL" "${is_top_level}")
add_feature_info(Packaging LZHL_INCLUDE_PACKAGING "Generate packaging rules for LZHL")
if(LZHL_INCLUDE_PACKAGING)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if (NOT DEFINED LZHL_INSTALL_CMAKEDIR)
set(LZHL_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/LZHL" CACHE STRING "Path to LZHL CMake files")
endif ()
install(TARGETS lzhl
EXPORT LZHL_Targets
RUNTIME COMPONENT LZHL_Runtime
LIBRARY COMPONENT LZHL_Runtime
NAMELINK_COMPONENT LZHL_Development
ARCHIVE COMPONENT LZHL_Development
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(DIRECTORY "${LZHL_SOURCE_DIR}/include/" "${LZHL_BINARY_DIR}/include/"
TYPE INCLUDE
COMPONENT LZHL_Development
)
if(BUILD_SHARED_LIBS)
set(type shared)
else()
set(type static)
endif()
install(EXPORT LZHL_Targets
DESTINATION "${LZHL_INSTALL_CMAKEDIR}"
NAMESPACE LZHL::
FILE LZHL-${type}-targets.cmake
COMPONENT LZHL_Development
)
write_basic_package_version_file(
LZHLConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/LZHLConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LZHLConfigVersion.cmake"
DESTINATION "${LZHL_INSTALL_CMAKEDIR}"
COMPONENT LZHL_Development
)
endif()
feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")