-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
89 lines (65 loc) · 2.33 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
cmake_minimum_required(VERSION 3.9.0)
set(CMAKE_VERBOSE_MAKEFILE OFF)
project(yukihttp VERSION 1.0.0 LANGUAGES CXX)
add_library(yukihttp SHARED src/request.cpp src/mime.cpp src/mime_part.cpp src/slist_wrapper.cpp src/utils.cpp src/mime_wrapper.cpp)
target_compile_features(yukihttp PRIVATE cxx_std_17)
target_compile_options(yukihttp PRIVATE -Wall -Wextra -Wpedantic -Wunused-parameter -Wunreachable-code)
target_include_directories(yukihttp
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
find_package(CURL 7.56 REQUIRED)
target_link_libraries(yukihttp
PRIVATE
${CURL_LIBRARIES}
)
find_package(Boost REQUIRED)
target_link_libraries(yukihttp
PRIVATE
${Boost_LIBRARIES}
)
# Installation instructions
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/yukiHTTP)
install(TARGETS yukihttp
EXPORT yukihttp-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
#This is required so that the exported target has the name yukiHTTP and not yukihttp
set_target_properties(yukihttp PROPERTIES EXPORT_NAME yukiHTTP)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
#Export the targets to a script
install(EXPORT yukihttp-targets
FILE
yukiHTTPTargets.cmake
NAMESPACE
yukiHTTP::
DESTINATION
${INSTALL_CONFIGDIR}
)
#Create a ConfigVersion.cmake file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/yukiHTTPConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/yukiHTTPConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/yukiHTTPConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
#Install the config, configversion and custom find modules
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/yukiHTTPConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/yukiHTTPConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
##############################################
## Exporting from the build tree
export(EXPORT yukihttp-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/yukiHTTPTargets.cmake NAMESPACE yukiHTTP::)
#Register package in user's package registry
export(PACKAGE yukiHTTP)