-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
132 lines (102 loc) · 3.44 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
128
129
130
131
132
# author Philippe Verney from F2I-CONSULTING
cmake_minimum_required(VERSION 3.6)
project(minizip VERSION 1.1)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
find_package(ZLIB)
add_library(${PROJECT_NAME} "")
add_library(minizip::${PROJECT_NAME} ALIAS minizip)
target_sources(${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/crypt.h"
"${CMAKE_CURRENT_LIST_DIR}/ioapi.c"
"${CMAKE_CURRENT_LIST_DIR}/ioapi.h"
"${CMAKE_CURRENT_LIST_DIR}/unzip.h"
"${CMAKE_CURRENT_LIST_DIR}/unzip.c"
"${CMAKE_CURRENT_LIST_DIR}/zip.h"
"${CMAKE_CURRENT_LIST_DIR}/zip.c"
)
if(WIN32)
target_sources(${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/iowin32.h"
"${CMAKE_CURRENT_LIST_DIR}/iowin32.c"
)
endif()
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_d" EXPORT_NAME minizip)
include(GNUInstallDirs)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT minizip_headers
FILES_MATCHING PATTERN "*.h"
PATTERN ".git" EXCLUDE
REGEX "iowin32.h" EXCLUDE
)
if(WIN32)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/iowin32.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT minizip_headers
)
endif()
include(CMakePackageConfigHelpers)
######## 1. Build tree
export(TARGETS ${PROJECT_NAME}
NAMESPACE minizip::
FILE "${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake"
)
export(PACKAGE ${PROJECT_NAME})
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/lib/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)
######## 2. Install tree
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT ${PROJECT_NAME}_applications
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${PROJECT_NAME}_libraries
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT ${PROJECT_NAME}_libraries
)
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE minizip::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT ${PROJECT_NAME}_libraries
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT ${PROJECT_NAME}_libraries
)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)
install(FILES "${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT ${PROJECT_NAME}_libraries
)