-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathCMakeLists.txt
106 lines (90 loc) · 3.6 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
#
# Copyright © 2022 Github Lzhiyong
#
# 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.
#
cmake_minimum_required(VERSION 3.14.2)
project(sdk-tools)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
enable_language(ASM)
# set global cflags and cxxflags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes")
# static link (may need some patches)
#set(CMAKE_EXE_LINKER_FLAGS "-static")
# platform tools version
# see the patches/other/platform_tools_version.h
set(TOOLS_VERSION 35.0.2)
set(SRC ${PROJECT_SOURCE_DIR}/src)
# 64-bit off_t for lseek.
add_definitions(-D_FILE_OFFSET_BITS=64)
set(PROTOC_COMPILER)
if(DEFINED PROTOC_PATH)
set(PROTOC_COMPILER ${PROTOC_PATH})
if(NOT EXISTS ${PROTOC_COMPILER})
unset(PROTOC_PATH CACHE)
message(FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER}, please check if the path is correct")
endif()
# check protoc version
execute_process(
COMMAND ${PROTOC_COMPILER} --version
OUTPUT_VARIABLE PTOTOBUF_VERSION
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(NOT PTOTOBUF_VERSION MATCHES "^libprotoc*")
unset(PROTOC_PATH CACHE)
message(FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER}, this may not be an executable")
endif()
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" VERSIONS ${PTOTOBUF_VERSION})
# please note that if the protobuf version is too high, you may encounter the following error
# error: This file was generated by a newer version of protoc
if(VERSIONS VERSION_GREATER "3.21.12")
message(WARNING "${PTOTOBUF_VERSION}, the protobuf version is too high, may be incompatible!!")
endif()
endif()
# thrid-party libraries
add_subdirectory(src/boringssl EXCLUDE_FROM_ALL)
add_subdirectory(src/fmtlib EXCLUDE_FROM_ALL)
add_subdirectory(src/pcre EXCLUDE_FROM_ALL)
add_subdirectory(src/libpng EXCLUDE_FROM_ALL)
add_subdirectory(src/zopfli EXCLUDE_FROM_ALL)
add_subdirectory(src/jsoncpp EXCLUDE_FROM_ALL)
add_subdirectory(src/expat/expat EXCLUDE_FROM_ALL)
add_subdirectory(src/zstd/build/cmake EXCLUDE_FROM_ALL)
add_subdirectory(src/lz4/build/cmake EXCLUDE_FROM_ALL)
add_subdirectory(src/brotli EXCLUDE_FROM_ALL)
add_subdirectory(src/abseil-cpp EXCLUDE_FROM_ALL)
add_subdirectory(src/protobuf EXCLUDE_FROM_ALL)
add_subdirectory(src/googletest EXCLUDE_FROM_ALL)
add_subdirectory(src/tinyxml2 EXCLUDE_FROM_ALL)
# building sdk-tools
add_subdirectory(lib)
add_subdirectory(build-tools)
add_subdirectory(platform-tools)
add_subdirectory(others)
# creating source tarballs
set(CPACK_PACKAGE_DIRECTORY ${PROJECT_SOURCE_DIR}/pack)
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_SOURCE_GENERATOR "TXZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${TOOLS_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES
${PROJECT_SOURCE_DIR}/.git
${PROJECT_SOURCE_DIR}/.gitignore
${PROJECT_SOURCE_DIR}/.gitmodules
${PROJECT_SOURCE_DIR}/get_source.py
${PROJECT_SOURCE_DIR}/build
${PROJECT_SOURCE_DIR}/patches
${PROJECT_SOURCE_DIR}/pack
)
include(CPack)