-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
73 lines (60 loc) · 1.81 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
cmake_minimum_required(VERSION 3.20)
project(toolbox-cpp
VERSION 0.0.1
DESCRIPTION "collection of snippets for C++17"
HOMEPAGE_URL https://github.com/gh4ck3r/toolbox-cpp
LANGUAGES CXX
)
option(GH4CK3R_USE_HTTP "use http server/client; It depends other projects")
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(compiledb)
# use package from host first
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
add_library(gh4ck3r INTERFACE)
set_property(TARGET gh4ck3r APPEND PROPERTY PUBLIC_HEADER
include/gh4ck3r/base64.hh
include/gh4ck3r/concat.hh
include/gh4ck3r/defer.hh
include/gh4ck3r/hexdump.hh
include/gh4ck3r/lazygetter.hh
include/gh4ck3r/logger.hh
include/gh4ck3r/recipe.hh
include/gh4ck3r/type_traits.hh
include/gh4ck3r/typemap.hh
include/gh4ck3r/singleton.hh
)
target_compile_features(gh4ck3r INTERFACE cxx_std_17)
target_include_directories(gh4ck3r INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(GH4CK3R_USE_HTTP)
find_package(httplib REQUIRED)
else()
find_package(httplib QUIET)
endif()
if (TARGET httplib::httplib)
target_include_directories(gh4ck3r
INTERFACE
$<$<BOOL:${httplib_FOUND}>:${HTTPLIB_INCLUDE_DIR}>
)
target_link_libraries(gh4ck3r INTERFACE httplib::httplib)
endif()
find_package(OpenSSL REQUIRED)
if(OpenSSL_FOUND)
set_property(TARGET gh4ck3r APPEND PROPERTY PUBLIC_HEADER
include/gh4ck3r/crypto.hh
)
link_libraries(gh4ck3r OpenSSL::Crypto)
endif()
set_target_properties(gh4ck3r PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
DEBUG_POSTFIX d
)
include(GNUInstallDirs)
install(TARGETS gh4ck3r
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gh4ck3r
)
enable_testing()
add_subdirectory(test)