-
Notifications
You must be signed in to change notification settings - Fork 71
/
CMakeLists.txt
46 lines (33 loc) · 1.39 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
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(zstr LANGUAGES CXX)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.12)
cmake_policy(SET CMP0074 NEW) # find_package uses <PackageName>_ROOT variables
endif()
if(${CMAKE_VERSION} VERSION_LESS 3.13)
message(WARNING
"Interface library targets are not well supported before cmake 3.13 .... "
"You may need to add \${ZSTR_INCLUDE_DIRS} to your include directories\n"
"target_include_directories(YourTarget PRIVATE \${ZSTR_INCLUDE_DIRS}) "
)
endif()
# -- locate zlib
find_package(ZLIB 1.2.3 REQUIRED) # defines imported target ZLIB::ZLIB
message(STATUS "zstr - found ZLIB (version: ${ZLIB_VERSION_STRING})")
# -- add target
add_library(zstr INTERFACE)
add_library(zstr::zstr ALIAS zstr)
# -- set target properties
target_include_directories(zstr INTERFACE "${PROJECT_SOURCE_DIR}/src")
target_link_libraries(zstr INTERFACE ZLIB::ZLIB)
target_compile_features(zstr INTERFACE cxx_std_11) # require c++11 flag
# -- set cache variables
# NOTE: these vars are mostly useful to people using cmake < 3.13
set(ZSTR_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src;${ZLIB_INCLUDE_DIRS}" CACHE PATH "" FORCE)
set(ZSTR_LIBRARIES "${ZLIB_LIBRARIES}" CACHE PATH "" FORCE)
# -- print target summary
message(STATUS
"zstr - added INTERFACE target 'zstr::zstr'
includes : ${ZSTR_INCLUDE_DIRS}
libraries: ZLIB::ZLIB
features : cxx_std_11"
)