1+ #
2+ # Copyright © 2022 Github Lzhiyong
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ #
16+
117cmake_minimum_required (VERSION 3.14.2)
218project (sdk-tools)
319
4- if (ANDROID_ABI STREQUAL "arm64-v8a" OR ANDROID_ABI STREQUAL "armeabi-v7a" )
5- enable_language (ASM)
6- elseif (ANDROID_ABI STREQUAL "x86_64" OR ANDROID_ABI STREQUAL "x86" )
7- enable_language (ASM_NASM)
8- else ()
9- message (FATAL_ERROR "Unsupported architecture: ${ANDROID_ABI} " )
10- endif ()
20+ set (CMAKE_C_STANDARD 11)
21+ set (CMAKE_CXX_STANDARD 20)
22+ enable_language (ASM)
1123
1224# set global cflags and cxxflags
13- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes -std=gnu11 " )
14- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes -std=gnu++2a " )
25+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes" )
26+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes" )
1527# static link
1628set (CMAKE_EXE_LINKER_FLAGS "-static" )
1729
1830# platform tools version
1931# see the patches/other/platform_tools_version.h
20- set (TOOLS_VERSION 33 .0.1)
32+ set (TOOLS_VERSION 35 .0.1)
2133set (SRC ${PROJECT_SOURCE_DIR} /src)
2234
2335# 64-bit off_t for lseek.
2436add_definitions (-D_FILE_OFFSET_BITS=64)
2537
26- if (NOT DEFINED PROTOC_PATH)
27- message (FATAL_ERROR "PROTOC_PATH undefined, please make sure to build and install protoc from the cloned submodule." )
28- endif ()
38+ set (PROTOC_COMPILER)
39+
40+ if (DEFINED PROTOC_PATH)
41+ set (PROTOC_COMPILER ${PROTOC_PATH} )
2942
30- set (PROTOC_COMPILER ${PROTOC_PATH} )
31-
32- if (NOT EXISTS ${PROTOC_COMPILER} )
33- unset (PROTOC_PATH CACHE )
34- message (FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER} , please check if the path is correct" )
43+ if (NOT EXISTS ${PROTOC_COMPILER} )
44+ unset (PROTOC_PATH CACHE )
45+ message (FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER} , please check if the path is correct" )
46+ endif ()
47+
48+ # check protoc version
49+ execute_process (
50+ COMMAND ${PROTOC_COMPILER} --version
51+ OUTPUT_VARIABLE PTOTOBUF_VERSION
52+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
53+ )
54+
55+ if (NOT PTOTOBUF_VERSION MATCHES "^libprotoc*" )
56+ unset (PROTOC_PATH CACHE )
57+ message (FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER} , this may not be an executable" )
58+ endif ()
59+
60+ string (REGEX MATCH "([0-9]+)\\ .([0-9]+)\\ .([0-9]+)" VERSIONS ${PTOTOBUF_VERSION} )
61+ # please note that if the protobuf version is too high, you may encounter the following error
62+ # error: This file was generated by a newer version of protoc
63+ if (VERSIONS VERSION_GREATER "3.21.12" )
64+ message (WARNING "${PTOTOBUF_VERSION} , the protobuf version is too high, may be incompatible!!" )
65+ endif ()
3566endif ()
3667
3768# thrid-party libraries
3869add_subdirectory (src/boringssl EXCLUDE_FROM_ALL )
3970add_subdirectory (src/fmtlib EXCLUDE_FROM_ALL )
4071add_subdirectory (src/pcre EXCLUDE_FROM_ALL )
41- add_subdirectory (src/expat EXCLUDE_FROM_ALL )
42- add_subdirectory (src/zopfli EXCLUDE_FROM_ALL )
43- add_subdirectory (src/protobuf/cmake EXCLUDE_FROM_ALL )
72+ add_subdirectory (src/libpng EXCLUDE_FROM_ALL )
73+ add_subdirectory (src/jsoncpp EXCLUDE_FROM_ALL )
74+ add_subdirectory (src/expat/expat EXCLUDE_FROM_ALL )
75+ add_subdirectory (src/protobuf EXCLUDE_FROM_ALL )
76+ add_subdirectory (src/googletest EXCLUDE_FROM_ALL )
4477
4578# building sdk-tools
46- add_subdirectory (cmake)
79+ add_subdirectory (lib)
80+ add_subdirectory (build -tools)
81+
0 commit comments