-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
98 lines (81 loc) · 2.37 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
cmake_minimum_required(VERSION 3.13)
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed. You should create separate directory for build files.")
endif()
set(VERSION "24.4")
set(PACKAGE "nzbget")
set(LIBS "")
set(INCLUDES ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
set(PACKAGE_BUGREPORT "https://github.com/nzbgetcom/nzbget/issues")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_EXTENSIONS OFF)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" VERSION_MATCH ${VERSION})
set(VERSION_MAJOR ${CMAKE_MATCH_1})
set(VERSION_MINOR ${CMAKE_MATCH_2})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
option(BUILD_ONLY_TESTS "Build only tests (for CI)")
project(
nzbget
VERSION ${VERSION}
DESCRIPTION "NZBGet is a binary downloader, which downloads files from Usenet"
LANGUAGES C CXX
)
include(cmake/common.cmake)
include(daemon/sources.cmake)
if(NOT BUILD_ONLY_TESTS)
add_executable(${PACKAGE} ${SRC})
target_precompile_headers(${PACKAGE} PRIVATE ${CMAKE_SOURCE_DIR}/daemon/main/nzbget.h)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_custom_command(
TARGET ${PACKAGE} POST_BUILD
DEPENDS ${PACKAGE}
COMMAND ${CMAKE_STRIP}
ARGS ${PACKAGE}
)
endif()
endif()
if(WIN32)
include(cmake/windows.cmake)
if(NOT BUILD_ONLY_TESTS)
target_sources(${PACKAGE} PRIVATE ${CMAKE_SOURCE_DIR}/windows/resources/nzbget.rc)
configure_file(
${CMAKE_SOURCE_DIR}/windows/resources/version.rc.in
${CMAKE_BINARY_DIR}/version.rc
)
configure_file(
${CMAKE_SOURCE_DIR}/windows/version.nsi.in
${CMAKE_BINARY_DIR}/version.nsi
@ONLY
)
configure_file(
${CMAKE_SOURCE_DIR}/windows/version-uninstall.nsi.in
${CMAKE_BINARY_DIR}/version-uninstall.nsi
@ONLY
)
target_sources(${PACKAGE} PRIVATE ${CMAKE_BINARY_DIR}/version.rc)
endif()
else()
include(cmake/posix.cmake)
if(NOT BUILD_ONLY_TESTS)
include(${CMAKE_SOURCE_DIR}/cmake/install.cmake)
endif()
endif()
include(lib/sources.cmake)
configure_file(
${CMAKE_SOURCE_DIR}/cmake/config.h.in
${CMAKE_BINARY_DIR}/config.h
)
if(NOT BUILD_ONLY_TESTS)
target_link_libraries(${PACKAGE} PRIVATE ${LIBS})
target_include_directories(${PACKAGE} PRIVATE ${INCLUDES})
endif()
if(ENABLE_TESTS OR BUILD_ONLY_TESTS)
include(CTest)
add_subdirectory(tests)
endif()