-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
146 lines (117 loc) · 5.43 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
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright (c) 2018 NoobsHPC Authors, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set(MIN_CMAKE_V 3.0)
cmake_minimum_required(VERSION ${MIN_CMAKE_V} FATAL_ERROR)
project(NBHPC C CXX)
include(cmake/colors.cmake)
include(cmake/utils.cmake)
# ----------------------------------------------------------------------------
# section: global noobshpc version and lib name
# ----------------------------------------------------------------------------
# global noobshpc version 0.0.1
set(VERSION_MAJOR "0")
set(VERSION_MINOR "0")
set(VERSION_PATCH "1")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
# noobshpc lib name and global directories
set(noobshpc_lib_so "noobshpc")
set(noobshpc_lib_static "noobshpc_static")
# set root dir of modules
set(NBHPC_ROOT ${PROJECT_SOURCE_DIR})
set(NBHPC_CMAKE ${NBHPC_ROOT}/cmake)
set(NBHPC_UTILS ${NBHPC_ROOT}/utils)
set(NBHPC_INCLUDE ${NBHPC_ROOT}/include)
set(NBHPC_ICESWORD ${NBHPC_ROOT}/icesword)
set(NBHPC_UNIT_TEST ${NBHPC_ROOT}/unit_test)
set(NBHPC_BENCHMARK ${NBHPC_ROOT}/benchmark)
set(NBHPC_THIRD_PARTY_PATH ${NBHPC_ROOT}/third-party)
# set build and output dir
set(NBHPC_BUILD ${NBHPC_ROOT}/build)
set(LIBRARY_OUTPUT_DIRECTORY ${NBHPC_BUILD}/lib)
set(RUNTIME_OUTPUT_DIRECTORY ${NBHPC_BUILD}/output)
# ----------------------------------------------------------------------------
# section: options for noobshpc
# ----------------------------------------------------------------------------
# common build options
noobshpc_option(ENABLE_DEBUG "Enable DEBUG(default) mode." NO)
noobshpc_option(ENABLE_VERBOSE_MSG "Enable verbose=1 : compile msg during make." NO)
noobshpc_option(ENABLE_EXPORT_COMPILE_COMMANDS "Export compile command to json." YES)
noobshpc_option(DISABLE_ALL_WARNINGS "Disable all the warning msg during compile." YES)
noobshpc_option(ENABLE_NOISY_WARNINGS "Enable noisy warning msg during compile." NO if DISABLE_ALL_WARNINGS)
# noobshpc data precision
noobshpc_option(NBHPC_TYPE_FP64 "define the FP64 for data precision." NO)
noobshpc_option(NBHPC_TYPE_FP32 "define the FP32 for data precision." YES)
noobshpc_option(NBHPC_TYPE_FP16 "define the FP16 for data precision." NO)
noobshpc_option(NBHPC_TYPE_INT8 "define the INT8 for data precision." YES)
# using common library
noobshpc_option(USE_OPENMP "Use Openmp." YES)
noobshpc_option(USE_LOGGER "Build baidu logger components." YES)
# select the plantform to build
noobshpc_option(USE_X86_PLACE "Select the build mode for X86 place." YES)
# build components
noobshpc_option(BUILD_WITH_UNIT_TEST "Build noobshpc unit_test components." YES)
noobshpc_option(BUILD_WITH_BENCHMARK "Build noobshpc benchmark components." NO)
# build library target
noobshpc_option(BUILD_SHARED "Build noobshpc shared lib." YES)
noobshpc_option(BUILD_STATIC "Build noobshpc static lib." NO)
# ----------------------------------------------------------------------------
# section: find modules and configure
# ----------------------------------------------------------------------------
if(USE_X86_PLACE)
noobshpc_option(USE_MKLML "Use MKLML libs." YES)
noobshpc_option(USE_XBYAK "Use XBYAK libs." NO)
endif()
if(BUILD_WITH_BENCHMARK )
noobshpc_option(USE_MKLDNN "Use MKLDNN libs." YES)
endif()
if(USE_MKLML)
include(${NBHPC_CMAKE}/external/mklml.cmake)
endif()
if(USE_XBYAK)
include(${NBHPC_CMAKE}/external/xbyak.cmake)
endif()
if(USE_MKLDNN)
include(${NBHPC_CMAKE}/external/mkldnn.cmake)
endif()
# ----------------------------------------------------------------------------
# section: noobshpc compiler and linker options
# ----------------------------------------------------------------------------
include(${NBHPC_CMAKE}/compiler.cmake)
# ----------------------------------------------------------------------------
# section: add dir to header files search path
# ----------------------------------------------------------------------------
# add the binary tree to the search path so that noobshpc will find noobshpc_config.h
configure_file ("${PROJECT_SOURCE_DIR}/cmake/config/noobshpc.config"
"${NBHPC_BUILD}/noobshpc_config.h")
include_directories(${NBHPC_ROOT})
include_directories(${NBHPC_INCLUDE})
include_directories(${PROJECT_BINARY_DIR})
# ----------------------------------------------------------------------------
# section: add dir to source files search path
# ----------------------------------------------------------------------------
add_subdirectory(${NBHPC_ICESWORD})
if(BUILD_WITH_UNIT_TEST)
add_subdirectory(${NBHPC_UNIT_TEST})
endif()
if(BUILD_WITH_BENCHMARK)
add_subdirectory(${NBHPC_BENCHMARK})
endif()
# ----------------------------------------------------------------------------
# section: show status
# ----------------------------------------------------------------------------
include(cmake/status.cmake)
# ----------------------------------------------------------------------------
# section: set make doc flag
# ----------------------------------------------------------------------------
include(cmake/doc.cmake)