-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
91 lines (71 loc) · 3.17 KB
/
CMakeLists.txt
File metadata and controls
91 lines (71 loc) · 3.17 KB
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
# cmake minimum required version
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 20)
project(njudb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# set debug or release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
set(CMAKE_CXX_FLAGS "-Wall -O3 -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -O0 -g -fPIC")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0 -g -fPIC")
# Lab configuration options - allows users to choose between source compilation and gold libraries
option(USE_GOLD_LAB01 "Use gold library for Lab01 (Buffer Pool)" OFF)
option(USE_GOLD_LAB02 "Use gold library for Lab02 (Executor Basic)" OFF)
option(USE_GOLD_LAB03 "Use gold library for Lab03 (Executor Analysis)" OFF)
option(USE_GOLD_LAB04 "Use gold library for Lab04 (Executor Index & Storage Index)" OFF)
# Detect platform
if(APPLE)
set(LIB_GOLD_PLATFORM "macos")
elseif(UNIX)
set(LIB_GOLD_PLATFORM "linux")
else()
message(FATAL_ERROR "Unsupported platform")
endif()
# Set build type for gold libraries
string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE_LOWER)
set(LIB_GOLD_PATH "${CMAKE_SOURCE_DIR}/lib-gold/${LIB_GOLD_PLATFORM}/${BUILD_TYPE_LOWER}")
# Check if gold libraries exist when needed
if(USE_GOLD_LAB01 OR USE_GOLD_LAB02 OR USE_GOLD_LAB03 OR USE_GOLD_LAB04)
if(NOT EXISTS ${LIB_GOLD_PATH})
message(FATAL_ERROR "Gold library path does not exist: ${LIB_GOLD_PATH}")
endif()
# Add gold library path to RPATH for runtime library resolution
# Prioritize locally built libraries by putting CMAKE_LIBRARY_OUTPUT_DIRECTORY first
set(CMAKE_INSTALL_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY};${LIB_GOLD_PATH}")
set(CMAKE_BUILD_RPATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY};${LIB_GOLD_PATH}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Suppress RPATH warnings for mixed gold/source configurations
# These warnings are generally safe when using compatible libraries
set(CMAKE_SUPPRESS_REGENERATION TRUE)
endif()
# Print configuration
message(STATUS "NJUDB Lab Configuration:")
message(STATUS " Lab01 (Buffer Pool): ${USE_GOLD_LAB01}")
message(STATUS " Lab02 (Executor Basic): ${USE_GOLD_LAB02}")
message(STATUS " Lab03 (Executor Analysis): ${USE_GOLD_LAB03}")
message(STATUS " Lab04 (Executor Index & Storage Index): ${USE_GOLD_LAB04}")
message(STATUS " Platform: ${LIB_GOLD_PLATFORM}")
message(STATUS " Build Type: ${CMAKE_BUILD_TYPE}")
if(USE_GOLD_LAB01 OR USE_GOLD_LAB02 OR USE_GOLD_LAB03 OR USE_GOLD_LAB04)
message(STATUS " Gold Library Path: ${LIB_GOLD_PATH}")
endif()
# Include the lab configuration helper
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(NJUDBLabConfig)
# Pre-declare gold libraries if needed
njudb_predeclare_gold_libraries()
include_directories(src)
include_directories(third_party/fmt/include)
include_directories(third_party/argparse/include)
add_subdirectory(src)
add_subdirectory(client)
add_subdirectory(common)
set(INSTALL_GTEST OFF)
add_subdirectory(third_party/googletest)
add_subdirectory(third_party/fmt)
enable_testing()
add_subdirectory(test)