forked from OpenPPL/ppl.common
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
103 lines (80 loc) · 2.95 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
cmake_minimum_required(VERSION 3.14)
project(ppl.common)
include(cmake/deps.cmake)
# --------------------------------------------------------------------------- #
option(PPLCOMMON_BUILD_TESTS "build tests" ON)
option(PPLCOMMON_BUILD_BENCHMARK "build benchmark" ON)
option(PPLCOMMON_INSTALL "install ppl.common headers and libs" ON)
option(PPLCOMMON_ENABLE_PYTHON_API "enable python api support" OFF)
option(PPLCOMMON_HOLD_DEPS "don't update dependencies" OFF)
option(PPLCOMMON_STDIO_LOG_COLOR "" ON)
option(PPLCOMMON_USE_X86_64 "" OFF)
option(PPLCOMMON_USE_AARCH64 "" OFF)
option(PPLCOMMON_USE_ARMV7 "" OFF)
option(PPLCOMMON_USE_CUDA "" OFF)
option(PPLCOMMON_USE_OPENCL "" OFF)
# deprecated options
if(HPCC_USE_X86_64)
message(FATAL_ERROR "`HPCC_USE_X86_64` is deprecated. use `PPLCOMMON_USE_X86_64` instead.")
endif()
if(HPCC_USE_AARCH64)
message(FATAL_ERROR "`HPCC_USE_AARCH64` is deprecated. use `PPLCOMMON_USE_AARCH64` instead.")
endif()
if(HPCC_USE_CUDA)
message(FATAL_ERROR "`HPCC_USE_CUDA` is deprecated. use `PPLCOMMON_USE_CUDA` instead.")
endif()
# --------------------------------------------------------------------------- #
if(PPLCOMMON_ENABLE_PYTHON_API)
add_subdirectory(python)
endif()
file(GLOB PPLCOMMON_SRC
src/ppl/common/*.cc)
if(MSVC)
file(GLOB __win_src__ src/ppl/common/windows/*.cc)
list(APPEND PPLCOMMON_SRC ${__win_src__})
unset(__win_src__)
endif()
set(PPLCOMMON_INCLUDES)
list(APPEND PPLCOMMON_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(PPLCOMMON_LINK_LIBRARIES)
set(PPLCOMMON_LINK_DIRECTORIES)
set(PPLCOMMON_DEFINITIONS)
if(PPLCOMMON_USE_X86_64)
include(cmake/x86.cmake)
endif()
if(PPLCOMMON_USE_AARCH64 OR PPLCOMMON_USE_ARMV7)
include(cmake/arm.cmake)
endif()
if(PPLCOMMON_USE_OPENCL)
include(cmake/ocl.cmake)
endif()
if(PPLCOMMON_USE_CUDA)
include(cmake/cuda.cmake)
endif()
if(PPLCOMMON_STDIO_LOG_COLOR)
list(APPEND PPLCOMMON_DEFINITIONS PPLCOMMON_STDIO_LOG_COLOR)
endif()
list(FILTER PPLCOMMON_SRC EXCLUDE REGEX "(.*)_unittest\\.cc$")
list(FILTER PPLCOMMON_SRC EXCLUDE REGEX "(.*)_benchmark\\.cc$")
# --------------------------------------------------------------------------- #
# for pplcommon_static and pplcommon-config.cmake
if(NOT MSVC)
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Android" AND NOT ANDROID)
list(APPEND PPLCOMMON_LINK_LIBRARIES pthread)
endif()
endif()
add_library(pplcommon_static STATIC ${PPLCOMMON_SRC})
target_link_libraries(pplcommon_static PUBLIC ${PPLCOMMON_LINK_LIBRARIES})
target_link_directories(pplcommon_static PUBLIC ${PPLCOMMON_LINK_DIRECTORIES})
target_include_directories(pplcommon_static PUBLIC ${PPLCOMMON_INCLUDES})
target_compile_definitions(pplcommon_static PUBLIC ${PPLCOMMON_DEFINITIONS})
target_compile_features(pplcommon_static PUBLIC cxx_std_11)
if(PPLCOMMON_INSTALL)
include(cmake/install.cmake)
endif()
if(PPLCOMMON_BUILD_TESTS)
include(cmake/unittest.cmake)
endif()
if(PPLCOMMON_BUILD_BENCHMARK)
include(cmake/benchmark.cmake)
endif()