Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
106 lines (82 loc) · 3.51 KB
/
Copy pathCMakeLists.txt
File metadata and controls
106 lines (82 loc) · 3.51 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 3.20)
project(sageFlow CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# 是否启用运行时指标采集代码(通过编译宏控制)。默认开启以保持现有行为。
option(SAGEFLOW_ENABLE_METRICS "Enable metrics instrumentation in join/operator and tests" ON)
message(STATUS "SAGEFLOW_ENABLE_METRICS: ${SAGEFLOW_ENABLE_METRICS}")
# 启用测试选项(CLion 识别 gtest 必需)
option(BUILD_TESTING "Build tests" ON)
if(BUILD_TESTING)
enable_testing()
endif()
set(_sage_flow_shared_deps FALSE)
if(DEFINED SAGE_COMMON_DEPS_FILE AND EXISTS "${SAGE_COMMON_DEPS_FILE}")
include("${SAGE_COMMON_DEPS_FILE}")
set(_sage_flow_shared_deps TRUE)
endif()
set(_sage_flow_enable_gperftools_default OFF)
if(DEFINED SAGE_ENABLE_GPERFTOOLS)
set(_sage_flow_enable_gperftools_default ${SAGE_ENABLE_GPERFTOOLS})
endif()
option(ENABLE_GPERFTOOLS "Enable gperftools profiling support" ${_sage_flow_enable_gperftools_default})
if(DEFINED SAGE_ENABLE_GPERFTOOLS)
set(ENABLE_GPERFTOOLS ${SAGE_ENABLE_GPERFTOOLS} CACHE BOOL "Enable gperftools profiling support" FORCE)
endif()
include(cmake/macros.cmake)
if(ENABLE_GPERFTOOLS)
if(NOT _sage_flow_shared_deps OR NOT (DEFINED SAGE_GPERFTOOLS_LIBS AND SAGE_GPERFTOOLS_LIBS))
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/gperftools.cmake)
endif()
if(NOT (DEFINED SAGE_GPERFTOOLS_LIBS AND SAGE_GPERFTOOLS_LIBS))
message(WARNING "ENABLE_GPERFTOOLS requested but gperftools libraries were not found; disabling support")
set(ENABLE_GPERFTOOLS OFF CACHE BOOL "Enable gperftools profiling support" FORCE)
endif()
endif()
# 先构建第三方库,确保 gtest/gtest_main 目标可用
add_subdirectory(third-party)
include(cmake/enableTest.cmake)
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(
CMAKE_CXX_FLAGS
"-Wall -Werror=return-type -Wno-error=unused-variable -Wno-error=unused-parameter -fPIC"
)
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -DNO_RACE_CHECK")
set(CMAKE_CXX_FLAGS_RELEASE "-Wno-ignored-qualifiers -Wno-sign-compare -O3")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
include_directories(
include
)
add_definitions(
-DPROJECT_DIR="${CMAKE_SOURCE_DIR}"
)
if(ENABLE_GPERFTOOLS)
add_definitions(-DENABLE_GPERFTOOLS)
endif()
# 全局启用指标收集宏,使得所有包含 monitoring.h 的代码都能正确启用指标
if(SAGEFLOW_ENABLE_METRICS)
add_definitions(-DSAGEFLOW_ENABLE_METRICS=1)
endif()
add_subdirectory(src)
# 只在需要时添加测试和示例(避免循环依赖问题)
if(BUILD_TESTING)
add_subdirectory(test)
add_subdirectory(examples)
endif()
# ============================================================================
# ============================================================================
# Python bindings (optional, auto-enabled for wheel builds)
# ============================================================================
option(BUILD_PYTHON_BINDINGS "Build Python bindings" OFF)
# Auto-enable for scikit-build-core wheel builds
if(SKBUILD)
set(BUILD_PYTHON_BINDINGS ON CACHE BOOL "Build Python bindings (auto-enabled by SKBUILD)" FORCE)
message(STATUS "SKBUILD detected: Auto-enabling BUILD_PYTHON_BINDINGS")
endif()
if(BUILD_PYTHON_BINDINGS)
message(STATUS "Building Python bindings for sage_flow")
add_subdirectory(sage_flow)
endif()