-
Notifications
You must be signed in to change notification settings - Fork 108
/
CMakeLists.txt
134 lines (108 loc) · 4.07 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
133
134
cmake_minimum_required(VERSION 3.14)
project(ppl.cv)
include(cmake/deps.cmake)
# --------------------------------------------------------------------------- #
option(PPLCV_INSTALL "install ppl.cv libs and headers" ON)
option(PPLCV_BUILD_TESTS "build tests" OFF)
option(PPLCV_BUILD_BENCHMARK "build benchmark" OFF)
option(PPLCV_HOLD_DEPS "don't update dependencies" OFF)
if(MSVC)
option(PPLCV_USE_MSVC_STATIC_RUNTIME "" ON)
endif()
option(PPLCV_USE_X86_64 "" OFF)
option(PPLCV_USE_AARCH64 "" OFF)
option(PPLCV_USE_CUDA "" OFF)
option(PPLCV_USE_RISCV64 "" OFF)
option(PPLCV_USE_OPENCL "" OFF)
# deprecated options
if(HPCC_USE_X86_64 AND NOT PPLCV_USE_X86_64)
message(FATAL_ERROR "`HPCC_USE_X86_64` is deprecated. use `PPLCV_USE_X86_64` instead.")
endif()
if(HPCC_USE_AARCH64 AND NOT PPLCV_USE_AARCH64)
message(FATAL_ERROR "`HPCC_USE_AARCH64` is deprecated. use `PPLCV_USE_AARCH64` instead.")
endif()
if(HPCC_USE_CUDA AND NOT PPLCV_USE_CUDA)
message(FATAL_ERROR "`HPCC_USE_CUDA` is deprecated. use `PPLCV_USE_CUDA` instead.")
endif()
# --------------------------------------------------------------------------- #
set(PPLCV_VERSION_MAJOR 0)
set(PPLCV_VERSION_MINOR 7)
set(PPLCV_VERSION_PATCH 0)
# --------------------------------------------------------------------------- #
set(PPLCV_SRC )
set(PPLCV_BENCHMARK_SRC )
set(PPLCV_UNITTEST_SRC )
set(PPLCV_INCLUDE_DIRECTORIES )
set(PPLCV_LINK_LIBRARIES )
set(PPLCV_COMPILE_DEFINITIONS )
# --------------------------------------------------------------------------- #
if(PPLCV_USE_MSVC_STATIC_RUNTIME)
hpcc_use_msvc_static_runtime()
else()
hpcc_use_msvc_dynamic_runtime()
endif()
# --------------------------------------------------------------------------- #
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0")
# suppress 'CMAKE_CUDA_ARCHITECTURES' warning
cmake_policy(SET CMP0104 OLD)
endif()
if(PPLCV_USE_X86_64)
include(cmake/x86.cmake)
endif()
if(PPLCV_USE_CUDA)
include(cmake/cuda.cmake)
endif()
if(PPLCV_USE_AARCH64)
include(cmake/arm.cmake)
endif()
if(PPLCV_USE_RISCV64)
include(cmake/riscv.cmake)
endif()
if(PPLCV_USE_OPENCL)
include(cmake/ocl.cmake)
endif()
hpcc_populate_dep(pplcommon)
list(FILTER PPLCV_SRC EXCLUDE REGEX "(.*)_unittest\\.cpp$")
list(FILTER PPLCV_SRC EXCLUDE REGEX "(.*)_benchmark\\.cpp$")
add_library(pplcv_static STATIC ${PPLCV_SRC})
if(PPLCV_USE_OPENCL)
target_include_directories(pplcv_static PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${CMAKE_CURRENT_BINARY_DIR}
${PPLCV_INCLUDE_DIRECTORIES})
else()
target_include_directories(pplcv_static PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
${PPLCV_INCLUDE_DIRECTORIES})
endif()
target_link_libraries(pplcv_static PUBLIC pplcommon_static ${PPLCV_LINK_LIBRARIES})
target_compile_definitions(pplcv_static PUBLIC
${PPLCV_COMPILE_DEFINITIONS}
PPLCV_VERSION_MAJOR=${PPLCV_VERSION_MAJOR}
PPLCV_VERSION_MINOR=${PPLCV_VERSION_MINOR}
PPLCV_VERSION_PATCH=${PPLCV_VERSION_PATCH})
target_compile_options(pplcv_static PRIVATE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>>>:-fno-exceptions -Wno-strict-aliasing>)
target_compile_features(pplcv_static PUBLIC cxx_std_11)
if(PPLCV_INSTALL)
install(DIRECTORY include DESTINATION .)
install(TARGETS pplcv_static DESTINATION lib)
set(PPLCV_CMAKE_CONFIG_FILE ${CMAKE_CURRENT_BINARY_DIR}/generated/pplcv-config.cmake)
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/pplcv-config.cmake.in
${PPLCV_CMAKE_CONFIG_FILE}
@ONLY)
install(FILES ${PPLCV_CMAKE_CONFIG_FILE} DESTINATION lib/cmake/ppl)
unset(PPLCV_CMAKE_CONFIG_FILE)
endif()
if(PPLCV_BUILD_TESTS OR PPLCV_BUILD_BENCHMARK)
include(cmake/opencv.cmake)
if (PPLCV_BUILD_TESTS)
include(cmake/unittest.cmake)
endif()
if(PPLCV_BUILD_BENCHMARK)
include(cmake/benchmark.cmake)
endif()
endif()