-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
90 lines (74 loc) · 2.3 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
cmake_minimum_required(VERSION 3.19)
project(pr-downloader)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "" FORCE)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULES_DOWNLOADER "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_MODULES_DOWNLOADER}")
include(UtilGit)
if(GIT_FOUND)
git_util_describe(PR_DOWNLOADER_VERSION "${CMAKE_CURRENT_SOURCE_DIR}/src" "*")
endif()
# Version couldn't be detected, we guess its compiled from tarball
if("${PR_DOWNLOADER_VERSION}" STREQUAL "")
set(PR_DOWNLOADER_VERSION "tarball")
endif()
message(STATUS "PR-Downloader version: ${PR_DOWNLOADER_VERSION}")
set(PRD_BINDIR "." CACHE PATH "Where to install pr-downloader binary.")
# Resolve dependencies.
# Threads
find_package(Threads REQUIRED)
# CURL
if(UNIX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl>=7.84)
add_library(prd::libcurl ALIAS PkgConfig::libcurl)
else()
find_package(CURL 7.85 REQUIRED)
add_library(prd::libcurl ALIAS CURL::libcurl)
endif()
# ZLIB
find_package(ZLIB REQUIRED)
# jsoncpp
if(UNIX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(jsoncpp IMPORTED_TARGET GLOBAL jsoncpp)
if(jsoncpp_FOUND)
add_library(prd::jsoncpp ALIAS PkgConfig::jsoncpp)
endif()
endif()
if(NOT jsoncpp_FOUND)
message(STATUS "Not found jsoncpp in system, using integrated version")
add_subdirectory(src/lib/jsoncpp)
add_library(prd::jsoncpp ALIAS pr-jsoncpp)
endif()
# minizip
if(UNIX)
find_package(PkgConfig REQUIRED)
pkg_check_modules(minizip IMPORTED_TARGET minizip)
if(minizip_FOUND)
add_library(prd::minizip ALIAS PkgConfig::minizip)
endif()
else()
find_package(minizip)
if(minizip_FOUND)
add_library(prd::minizip ALIAS minizip::minizip)
endif()
endif()
if(NOT minizip_FOUND)
message(STATUS "Not found minizip in system, using integrated version")
add_subdirectory(src/lib/minizip)
add_library(prd::minizip ALIAS pr-minizip)
endif()
add_subdirectory(src/lib)
add_library(prd::base64 ALIAS pr-base64)
# Include actual program source
add_subdirectory(src)
option(PRD_TESTS "Build tests" OFF)
if(PRD_TESTS)
enable_testing()
add_subdirectory(test)
endif()