-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
58 lines (49 loc) · 2.35 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
if(POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif()
MESSAGE(STATUS "Cmake output binray directory: ${CMAKE_BINARY_DIR}")
# Project Info
SET(CMAKE_CXX_STANDARD 17)
PROJECT(MiniSQL
VERSION 2022.1
DESCRIPTION "ZheJiang University 2021~2022 Spring-Summer Database System Project"
LANGUAGES C CXX)
# CTest
enable_testing()
# Options
ADD_DEFINITIONS(-DENABLE_DEBUG)
# ADD_DEFINITIONS(-DENABLE_EXECUTE_DEBUG)
# ADD_DEFINITIONS(-DENABLE_PARSER_DEBUG)
# ADD_DEFINITIONS(-DENABLE_BPM_DEBUG)
# ADD_DEFINITIONS(-DSHOW_PAGE_SPLIT)
# Set Include Directory
SET(THIRD_PARTY_DIR ${PROJECT_SOURCE_DIR}/thirdparty)
SET(MINISQL_SRC_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include)
SET(MINISQL_TEST_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/test/include)
SET(MINISQL_GTEST_INCLUDE_DIR ${THIRD_PARTY_DIR}/googletest/include)
SET(MINISQL_GLOG_INCLUDE_DIR ${THIRD_PARTY_DIR}/glog/src)
INCLUDE_DIRECTORIES(${MINISQL_SRC_INCLUDE_DIR} ${MINISQL_TEST_INCLUDE_DIR} ${MINISQL_GTEST_INCLUDE_DIR} ${MINISQL_GLOG_INCLUDE_DIR})
# Add gtest
ADD_SUBDIRECTORY(${THIRD_PARTY_DIR}/googletest ${CMAKE_BINARY_DIR}/googletest-build)
# Add glog
ADD_SUBDIRECTORY(${THIRD_PARTY_DIR}/glog ${CMAKE_BINARY_DIR}/glog-build)
target_compile_options(gtest PRIVATE "-fPIC")
target_compile_options(gtest_main PRIVATE "-fPIC")
# Compiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wextra -Werror -march=native")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
# set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC")
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIC")
# set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -fPIC")
# set(GCC_COVERAGE_LINK_FLAGS "-fPIC")
# message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
# message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
# message(STATUS "CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}")
# Add Subdirectory
ADD_SUBDIRECTORY(src ${CMAKE_BINARY_DIR}/bin)
ADD_SUBDIRECTORY(test ${CMAKE_BINARY_DIR}/test)