chore: 工程工具 + CMake 修复
- tools/build.sh: 一键编译(支持 Release/Debug/ASan) - tools/run_tests.sh: 运行测试 - tools/release.sh: 发布打包 - tools/format.sh: 代码格式化 - tools/clean.sh: 清理构建产物 - 修复 CMakeLists.txt: vde_compile_options 顺序错误 - 修复 src/CMakeLists.txt: 移除重复配置行
This commit is contained in:
+15
-26
@@ -6,21 +6,22 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# ── 选项 ──────────────────────────────────────────
|
||||
option(BUILD_TESTS "Build unit tests" ON)
|
||||
option(BUILD_EXAMPLES "Build examples" ON)
|
||||
# ── 选项 ──
|
||||
option(BUILD_TESTS "Build unit tests" ON)
|
||||
option(BUILD_EXAMPLES "Build examples" ON)
|
||||
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
|
||||
option(BUILD_SHARED_LIBS "Build shared library" OFF)
|
||||
option(ENABLE_SANITIZERS "Enable ASan/UBSan" OFF)
|
||||
option(ENABLE_LTO "Enable LTO" ON)
|
||||
option(VDE_BUILD_PYTHON "Build Python bindings" OFF)
|
||||
|
||||
# ── 编译设置 ──────────────────────────────────────
|
||||
# ── 编译选项接口(必须在 include(CompilerSettings) 之前创建)──
|
||||
add_library(vde_compile_options INTERFACE)
|
||||
include(cmake/CompilerSettings.cmake)
|
||||
|
||||
# ── 依赖 ──────────────────────────────────────────
|
||||
# ── 依赖 ──
|
||||
find_package(Eigen3 3.3 QUIET)
|
||||
if(NOT Eigen3_FOUND)
|
||||
message(STATUS "Eigen3 not found — using FetchContent")
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(Eigen3
|
||||
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
|
||||
@@ -28,11 +29,10 @@ if(NOT Eigen3_FOUND)
|
||||
FetchContent_MakeAvailable(Eigen3)
|
||||
endif()
|
||||
|
||||
# ── 子目录 ────────────────────────────────────────
|
||||
# ── 子目录 ──
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(src)
|
||||
|
||||
# ── 测试 ──────────────────────────────────────────
|
||||
# ── 测试 ──
|
||||
if(BUILD_TESTS)
|
||||
enable_testing()
|
||||
find_package(GTest QUIET)
|
||||
@@ -47,28 +47,17 @@ if(BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
# ── 示例 ──────────────────────────────────────────
|
||||
# ── Python 绑定 ────────────────────────────────────option(VDE_BUILD_PYTHON "Build Python bindings (pybind11)" OFF)if(VDE_BUILD_PYTHON) add_subdirectory(python)endif()
|
||||
# ── 示例 ──
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
# ── 性能测试 ──────────────────────────────────────
|
||||
# ── 性能测试 ──
|
||||
if(BUILD_BENCHMARKS)
|
||||
find_package(benchmark QUIET)
|
||||
if(NOT benchmark_FOUND)
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(googlebenchmark
|
||||
URL https://github.com/google/benchmark/archive/refs/tags/v1.8.0.tar.gz
|
||||
)
|
||||
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googlebenchmark)
|
||||
endif()
|
||||
add_subdirectory(benchmarks)
|
||||
endif()
|
||||
|
||||
# ── 安装 ──────────────────────────────────────────
|
||||
include(GNUInstallDirs)
|
||||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install(TARGETS vde EXPORT ViewDesignEngine-targets)
|
||||
install(EXPORT ViewDesignEngine-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ViewDesignEngine)
|
||||
# ── Python 绑定 ──
|
||||
if(VDE_BUILD_PYTHON)
|
||||
add_subdirectory(python)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user