forked from ApsaraDB/PolarDB-FileSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
108 lines (89 loc) · 3.41 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
# Copyright (c) 2017-2021, Alibaba Group Holding Limited
# 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 2.8)
project(pfsd CXX C ASM)
message("compile pfsd for PostgreSQL")
set(CMAKE_BUILD_TYPE "Release")
#set(CMAKE_BUILD_TYPE "Debug")
include(CMakeLists-config.txt)
set(COMMON_FLAGS
-fno-strict-aliasing
#-fstack-protector
#-fsanitize=address
#-DEV_STANDALONE
-Wall
-Werror
-Wno-deprecated-declarations
-Wno-unused-result
-Wno-format-overflow
-Wno-misleading-indentation
-Wno-format-truncation
-Wno-stringop-truncation
-Wno-int-in-bool-context
-Wno-stringop-overflow
-Wno-error=attributes
-Wextra -Wno-unused-parameter -Wno-missing-field-initializers
-Wno-missing-declarations -fno-strict-aliasing
-Wformat -Wformat-security -Wformat-nonliteral
-g
)
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(COMMON_FLAGS ${COMMON_FLAGS} -march=native -m64)
endif()
set(CMAKE_EXE_LINKER_FLAGS
# Enable full RELRO - no lazy relocation (resolve everything at load time).
# This allows the GOT to be made read-only early in the loading process.
-Wl,-z,relro,-z,now,-z,noexecstack
# Make the stack non-executable.
# This is the default in most environments, but it doesn't hurt to set it explicitly.
#-Wl,-z,noexecstack
)
set(COMMON_FLAGS ${COMMON_FLAGS} -DPFS_DISK_IO_ONLY)
set(CXX_FLAGS
${COMMON_FLAGS}
-std=c++11
-Wno-deprecated
-Wno-unused-local-typedefs
-Wno-sign-compare
-fpermissive
-Wno-unused-variable
-Wno-unused-function
)
set(C_FLAGS
${COMMON_FLAGS}
)
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")
string(REPLACE ";" " " CMAKE_C_FLAGS "${C_FLAGS}")
set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_C_COMPILER "cc")
set(DEBUG_LEVEL 20)
set(RELEASE_LEVEL 40)
if(DEFINED ENV{POLAR_LOG_DEBUG_LEVEL})
set(DEBUG_LEVEL $ENV{POLAR_LOG_DEBUG_LEVEL})
endif()
if(DEFINED ENV{POLAR_LOG_RELEASE_LEVEL})
set(RELEASE_LEVEL $ENV{POLAR_LOG_RELEASE_LEVEL})
endif()
message("build log level release level "${RELEASE_LEVEL} " debug level "${DEBUG_LEVEL})
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -ggdb -DDEBUG -DCHKSVR_LOG_LEVEL=${DEBUG_LEVEL}")
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -finline-limit=100000 -DNDEBUG -DCHKSVR_LOG_LEVEL=${RELEASE_LEVEL}")
set(CMAKE_C_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -ggdb -DDEBUG -DCHKSVR_LOG_LEVEL=${DEBUG_LEVEL}")
set(CMAKE_C_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -finline-limit=100000 -DNDEBUG -DCHKSVR_LOG_LEVEL=${RELEASE_LEVEL}")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
message(STATUS "CXX_FLAGS = " ${CMAKE_CXX_FLAGS} " " ${CMAKE_CXX_FLAGS_${BUILD_TYPE}})
message(STATUS "C_FLAGS = " ${CMAKE_C_FLAGS} " " ${CMAKE_C_FLAGS_${BUILD_TYPE}})
execute_process(COMMAND mkdir -p ${PROJECT_SOURCE_DIR}/include)
execute_process(COMMAND cp ${PROJECT_SOURCE_DIR}/src/pfs_sdk/pfsd_sdk.h ${PROJECT_SOURCE_DIR}/include/)
add_subdirectory(src)